Skip to content

Commit

Permalink
Support closed flag on BufferBuilders
Browse files Browse the repository at this point in the history
Thanks to Moulberry for noting this vanilla change
  • Loading branch information
embeddedt committed Nov 2, 2023
1 parent 915de81 commit 86c6e90
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@Mixin(BufferBuilder.class)
public class BufferBuilderMixin {
@Shadow private ByteBuffer buffer;
@Shadow private boolean closed;

private static boolean leakReported = false;

Expand All @@ -30,7 +31,7 @@ protected void finalize() throws Throwable {
try {
ByteBuffer buf = buffer;
// can be null if a mod already tried to free the buffer
if(buf != null) {
if(!this.closed && buf != null) {
if(!leakReported) {
leakReported = true;
ModernFix.LOGGER.warn("One or more BufferBuilders have been leaked, ModernFix will attempt to correct this.");
Expand Down

0 comments on commit 86c6e90

Please sign in to comment.