Skip to content

Commit e621c70

Browse files
authored
[FLINK-21569][dependency] Upgrade flink-shaded-jackson version to 2.12.1-13.0
This closes #16642
1 parent 4e14b3f commit e621c70

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed

flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvFilesystemBatchITCase.java

+70
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818

1919
package org.apache.flink.formats.csv;
2020

21+
import org.apache.flink.table.api.config.ExecutionConfigOptions;
2122
import org.apache.flink.table.planner.runtime.batch.sql.BatchFileSystemITCaseBase;
23+
import org.apache.flink.table.planner.runtime.utils.BatchTestBase;
2224
import org.apache.flink.types.Row;
25+
import org.apache.flink.util.CollectionUtil;
2326
import org.apache.flink.util.FileUtils;
2427

28+
import org.junit.Assert;
2529
import org.junit.Test;
2630
import org.junit.experimental.runners.Enclosed;
2731
import org.junit.runner.RunWith;
@@ -90,4 +94,70 @@ public void testEscapeChar() throws Exception {
9094
Arrays.asList(Row.of("x5,5,1,1"), Row.of("x5,5,2,2")));
9195
}
9296
}
97+
98+
/**
99+
* IT case which checks for a bug in Jackson 2.10. When the 4000th character in csv file is the
100+
* new line character (\n) an exception will be thrown. After upgrading jackson to >= 2.11 this
101+
* bug should not exist anymore.
102+
*/
103+
public static class JacksonVersionUpgradeITCase extends BatchTestBase {
104+
105+
@Test
106+
public void testCsvFileWithNewLineAt4000() throws Exception {
107+
StringBuilder csvContent = new StringBuilder("# ");
108+
for (int i = 0; i < 97; i++) {
109+
csvContent.append("-");
110+
}
111+
csvContent.append("\n");
112+
for (int i = 0; i < 50; i++) {
113+
for (int j = 0; j < 49; j++) {
114+
csvContent.append("a");
115+
}
116+
csvContent.append(",");
117+
for (int j = 0; j < 49; j++) {
118+
csvContent.append("b");
119+
}
120+
csvContent.append("\n");
121+
}
122+
123+
File tempCsvFile = File.createTempFile("new-line-at-4000", ".csv");
124+
tempCsvFile.createNewFile();
125+
FileUtils.writeFileUtf8(tempCsvFile, csvContent.toString());
126+
127+
tEnv().getConfig()
128+
.getConfiguration()
129+
.setInteger(ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM, 1);
130+
tEnv().executeSql(
131+
"CREATE TABLE T (\n"
132+
+ " a VARCHAR,\n"
133+
+ " b VARCHAR\n"
134+
+ ") WITH (\n"
135+
+ " 'connector' = 'filesystem',\n"
136+
+ " 'path' = 'file://"
137+
+ tempCsvFile.toString()
138+
+ "',\n"
139+
+ " 'format' = 'csv',\n"
140+
+ " 'csv.allow-comments' = 'true'\n"
141+
+ ")")
142+
.await();
143+
List<Row> results =
144+
CollectionUtil.iteratorToList(
145+
tEnv().executeSql("SELECT a, b FROM T").collect());
146+
147+
Assert.assertEquals(50, results.size());
148+
for (Row actual : results) {
149+
StringBuilder a = new StringBuilder();
150+
for (int i = 0; i < 49; i++) {
151+
a.append("a");
152+
}
153+
StringBuilder b = new StringBuilder();
154+
for (int i = 0; i < 49; i++) {
155+
b.append("b");
156+
}
157+
Assert.assertEquals(2, actual.getArity());
158+
Assert.assertEquals(a.toString(), actual.getField(0));
159+
Assert.assertEquals(b.toString(), actual.getField(1));
160+
}
161+
}
162+
}
93163
}

pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ under the License.
123123
<zookeeper.version>3.4.14</zookeeper.version>
124124
<!-- Only the curator2 TestingServer works with ZK 3.4 -->
125125
<curator.version>2.12.0</curator.version>
126-
<jackson.version>2.10.1</jackson.version>
126+
<jackson.version>2.12.1</jackson.version>
127127
<prometheus.version>0.8.1</prometheus.version>
128128
<avro.version>1.10.0</avro.version>
129129
<javax.activation.api.version>1.2.0</javax.activation.api.version>
@@ -285,13 +285,13 @@ under the License.
285285
<dependency>
286286
<groupId>org.apache.flink</groupId>
287287
<artifactId>flink-shaded-jackson</artifactId>
288-
<version>${jackson.version}-${flink.shaded.version}</version>
288+
<version>${jackson.version}-13.0</version>
289289
</dependency>
290290

291291
<dependency>
292292
<groupId>org.apache.flink</groupId>
293293
<artifactId>flink-shaded-jackson-module-jsonSchema</artifactId>
294-
<version>${jackson.version}-${flink.shaded.version}</version>
294+
<version>${jackson.version}-13.0</version>
295295
</dependency>
296296

297297
<dependency>

0 commit comments

Comments
 (0)