Skip to content

Commit

Permalink
Fix a problem with ByteArrayBuilder.close() vs release()
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 19, 2024
1 parent f32c57d commit 4c0047e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ public int size() {
/**
* Clean up method to call to release all buffers this object may be
* using. After calling the method, no other accessors can be used (and
* attempt to do so may result in an exception)
* attempt to do so may result in an exception).
*<p>
* NOTE: calling {@link #close()} will implicitly call this method,
* as of Jackson 2.17.
*/
public void release() {
reset();
Expand Down Expand Up @@ -273,6 +276,10 @@ public void write(int b) {
append(b);
}

/**
* NOTE: calling this method will also implicitly call {@link #release()}
* (as of Jackson 2.17)
*/
@Override
public void close() {
// Since 2.17 release on close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void testBufferRecyclerReuse() throws Exception
assertSame(br, ((GeneratorBase) g).ioContext().bufferRecycler());
g.writeStartArray();
g.writeEndArray();
g.flush();
assertEquals("[]", new String(bab.toByteArray(), StandardCharsets.UTF_8));
}
assertEquals("[]", new String(bab.toByteArray(), StandardCharsets.UTF_8));
}
}

0 comments on commit 4c0047e

Please sign in to comment.