|
4 | 4 | import java.util.BitSet;
|
5 | 5 | import java.util.concurrent.atomic.AtomicReference;
|
6 | 6 |
|
| 7 | +import com.fasterxml.jackson.core.exc.StreamReadException; |
7 | 8 | import com.fasterxml.jackson.core.json.JsonFactory;
|
8 | 9 | import com.fasterxml.jackson.core.util.InternCache;
|
9 | 10 |
|
@@ -531,7 +532,7 @@ private void _handleSpillOverflow(int bucketIndex, Bucket newBucket, int mainInd
|
531 | 532 | if (_overflows.get(bucketIndex)) {
|
532 | 533 | // Has happened once already for this bucket index, so probably not coincidental...
|
533 | 534 | if (JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW.enabledIn(_flags)) {
|
534 |
| - reportTooManyCollisions(MAX_COLL_CHAIN_LENGTH); |
| 535 | + _reportTooManyCollisions(MAX_COLL_CHAIN_LENGTH); |
535 | 536 | }
|
536 | 537 | // but even if we don't fail, we will stop canonicalizing as safety measure
|
537 | 538 | // (so as not to cause problems with PermGen)
|
@@ -700,9 +701,13 @@ private void rehash() {
|
700 | 701 | }
|
701 | 702 | }
|
702 | 703 |
|
703 |
| - protected void reportTooManyCollisions(int maxLen) { |
704 |
| - throw new IllegalStateException("Longest collision chain in symbol table (of size "+_size |
705 |
| - +") now exceeds maximum, "+maxLen+" -- suspect a DoS attack based on hash collisions"); |
| 704 | + // 20-Mar-2021, tatu: [core#686]: should use Jackson-specific exception |
| 705 | + // (to use new "processing limit" exception when available) |
| 706 | + protected void _reportTooManyCollisions(int maxLen) { |
| 707 | + throw new StreamReadException(null, |
| 708 | +"Longest collision chain in symbol table (of size "+_size |
| 709 | ++") now exceeds maximum, "+maxLen+" -- suspect a DoS attack based on hash collisions." |
| 710 | ++" You can disable the check via `TokenStreamFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW`"); |
706 | 711 | }
|
707 | 712 |
|
708 | 713 | // Diagnostics method that will verify that internal data structures are consistent;
|
|
0 commit comments