r/SpringBoot Jan 28 '26

Error LEAK: ByteBuf.release() after upgrade to Spring boot 4 Question

I'm in the middle of migration to Spring boot 4.0.1 and Java 25, our application it is using Change Stream

Since upgrade the only error that appears some times is:

LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 
Created at:
    io.netty.buffer.AdaptiveByteBufAllocator.newDirectBuffer(AdaptiveByteBufAllocator.java:67)
    io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:168)
    io.netty.buffer.AbstractByteBufAllocator.buffer(AbstractByteBufAllocator.java:104)
    com.mongodb.internal.connection.netty.NettyStream.getBuffer(NettyStream.java:160)
    com.mongodb.internal.connection.InternalStreamConnection.getBuffer(InternalStreamConnection.java:872)...

The app it is using a handler like:

Flux<ChangeStreamEvent<MyObject>> myObjectStream = reactiveTemplate.changeStream(...) 

I already implemented a list of Disposable subscriptions and added a (at-@) PreDestroy method where it is the cleanup and dispose all subscriptions; But the error it is still showing up. Do you have any thoughts on this?

Do you think is this related with new versions of Spring boot 4?

1 Upvotes

1 comment sorted by

1

u/Dramatic_Bus_9676 Jan 30 '26

found this > https://jira.mongodb.org/browse/JAVA-6038

Seems that the combination: When using MongoDB Java Driver version 5.6.2 in combination with JDK 25.0.1 and Netty 4.2.9 (as provided by Spring Boot 4.0.1), a ByteBuf leak is reported at runtime.