+1 When using objects allocated from Netty's Recycler inside a callback thread, there is a risk that the object has already been recycled and reused by another thread. This can lead to subtle use-after-recycle bugs that manifest as corrupted state or unexpected exceptions, making them extremely difficult to troubleshoot.
Thanks, Zixuan Yunze Xu <[email protected]> 于2025年9月12日周五 23:40写道: > Hi all, > > Following the previous few discussions [1][2][3] about the Netty > Recycler, I revisited it again by looking into the implementation and > running some benchmarks. > > In short, I suggest stopping using Netty Recycler in new code. It's > okay to leave existing use cases of Recycler to avoid unnecessary code > refactorings. But if these hard-to-use recycler based classes make new > code hard to write, it should be reasonable to remove them when > necessary. > > I wrote a blog here [4] to share my thoughts. Feel free to leave any > comment. > > [1] https://lists.apache.org/thread/xv9p68f3jx64vjq82nh4tscmmcw5n8pd > [2] https://lists.apache.org/thread/po08w0tkhc7q8gc5khpdft6stxnr1v2y > [3] https://lists.apache.org/thread/7pwywp5n6kb9ccwfvw0n5jqtsq9o3gtq > [4] https://gist.github.com/BewareMyPower/5dac596a2f48b54c9a6d2223cdaa12c9 > > Thanks, > Yunze >
