Skip to content

Commit ff8b1cc

Browse files
committed
Minor tweaks post #948 wrt internal exceptions; update release notes
1 parent 25313f1 commit ff8b1cc

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ JSON library.
3737
allow for deferred decoding in some cases
3838
#921: Add `JsonFactory.Feature` to disable charset detection
3939
(contributed by @yawkat)
40+
#948: Use `StreamConstraintsException` in name canonicalizers
41+
(contributed by @pjfanning)
4042
- Build uses package type "jar" but still produces valid OSGi bundle
4143
(changed needed to keep class timestamps with Reproducible Build)
4244

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,16 +990,16 @@ public String addName(String name, int[] q, int qlen) throws StreamConstraintsEx
990990
return name;
991991
}
992992

993-
private void _verifySharing() throws StreamConstraintsException
993+
private void _verifySharing()
994994
{
995995
if (_hashShared) {
996996
// 12-Mar-2021, tatu: prevent modifying of "placeholder" and
997997
// parent tables
998998
if (_parent == null) {
999999
if (_count == 0) { // root
1000-
throw new StreamConstraintsException("Cannot add names to Root symbol table");
1000+
throw new IllegalStateException("Internal error: Cannot add names to Root symbol table");
10011001
}
1002-
throw new StreamConstraintsException("Cannot add names to Placeholder symbol table");
1002+
throw new IllegalStateException("Internal error: Cannot add names to Placeholder symbol table");
10031003
}
10041004

10051005
_hashArea = Arrays.copyOf(_hashArea, _hashArea.length);
@@ -1314,7 +1314,7 @@ private void rehash() throws StreamConstraintsException
13141314
// Sanity checks: since corruption difficult to detect, assert explicitly
13151315
// with production code
13161316
if (copyCount != oldCount) {
1317-
throw new StreamConstraintsException("Failed rehash(): old count="+oldCount+", copyCount="+copyCount);
1317+
throw new IllegalStateException("Internal error: Failed rehash(), old count="+oldCount+", copyCount="+copyCount);
13181318
}
13191319
}
13201320

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,9 @@ protected void _reportTooManyCollisions(int maxLen) throws StreamConstraintsExce
725725
* Diagnostics method that will verify that internal data structures are consistent;
726726
* not meant as user-facing method but only for test suites and possible troubleshooting.
727727
*
728-
* @throws StreamConstraintsException if the size does not match what is expected
729728
* @since 2.10
730729
*/
731-
protected void verifyInternalConsistency() throws IOException {
730+
protected void verifyInternalConsistency() {
732731
int count = 0;
733732
final int size = _symbols.length;
734733

@@ -746,7 +745,7 @@ protected void verifyInternalConsistency() throws IOException {
746745
}
747746
}
748747
if (count != _size) {
749-
throw new StreamConstraintsException(
748+
throw new IllegalStateException(
750749
String.format("Internal error: expected internal size %d vs calculated count %d",
751750
_size, count));
752751
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testIssue207() throws Exception
122122
}
123123

124124
// [core#548]
125-
public void testQuadsIssue548() throws IOException
125+
public void testQuadsIssue548() throws Exception
126126
{
127127
Random r = new Random(42);
128128
ByteQuadsCanonicalizer root = ByteQuadsCanonicalizer.createRoot();
@@ -170,7 +170,7 @@ public void testQuadsIssue548() throws IOException
170170
/**********************************************************
171171
*/
172172

173-
protected JsonParser createParser(JsonFactory jf, String input) throws IOException
173+
protected JsonParser createParser(JsonFactory jf, String input) throws Exception
174174
{
175175
byte[] data = input.getBytes(StandardCharsets.UTF_8);
176176
InputStream is = new ByteArrayInputStream(data);

0 commit comments

Comments
 (0)