Skip to content

Commit a71a00e

Browse files
committed
Add the failing test for #207
1 parent bcbc3df commit a71a00e

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/main/java/com/fasterxml/jackson/core/sym/ByteQuadsCanonicalizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public final class ByteQuadsCanonicalizer
151151
* Array that contains <code>String</code> instances matching
152152
* entries in {@link #_hashArea}.
153153
* Contains nulls for unused entries. Note that this size is twice
154-
* that o
154+
* that of {@link #_hashArea}
155155
*/
156156
protected String[] _names;
157157

@@ -1266,7 +1266,7 @@ public static TableInfo createInitial(int sz) {
12661266
0, // count
12671267
tertShift,
12681268
new int[hashAreaSize], // mainHash, 2x slots, 4 ints per slot
1269-
new String[sz << 1], // 2x slots
1269+
new String[sz << 1], // names == 2x slots
12701270
hashAreaSize - sz, // at 7/8 of the total area
12711271
hashAreaSize // longNameOffset, immediately after main hashes
12721272
);

src/test/java/com/fasterxml/jackson/core/sym/TestByteBasedSymbols.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.fasterxml.jackson.core.sym;
22

33
import java.io.*;
4+
import java.lang.reflect.Field;
45

56
import com.fasterxml.jackson.core.*;
67

78
/**
89
* Unit test(s) to verify that handling of (byte-based) symbol tables
9-
* is working. Created to verify fix to [JACKSON-5] (although not very
10-
* good at catching it...).
10+
* is working.
1111
*/
1212
public class TestByteBasedSymbols
1313
extends com.fasterxml.jackson.core.BaseTest
@@ -97,7 +97,29 @@ public void testAuxMethodsWithNewSymboTable() throws Exception
9797
*/
9898
assertNotNull(nc.toString());
9999
}
100-
100+
101+
// as per name, for [core#207]
102+
public void testIssue207() throws Exception
103+
{
104+
ByteQuadsCanonicalizer nc = ByteQuadsCanonicalizer.createRoot(-523743345);
105+
Field byteSymbolCanonicalizerField = JsonFactory.class.getDeclaredField("_byteSymbolCanonicalizer");
106+
byteSymbolCanonicalizerField.setAccessible(true);
107+
JsonFactory jsonF = new JsonFactory();
108+
byteSymbolCanonicalizerField.set(jsonF, nc);
109+
110+
StringBuilder stringBuilder = new StringBuilder();
111+
stringBuilder.append("{\n");
112+
stringBuilder.append(" \"expectedGCperPosition\": null");
113+
for (int i = 0; i < 60; ++i) {
114+
stringBuilder.append(",\n \"").append(i + 1).append("\": null");
115+
}
116+
stringBuilder.append("\n}");
117+
118+
JsonParser p = jsonF.createParser(stringBuilder.toString().getBytes("UTF-8"));
119+
while (p.nextToken() != null) { }
120+
p.close();
121+
}
122+
101123
/*
102124
/**********************************************************
103125
/* Helper methods

0 commit comments

Comments
 (0)