Skip to content

Commit d533f29

Browse files
committed
Fix #152 in 2.4
1 parent 63a87b9 commit d533f29

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

release-notes/VERSION

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
Project: jackson-core
2-
Version: 2.4.2 (13-Aug-2014)
2+
Version: 2.4.3 (xx-xxx-2014)
33

4-
#145: NPE at BytesToNameCanonicalizer
5-
(reported by Shay B)
6-
#146: Error while parsing negative floats at the end of the input buffer
7-
(reported by rjmac@github)
4+
#152: Exception for property names longer than 256k
5+
(reported by CrendKing@github)
86

97
------------------------------------------------------------------------
108
=== History: ===
119
------------------------------------------------------------------------
1210

11+
2.4.2 (13-Aug-2014)
12+
13+
#145: NPE at BytesToNameCanonicalizer
14+
(reported by Shay B)
15+
#146: Error while parsing negative floats at the end of the input buffer
16+
(reported by rjmac@github)
17+
1318
2.4.1 (16-Jun-2014)
1419

1520
#143: Flaw in `BufferRecycler.allocByteBuffer(int,int)` that results in

src/main/java/com/fasterxml/jackson/core/util/TextBuffer.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,13 @@ public char[] finishCurrentSegment() {
580580
public char[] expandCurrentSegment()
581581
{
582582
final char[] curr = _currentSegment;
583-
// Let's grow by 50%
583+
// Let's grow by 50% by default
584584
final int len = curr.length;
585-
// Must grow by at least 1 char, no matter what
586-
int newLen = (len == MAX_SEGMENT_LEN) ? (MAX_SEGMENT_LEN+1) : Math.min(MAX_SEGMENT_LEN, len + (len >> 1));
585+
int newLen = len + (len >> 1);
586+
// but above intended maximum, slow to increase by 25%
587+
if (newLen > MAX_SEGMENT_LEN) {
588+
newLen = len + (len >> 2);
589+
}
587590
return (_currentSegment = Arrays.copyOf(curr, newLen));
588591
}
589592

src/test/java/com/fasterxml/jackson/core/util/TestTextBuffer.java

+15
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,19 @@ public void testLongAppend()
6262
assertEquals(len+2, tb.size());
6363
assertEquals(EXP, tb.contentsAsString());
6464
}
65+
66+
// [Core#152]
67+
public void testExpand()
68+
{
69+
TextBuffer tb = new TextBuffer(new BufferRecycler());
70+
char[] buf = tb.getCurrentSegment();
71+
72+
while (buf.length < 500 * 1000) {
73+
char[] old = buf;
74+
buf = tb.expandCurrentSegment();
75+
if (old.length >= buf.length) {
76+
fail("Expected buffer of "+old.length+" to expand, did not, length now "+buf.length);
77+
}
78+
}
79+
}
6580
}

0 commit comments

Comments
 (0)