This repository was archived by the owner on Jan 22, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +50
-4
lines changed
main/java/com/fasterxml/jackson/dataformat/csv/impl
test/java/com/fasterxml/jackson/dataformat/csv Expand file tree Collapse file tree 4 files changed +50
-4
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,9 @@ Jason Dunkelberger (dirkraft@github)
22
22
23
23
* Suggested #32: Allow disabling of quoteChar
24
24
(2.4.0)
25
+
26
+ Wei Li (wli600@github)
27
+
28
+ * Contributed fix for 54: Encounter ArrayIndexOutOfBoundsException in the corner case delimiter
29
+ or end-of-line happened to be the leading character of a segment buffer
30
+ (2.4.4)
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ Project: jackson-dataformat-csv
9
9
#53: Add a way to specify "null value" (String) for `CsvGenerator` to use when writing `null`s
10
10
(part of `CsvSchema`; method `withNullValue()`)
11
11
12
+ 2.4.4 (not yet released)
13
+
14
+ #54: Encounter ArrayIndexOutOfBoundsException in the corner case delimiter or end-of-line
15
+ happened to be the leading character of a segment buffer
16
+ (contributed by wli600@github)
17
+
12
18
2.4.3 (04-Oct-2014)
13
19
14
20
- Support JDK serializability of CsvMapper
Original file line number Diff line number Diff line change @@ -404,16 +404,17 @@ public int getCurrentSegmentSize() {
404
404
}
405
405
406
406
/**
407
- *
408
- * @param lastSegmentEnd End offset in the currently active segment
407
+ * @param lastSegmentEnd End offset in the currently active segment,
408
+ * could be 0 in the case of first character is
409
+ * delimiter or end-of-line
409
410
* @param trimTrailingSpaces Whether trailing spaces should be trimmed or not
410
411
*/
411
412
public String finishAndReturn (int lastSegmentEnd , boolean trimTrailingSpaces )
412
413
{
413
414
if (trimTrailingSpaces ) {
414
415
// First, see if it's enough to trim end of current segment:
415
- int ptr = lastSegmentEnd - 1 ;
416
- if (_currentSegment [ptr ] <= 0x0020 ) {
416
+ int ptr = lastSegmentEnd - 1 ;
417
+ if (ptr < 0 || _currentSegment [ptr ] <= 0x0020 ) {
417
418
return _doTrim (ptr );
418
419
}
419
420
}
Original file line number Diff line number Diff line change @@ -120,4 +120,37 @@ public void testUntypedAsSequenceVarLengths() throws Exception
120
120
it .close ();
121
121
}
122
122
123
+ // [Issue#54]
124
+ public void testDelimiterAtBufferBoundary () throws Exception
125
+ {
126
+ CsvMapper mapper = mapperForCsv ();
127
+ mapper .enable (CsvParser .Feature .TRIM_SPACES );
128
+
129
+ final String col1 = "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" +
130
+ "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" +
131
+ "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" +
132
+ "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" ;
133
+ final String col2 = "H" ;
134
+
135
+ CsvParser cp = mapper .getFactory ().createParser (col1 + " ," + col2 +"\n " + col2 + "," + col1 + "\n " );
136
+ MappingIterator <Object []> it = mapper .reader (Object [].class ).readValues (cp );
137
+
138
+ Object [] row ;
139
+
140
+ assertTrue (it .hasNext ());
141
+ row = it .next ();
142
+ assertEquals (2 , row .length );
143
+ assertEquals (col1 , row [0 ]);
144
+ assertEquals (col2 , row [1 ]);
145
+
146
+ assertTrue (it .hasNext ());
147
+ row = it .next ();
148
+ assertEquals (2 , row .length );
149
+ assertEquals (col2 , row [0 ]);
150
+ assertEquals (col1 , row [1 ]);
151
+
152
+ cp .close ();
153
+ it .close ();
154
+ }
155
+
123
156
}
You can’t perform that action at this time.
0 commit comments