lingdongs opened a new issue, #5987:
URL: https://github.com/apache/shenyu/issues/5987

   ### Is there an existing issue for this?
   
   - [x] I have searched the existing issues
   
   ### Current Behavior
   
   2025-03-31 11:16:33 [reactor-http-epoll-6] ERROR 
io.netty.util.ResourceLeakDetector - 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: 
   #1:
        
io.netty.buffer.AdvancedLeakAwareCompositeByteBuf.readBytes(AdvancedLeakAwareCompositeByteBuf.java:476)
        
io.netty.buffer.AdvancedLeakAwareCompositeByteBuf.readBytes(AdvancedLeakAwareCompositeByteBuf.java:36)
        
org.springframework.core.io.buffer.NettyDataBuffer.read(NettyDataBuffer.java:159)
        
org.springframework.core.io.buffer.NettyDataBuffer.read(NettyDataBuffer.java:43)
        
org.apache.shenyu.plugin.base.support.ResponseDecorator.lambda$writeWith$0(ResponseDecorator.java:54)
        
reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125)
        
reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107)
        
reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299)
        
reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337)
        
reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1839)
        
reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160)
        
reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
        
reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
        
reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
        
reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:413)
        
reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:437)
        
reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:491)
        
reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:753)
        
reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:114)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        
io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
        
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
        
io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:405)
        
io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:376)
        
io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:328)
        
io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:221)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
        
io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
        
io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
        
io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)
        
io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813)
        
io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
        
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
        
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
        io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413)
        
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        java.lang.Thread.run(Thread.java:748)
   #2:
        
io.netty.buffer.AdvancedLeakAwareCompositeByteBuf.addComponent(AdvancedLeakAwareCompositeByteBuf.java:920)
        
org.springframework.core.io.buffer.NettyDataBufferFactory.join(NettyDataBufferFactory.java:111)
        
org.springframework.core.io.buffer.DataBufferUtils.lambda$join$20(DataBufferUtils.java:584)
        
reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:283)
        
reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337)
        
reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1839)
        
reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160)
        
reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
        
reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
        
reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
        
reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:413)
        
reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:437)
        
reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:491)
        
reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:753)
        
reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:114)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        
io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
        
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
        
io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:405)
        
io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:376)
        
io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:328)
        
io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:221)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
        
io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
        
io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
        
io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)
        
io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813)
        
io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
        
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
        
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
        io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413)
        
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        java.lang.Thread.run(Thread.java:748)
   Created at:
        
io.netty.buffer.UnpooledByteBufAllocator.compositeDirectBuffer(UnpooledByteBufAllocator.java:108)
        
io.netty.buffer.AbstractByteBufAllocator.compositeBuffer(AbstractByteBufAllocator.java:202)
        
org.springframework.core.io.buffer.NettyDataBufferFactory.join(NettyDataBufferFactory.java:108)
        
org.springframework.core.io.buffer.DataBufferUtils.lambda$join$20(DataBufferUtils.java:584)
        
reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:283)
        
reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337)
        
reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1839)
        
reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160)
        
reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
        
reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
        
reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
        
reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:413)
        
reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:437)
        
reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:491)
        
reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:753)
        
reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:114)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        
io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
        
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
        
io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:405)
        
io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:376)
        
io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:328)
        
io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:221)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
        
io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
        
io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301)
        
io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
        
io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)
        
io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813)
        
io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
        
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
        
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
        io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413)
        
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        java.lang.Thread.run(Thread.java:748)
   : 12 leak records were discarded because they were duplicates
   2025-03-31 11:16:33 [reactor-http-epoll-6] ERROR 
io.netty.util.ResourceLeakDetector - 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: 
   
   ### Expected Behavior
   
   I've modified some encryption and decryption code, but I'm not sure if this 
is the reason for the memory leak. 
   On the left side of the image is the code I modified, and on the right side 
is the 2.6.1 release code.
   
   
![Image](https://github.com/user-attachments/assets/a07775ce-06ab-42c8-b987-8970bce75818)
   
   
![Image](https://github.com/user-attachments/assets/13251e5b-248c-421a-a37d-668ec4915745)
   
   
![Image](https://github.com/user-attachments/assets/54be78b5-0115-49fd-9ad1-d2a5f52d8a22)
   
   
![Image](https://github.com/user-attachments/assets/292a31f8-7066-4134-b0b2-133f51e840ed)
   
   [code.zip](https://github.com/user-attachments/files/19531153/code.zip)
   
   ### Steps To Reproduce
   
   _No response_
   
   ### Environment
   
   ```markdown
   ShenYu version(s):2.6.1
   ```
   
   ### Debug logs
   
   
   I enabled some Netty configurations to see this log. 
   -Dio.netty.leakDetection.level=PARANOID
   -Dio.netty.leakDetection.targetRecords=20
   The complete logs and modified code are in the attachments.
   
   
[shenyu-bootstrap-error.log](https://github.com/user-attachments/files/19531038/shenyu-bootstrap-error.log)
   
   
![Image](https://github.com/user-attachments/assets/00a9868b-a54c-4b5e-89c7-e6c1718950d9)
   
   
![Image](https://github.com/user-attachments/assets/477a8664-de93-4514-8104-dca214d4a86e)
   
   
![Image](https://github.com/user-attachments/assets/6080f05e-8695-4c4a-a9c9-47b89750c04a)
   
   
![Image](https://github.com/user-attachments/assets/b01b49ed-ea43-45a6-9b7c-c0bfbb8e2dc4)
   
   ### Anything else?
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@shenyu.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to