aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-10 10:55:06 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-10 10:55:06 +1200
commit1dc1e06cfd4b7b23775984a254723b2d06b4f1dd (patch)
tree6dd89b120a7400ff3f08b2cb213cadc27112d0e7 /src/org
parent58a222ba3d546dc2366586f2c904e70680a394bd (diff)
downloadtraccar-server-1dc1e06cfd4b7b23775984a254723b2d06b4f1dd.tar.gz
traccar-server-1dc1e06cfd4b7b23775984a254723b2d06b4f1dd.tar.bz2
traccar-server-1dc1e06cfd4b7b23775984a254723b2d06b4f1dd.zip
Handle buffers reference count
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/DmtProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/EgtsProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/HuaShengFrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/HuabaoFrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/HuabaoProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/MxtFrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/ObdDongleProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Tk102ProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/UlbotechFrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/Vt200FrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/WatchFrameDecoder.java2
18 files changed, 52 insertions, 35 deletions
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index 1be66b17d..344ca2df4 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -205,6 +205,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
response.writeShort(type);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
response.writeShortLE(
Checksum.crc16(Checksum.CRC16_X25, response.nioBuffer(0, response.writerIndex())));
@@ -296,7 +297,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
|| type == MSG_SC_ALARM || type == MSG_SC_CURRENT_LOCATION || type == MSG_SC_FUEL) {
if (type == MSG_SC_LOGIN) {
- ByteBuf response = Unpooled.buffer(10); // TODO ref count
+ ByteBuf response = Unpooled.buffer(10);
response.writeIntLE(0xFFFFFFFF);
response.writeShortLE(0);
response.writeIntLE((int) (System.currentTimeMillis() / 1000));
diff --git a/src/org/traccar/protocol/DmtProtocolDecoder.java b/src/org/traccar/protocol/DmtProtocolDecoder.java
index 637b9f9ca..613b8cddd 100644
--- a/src/org/traccar/protocol/DmtProtocolDecoder.java
+++ b/src/org/traccar/protocol/DmtProtocolDecoder.java
@@ -58,6 +58,7 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
response.writeShortLE(content != null ? content.readableBytes() : 0);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
@@ -244,7 +245,7 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession = getDeviceSession(
channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII));
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
if (length == 51) {
response.writeByte(0); // reserved
response.writeIntLE(0); // reserved
@@ -257,13 +258,13 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_COMMIT) {
- ByteBuf response = Unpooled.buffer(0); // TODO ref count
+ ByteBuf response = Unpooled.buffer(0);
response.writeByte(1); // flags (success)
sendResponse(channel, MSG_COMMIT_RESPONSE, response);
} else if (type == MSG_CANNED_REQUEST_1) {
- ByteBuf response = Unpooled.buffer(0); // TODO ref count
+ ByteBuf response = Unpooled.buffer(0);
response.writeBytes(new byte[12]);
sendResponse(channel, MSG_CANNED_RESPONSE_1, response);
diff --git a/src/org/traccar/protocol/EgtsProtocolDecoder.java b/src/org/traccar/protocol/EgtsProtocolDecoder.java
index 5b1b49370..45e191d1e 100644
--- a/src/org/traccar/protocol/EgtsProtocolDecoder.java
+++ b/src/org/traccar/protocol/EgtsProtocolDecoder.java
@@ -75,12 +75,13 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
Channel channel, int packetType, int index, int serviceType, int type, ByteBuf content) {
if (channel != null) {
- ByteBuf data = Unpooled.buffer(); // TODO ref count
+ ByteBuf data = Unpooled.buffer();
data.writeByte(type);
data.writeShortLE(content.readableBytes());
data.writeBytes(content);
+ content.release();
- ByteBuf record = Unpooled.buffer(); // TODO ref count
+ ByteBuf record = Unpooled.buffer();
if (packetType == PT_RESPONSE) {
record.writeShortLE(index);
record.writeByte(0); // success
@@ -91,6 +92,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
record.writeByte(serviceType);
record.writeByte(serviceType);
record.writeBytes(data);
+ data.release();
int recordChecksum = Checksum.crc16(Checksum.CRC16_CCITT_FALSE, record.nioBuffer());
ByteBuf response = Unpooled.buffer();
@@ -104,6 +106,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(packetType);
response.writeByte(Checksum.crc8(Checksum.CRC8_EGTS, response.nioBuffer()));
response.writeBytes(record);
+ record.release();
response.writeShortLE(recordChecksum);
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
@@ -150,7 +153,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
}
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
response.writeShortLE(recordIndex);
response.writeByte(0); // success
sendResponse(channel, PT_RESPONSE, index, serviceType, MSG_RECORD_RESPONSE, response);
@@ -189,7 +192,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII).trim());
}
- response = Unpooled.buffer(); // TODO ref count
+ response = Unpooled.buffer();
response.writeByte(0); // success
sendResponse(channel, PT_APPDATA, 0, serviceType, MSG_RESULT_CODE, response);
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 22391c750..fa4ed417d 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -178,6 +178,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(type);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
response.writeShort(index);
response.writeShort(Checksum.crc16(Checksum.CRC16_X25,
@@ -189,7 +190,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private void sendPhotoRequest(Channel channel, int pictureId) {
ByteBuf photo = photos.get(pictureId);
- ByteBuf content = Unpooled.buffer(); // TODO ref count
+ ByteBuf content = Unpooled.buffer();
content.writeInt(pictureId);
content.writeInt(photo.writerIndex());
content.writeShort(Math.min(photo.writableBytes(), 1024));
@@ -437,7 +438,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_ADDRESS_REQUEST) {
String response = "NA&&NA&&0##";
- ByteBuf content = Unpooled.buffer(); // TODO ref count
+ ByteBuf content = Unpooled.buffer();
content.writeByte(response.length());
content.writeInt(0);
content.writeBytes(response.getBytes(StandardCharsets.US_ASCII));
@@ -446,7 +447,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_TIME_REQUEST) {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- ByteBuf content = Unpooled.buffer(); // TODO ref count
+ ByteBuf content = Unpooled.buffer();
content.writeByte(calendar.get(Calendar.YEAR) - 2000);
content.writeByte(calendar.get(Calendar.MONTH) + 1);
content.writeByte(calendar.get(Calendar.DAY_OF_MONTH));
@@ -484,7 +485,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // photo source
buf.readUnsignedByte(); // picture format
- ByteBuf photo = Unpooled.buffer(buf.readInt()); // TODO release photo
+ ByteBuf photo = Unpooled.buffer(buf.readInt());
int pictureId = buf.readInt();
photos.put(pictureId, photo);
sendPhotoRequest(channel, pictureId);
@@ -719,7 +720,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
Device device = Context.getDeviceManager().getById(deviceSession.getDeviceId());
position.set(
Position.KEY_IMAGE, Context.getMediaManager().writeFile(device.getUniqueId(), photo, "jpg"));
- photos.remove(pictureId);
+ photos.remove(pictureId).release();
}
} else if (type == MSG_AZ735_GPS || type == MSG_AZ735_ALARM) {
diff --git a/src/org/traccar/protocol/HuaShengFrameDecoder.java b/src/org/traccar/protocol/HuaShengFrameDecoder.java
index f9fbc5554..bd52aa9e7 100644
--- a/src/org/traccar/protocol/HuaShengFrameDecoder.java
+++ b/src/org/traccar/protocol/HuaShengFrameDecoder.java
@@ -33,7 +33,7 @@ public class HuaShengFrameDecoder extends BaseFrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0xC0);
if (index != -1) {
- ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
index 7b09b5854..ae57ef296 100644
--- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -53,6 +53,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
response.writeInt(index);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
response.writeByte(0xC0);
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
@@ -84,7 +85,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
String imei = buf.readSlice(length).toString(StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null && channel != null) {
- ByteBuf content = Unpooled.buffer(); // TODO ref count
+ ByteBuf content = Unpooled.buffer();
content.writeByte(0); // success
sendResponse(channel, MSG_LOGIN_RSP, index, content);
}
diff --git a/src/org/traccar/protocol/HuabaoFrameDecoder.java b/src/org/traccar/protocol/HuabaoFrameDecoder.java
index 1e98f9f12..b520f6be9 100644
--- a/src/org/traccar/protocol/HuabaoFrameDecoder.java
+++ b/src/org/traccar/protocol/HuabaoFrameDecoder.java
@@ -33,7 +33,7 @@ public class HuabaoFrameDecoder extends BaseFrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x7e);
if (index != -1) {
- ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
index 7546b75a8..afb29e3c3 100644
--- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -56,6 +56,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
buf.writeBytes(id);
buf.writeShort(1); // index
buf.writeBytes(data);
+ data.release();
buf.writeByte(Checksum.xor(buf.nioBuffer(1, buf.readableBytes() - 1)));
buf.writeByte(0x7e);
return buf;
@@ -64,7 +65,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
private void sendGeneralResponse(
Channel channel, SocketAddress remoteAddress, ByteBuf id, int type, int index) {
if (channel != null) {
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
response.writeShort(index);
response.writeShort(type);
response.writeByte(RESULT_SUCCESS);
@@ -119,7 +120,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_TERMINAL_REGISTER) {
if (channel != null) {
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
response.writeShort(index);
response.writeByte(RESULT_SUCCESS);
response.writeBytes("authentication".getBytes(StandardCharsets.US_ASCII));
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 738610cac..30905076e 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -189,7 +189,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
if (channel != null) {
ByteBuf buf = Unpooled.buffer(
- 2 + 2 + id.readableBytes() + 2 + msg.readableBytes() + 2 + 2); // TODO ref count
+ 2 + 2 + id.readableBytes() + 2 + msg.readableBytes() + 2 + 2);
buf.writeByte('@');
buf.writeByte('@');
@@ -197,6 +197,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
buf.writeBytes(id);
buf.writeShort(type);
buf.writeBytes(msg);
+ msg.release();
buf.writeShort(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.nioBuffer()));
buf.writeByte('\r');
buf.writeByte('\n');
@@ -415,7 +416,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
return null;
} else if (command == MSG_UPLOAD_PHOTO) {
byte imageIndex = buf.readByte();
- photos.put(imageIndex, Unpooled.buffer()); // TODO release photos
+ photos.put(imageIndex, Unpooled.buffer());
ByteBuf response = Unpooled.copiedBuffer(new byte[]{imageIndex});
sendResponse(channel, remoteAddress, id, MSG_UPLOAD_PHOTO_RESPONSE, response);
return null;
@@ -475,8 +476,12 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
byte imageIndex = buf.readByte();
buf.readUnsignedByte(); // image upload type
String uniqueId = Context.getIdentityManager().getById(deviceSession.getDeviceId()).getUniqueId();
- String file = Context.getMediaManager().writeFile(uniqueId, photos.remove(imageIndex), "jpg");
- position.set(Position.KEY_IMAGE, file);
+ ByteBuf photo = photos.remove(imageIndex);
+ try {
+ position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(uniqueId, photo, "jpg"));
+ } finally {
+ photo.release();
+ }
}
String sentence = buf.toString(buf.readerIndex(), buf.readableBytes() - 4, StandardCharsets.US_ASCII);
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index dcd1b0d91..465cfd9fa 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -471,7 +471,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
switch (type) {
case "D00":
if (photo == null) {
- photo = Unpooled.buffer(); // TODO ref count
+ photo = Unpooled.buffer();
}
index = index + 1 + type.length() + 1;
@@ -494,6 +494,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(imei, photo, "jpg"));
+ photo.release();
photo = null;
return position;
@@ -504,7 +505,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
return null;
}
case "D03":
- photo = Unpooled.buffer(); // TODO ref count
+ photo = Unpooled.buffer();
requestPhotoPacket(channel, remoteAddress, imei, "camera_picture.jpg", 0);
return null;
case "CCC":
diff --git a/src/org/traccar/protocol/MxtFrameDecoder.java b/src/org/traccar/protocol/MxtFrameDecoder.java
index fe6bbaa4d..d70e92da1 100644
--- a/src/org/traccar/protocol/MxtFrameDecoder.java
+++ b/src/org/traccar/protocol/MxtFrameDecoder.java
@@ -33,7 +33,7 @@ public class MxtFrameDecoder extends BaseFrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x04);
if (index != -1) {
- ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index 986fa542a..d6029c6d0 100644
--- a/src/org/traccar/protocol/MxtProtocolDecoder.java
+++ b/src/org/traccar/protocol/MxtProtocolDecoder.java
@@ -41,7 +41,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel, int device, long id, int crc) {
if (channel != null) {
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
response.writeByte(device);
response.writeByte(MSG_ACK);
response.writeIntLE((int) id);
@@ -59,6 +59,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
}
encoded.writeByte(b);
}
+ response.release();
encoded.writeByte(0x04); // ending
channel.writeAndFlush(new NetworkMessage(encoded, channel.remoteAddress()));
}
diff --git a/src/org/traccar/protocol/ObdDongleProtocolDecoder.java b/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
index f0704c50c..2f96bbac5 100644
--- a/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
+++ b/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
@@ -52,6 +52,7 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(type);
response.writeShort(content.readableBytes());
response.writeBytes(content);
+ content.release();
response.writeByte(0); // checksum
response.writeShort(0xAAAA);
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
@@ -79,7 +80,7 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_TYPE_CONNECT) {
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
response.writeByte(1);
response.writeShort(0);
response.writeInt(0);
@@ -113,7 +114,7 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromMph(BitUtil.from(speedCourse, 10) * 0.1));
position.setCourse(BitUtil.to(speedCourse, 10));
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
response.writeByte(typeMajor);
response.writeByte(typeMinor);
sendResponse(channel, MSG_TYPE_PUBACK, index, imei, response);
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index aec9b0712..e0aea693a 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -182,7 +182,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(uniqueId, photo, "jpg"));
-
+ photo.release();
photo = null;
return position;
@@ -196,7 +196,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
if (type.startsWith("$PHO")) {
int size = Integer.parseInt(type.split("-")[0].substring(4));
if (size > 0) {
- photo = Unpooled.buffer(size); // TODO ref count
+ photo = Unpooled.buffer(size);
requestPhotoFragment(channel);
}
}
diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
index 71e103e15..c3ba6d303 100644
--- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
@@ -68,6 +68,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
response.writeBytes(dataSequence);
response.writeByte(content.readableBytes());
response.writeBytes(content);
+ content.release();
response.writeByte(']');
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
@@ -96,7 +97,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
}
if (getDeviceSession(channel, remoteAddress, id) != null) {
- ByteBuf response = Unpooled.buffer(); // TODO ref count
+ ByteBuf response = Unpooled.buffer();
response.writeByte(MODE_GPRS);
response.writeBytes(data);
sendResponse(channel, MSG_LOGIN_RESPONSE, dataSequence, response);
@@ -104,7 +105,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_HEARTBEAT_REQUEST) {
- sendResponse(channel, MSG_HEARTBEAT_RESPONSE, dataSequence, buf.readSlice(length));
+ sendResponse(channel, MSG_HEARTBEAT_RESPONSE, dataSequence, buf.readRetainedSlice(length));
} else {
diff --git a/src/org/traccar/protocol/UlbotechFrameDecoder.java b/src/org/traccar/protocol/UlbotechFrameDecoder.java
index 776400cda..f141dc9b7 100644
--- a/src/org/traccar/protocol/UlbotechFrameDecoder.java
+++ b/src/org/traccar/protocol/UlbotechFrameDecoder.java
@@ -36,7 +36,7 @@ public class UlbotechFrameDecoder extends BaseFrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0xF8);
if (index != -1) {
- ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/Vt200FrameDecoder.java b/src/org/traccar/protocol/Vt200FrameDecoder.java
index bccdcba08..0fd83e715 100644
--- a/src/org/traccar/protocol/Vt200FrameDecoder.java
+++ b/src/org/traccar/protocol/Vt200FrameDecoder.java
@@ -31,7 +31,7 @@ public class Vt200FrameDecoder extends BaseFrameDecoder {
int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ')') + 1;
if (endIndex > 0) {
- ByteBuf frame = Unpooled.buffer(); // TODO ref count
+ ByteBuf frame = Unpooled.buffer();
while (buf.readerIndex() < endIndex) {
int b = buf.readByte();
diff --git a/src/org/traccar/protocol/WatchFrameDecoder.java b/src/org/traccar/protocol/WatchFrameDecoder.java
index 032063408..1e2f0cea3 100644
--- a/src/org/traccar/protocol/WatchFrameDecoder.java
+++ b/src/org/traccar/protocol/WatchFrameDecoder.java
@@ -57,7 +57,7 @@ public class WatchFrameDecoder extends BaseFrameDecoder {
int length = Integer.parseInt(
buf.toString(lengthIndex, payloadIndex - lengthIndex, StandardCharsets.US_ASCII), 16);
if (buf.readableBytes() >= payloadIndex + 1 + length + 1) {
- ByteBuf frame = Unpooled.buffer(); // TODO ref count
+ ByteBuf frame = Unpooled.buffer();
int endIndex = buf.readerIndex() + payloadIndex + 1 + length + 1;
while (buf.readerIndex() < endIndex) {
byte b = buf.readByte();