Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 14, 2024
2 parents 3ca4cf5 + ec4ef5e commit b80bca3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
with:
sarif_file: results.sarif
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ a pure JSON library.
#1179: Allow configuring `DefaultPrettyPrinter` separators for empty
Arrays and Objects
(contributed by Guillaume L)
#1186: `BufferRecycler` should avoid setting replacement if one already returned, bigger
(suggested by @kkkkkhhhh)

2.16.2 (not yet released)

Expand Down
14 changes: 12 additions & 2 deletions src/main/java/tools/jackson/core/util/BufferRecycler.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ public byte[] allocByteBuffer(int ix, int minSize) {
}

public void releaseByteBuffer(int ix, byte[] buffer) {
_byteBuffers.set(ix, buffer);
// 13-Jan-2024, tatu: [core#1186] Replace only if beneficial:
byte[] oldBuffer = _byteBuffers.get(ix);
if ((oldBuffer == null) || buffer.length > oldBuffer.length) {
// Could use CAS, but should not really matter
_byteBuffers.set(ix, buffer);
}
}

/*
Expand All @@ -167,7 +172,12 @@ public char[] allocCharBuffer(int ix, int minSize) {
}

public void releaseCharBuffer(int ix, char[] buffer) {
_charBuffers.set(ix, buffer);
// 13-Jan-2024, tatu: [core#1186] Replace only if beneficial:
char[] oldBuffer = _charBuffers.get(ix);
if ((oldBuffer == null) || buffer.length > oldBuffer.length) {
// Could use CAS, but should not really matter
_charBuffers.set(ix, buffer);
}
}

/*
Expand Down

0 comments on commit b80bca3

Please sign in to comment.