Skip to content

Commit

Permalink
Minor tweaks post #948 wrt internal exceptions; update release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 14, 2023
1 parent 25313f1 commit ff8b1cc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Expand Up @@ -37,6 +37,8 @@ JSON library.
allow for deferred decoding in some cases
#921: Add `JsonFactory.Feature` to disable charset detection
(contributed by @yawkat)
#948: Use `StreamConstraintsException` in name canonicalizers
(contributed by @pjfanning)
- Build uses package type "jar" but still produces valid OSGi bundle
(changed needed to keep class timestamps with Reproducible Build)

Expand Down
Expand Up @@ -990,16 +990,16 @@ public String addName(String name, int[] q, int qlen) throws StreamConstraintsEx
return name;
}

private void _verifySharing() throws StreamConstraintsException
private void _verifySharing()
{
if (_hashShared) {
// 12-Mar-2021, tatu: prevent modifying of "placeholder" and
// parent tables
if (_parent == null) {
if (_count == 0) { // root
throw new StreamConstraintsException("Cannot add names to Root symbol table");
throw new IllegalStateException("Internal error: Cannot add names to Root symbol table");
}
throw new StreamConstraintsException("Cannot add names to Placeholder symbol table");
throw new IllegalStateException("Internal error: Cannot add names to Placeholder symbol table");
}

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

Expand Down
Expand Up @@ -725,10 +725,9 @@ protected void _reportTooManyCollisions(int maxLen) throws StreamConstraintsExce
* Diagnostics method that will verify that internal data structures are consistent;
* not meant as user-facing method but only for test suites and possible troubleshooting.
*
* @throws StreamConstraintsException if the size does not match what is expected
* @since 2.10
*/
protected void verifyInternalConsistency() throws IOException {
protected void verifyInternalConsistency() {
int count = 0;
final int size = _symbols.length;

Expand All @@ -746,7 +745,7 @@ protected void verifyInternalConsistency() throws IOException {
}
}
if (count != _size) {
throw new StreamConstraintsException(
throw new IllegalStateException(
String.format("Internal error: expected internal size %d vs calculated count %d",
_size, count));
}
Expand Down
Expand Up @@ -122,7 +122,7 @@ public void testIssue207() throws Exception
}

// [core#548]
public void testQuadsIssue548() throws IOException
public void testQuadsIssue548() throws Exception
{
Random r = new Random(42);
ByteQuadsCanonicalizer root = ByteQuadsCanonicalizer.createRoot();
Expand Down Expand Up @@ -170,7 +170,7 @@ public void testQuadsIssue548() throws IOException
/**********************************************************
*/

protected JsonParser createParser(JsonFactory jf, String input) throws IOException
protected JsonParser createParser(JsonFactory jf, String input) throws Exception
{
byte[] data = input.getBytes(StandardCharsets.UTF_8);
InputStream is = new ByteArrayInputStream(data);
Expand Down

0 comments on commit ff8b1cc

Please sign in to comment.