mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 19:29:52 +08:00
手动释放对象
This commit is contained in:
@@ -8,6 +8,7 @@ import com.jsowell.netty.service.electricbicycles.EBikeBusinessService;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.handler.timeout.ReadTimeoutException;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -60,6 +61,7 @@ public class ElectricBicyclesServerHandler extends ChannelInboundHandlerAdapter
|
||||
*/
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
|
||||
try {
|
||||
byte[] msg = (byte[]) message;
|
||||
// 处理数据
|
||||
byte[] response = eBikeService.process(msg, ctx);
|
||||
@@ -79,6 +81,10 @@ public class ElectricBicyclesServerHandler extends ChannelInboundHandlerAdapter
|
||||
// BytesUtil.binary(response, 16));
|
||||
// }
|
||||
}
|
||||
} finally {
|
||||
ReferenceCountUtil.release(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user