Ver Fonte

fix bug: byteBuf没有回收

vinson há 5 anos atrás
pai
commit
99c2593355

+ 11 - 4
src/main/java/com/tidecloud/dataacceptance/service/impl/GK309GpsServerHandler.java

@@ -156,9 +156,17 @@ public class GK309GpsServerHandler extends HexBinaryAcceptanceHandlerAdapter {
 
 
                 // 根据文档查看上下班标示
-                ByteBuf byteBuf = in.readBytes(13);
-                byteBuf.skipBytes(12);
-                byte b = byteBuf.readByte();
+                ByteBuf byteBuf = null;
+                byte b;
+                try {
+                    byteBuf = in.readBytes(13);
+                    byteBuf.skipBytes(12);
+                    b = byteBuf.readByte();
+                } finally {
+                    if (byteBuf != null) {
+                        byteBuf.release();
+                    }
+                }
                 // 2-5位代表是上班还是下班
                 byte i = (byte) (b & MARK);
 
@@ -170,7 +178,6 @@ public class GK309GpsServerHandler extends HexBinaryAcceptanceHandlerAdapter {
                     signResponse = 0x02;
                 }
 
-
                 // 减去前面跳过的第一位和前面跳过的7位,再减去最后的四位(序列号本身的2位+校验位2位)
                 in.skipBytes(length - 8 - 2 - 2 - 15);
                 short serNum = in.readShort();