Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 9, 2024
2 parents 429efc9 + 818647a commit b794405
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/main/java/tools/jackson/core/sym/ByteQuadsCanonicalizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1107,22 +1107,27 @@ private boolean _checkNeedForRehash() {
return false;
}

private int _appendLongName(int[] quads, int qlen)
private int _appendLongName(final int[] quads, final int qlen)
{
int start = _longNameOffset;
final int start = _longNameOffset;
final int newStart = start + qlen;
if (newStart < 0) {
throw new IllegalStateException(String.format(
"Internal error: long name offset overflow; start=%s, qlen=%s", start, qlen));
}

// note: at this point we must already be shared. But may not have enough space
if ((start + qlen) > _hashArea.length) {
// note: at this point we must already be unshared. But may not have enough space
if (newStart > _hashArea.length) {
// try to increment in reasonable chunks; at least space that we need
int toAdd = (start + qlen) - _hashArea.length;
int toAdd = newStart - _hashArea.length;
// but at least 1/8 of regular hash area size or 16kB (whichever smaller)
int minAdd = Math.min(4096, _hashSize);

int newSize = _hashArea.length + Math.max(toAdd, minAdd);
_hashArea = Arrays.copyOf(_hashArea, newSize);
}
System.arraycopy(quads, 0, _hashArea, start, qlen);
_longNameOffset += qlen;
_longNameOffset = newStart;
return start;
}

Expand Down Expand Up @@ -1252,9 +1257,8 @@ private void rehash() throws StreamConstraintsException
final int newSize = oldSize + oldSize;
final int oldEnd = _spilloverEnd;

/* 13-Mar-2010, tatu: Let's guard against OOME that could be caused by
* large documents with unique (or mostly so) names
*/
// 13-Mar-2010, tatu: Let's guard against OOME that could be caused by
// large documents with unique (or mostly so) names
if (newSize > MAX_T_SIZE) {
nukeSymbols(true);
return;
Expand Down

0 comments on commit b794405

Please sign in to comment.