aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-09 16:16:37 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-09 16:16:37 +1200
commit0e1c89d007b761a83c11dcb2ba378c4db02200ee (patch)
tree2589b42bf1e0cecd0fa1cc74df3b0adacd47c647 /src
parent5cf987a9e9cab3e9ec3d2a8acc335a85f2637df0 (diff)
downloadtraccar-server-0e1c89d007b761a83c11dcb2ba378c4db02200ee.tar.gz
traccar-server-0e1c89d007b761a83c11dcb2ba378c4db02200ee.tar.bz2
traccar-server-0e1c89d007b761a83c11dcb2ba378c4db02200ee.zip
Mark reference counting to fix
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/BlackKiteProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CellocatorProtocolDecoder.java38
-rw-r--r--src/org/traccar/protocol/DmtProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/EgtsProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Gps056ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/GranitProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/HuaShengFrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/HuabaoFrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/HuabaoProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/MxtFrameDecoder.java2
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/NavigilProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/ObdDongleProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/RoboTrackProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Tk102ProtocolDecoder.java2
-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
26 files changed, 77 insertions, 72 deletions
diff --git a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
index 54761b87c..aebf970d0 100644
--- a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
+++ b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
@@ -56,10 +56,10 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
private static final int TAG_XT3 = 0x62;
private void sendReply(Channel channel, int checksum) {
- ByteBuf reply = Unpooled.buffer(3);
- reply.writeByte(0x02);
- reply.writeShortLE((short) checksum);
if (channel != null) {
+ ByteBuf reply = Unpooled.buffer(3);
+ reply.writeByte(0x02);
+ reply.writeShortLE((short) checksum);
channel.writeAndFlush(new NetworkMessage(reply, channel.remoteAddress()));
}
}
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index af0bb9d41..1be66b17d 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -296,7 +296,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);
+ ByteBuf response = Unpooled.buffer(10); // TODO ref count
response.writeIntLE(0xFFFFFFFF);
response.writeShortLE(0);
response.writeIntLE((int) (System.currentTimeMillis() / 1000));
diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
index 18e20699a..30319eaee 100644
--- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
@@ -44,26 +44,26 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
private byte commandCount;
private void sendReply(Channel channel, SocketAddress remoteAddress, long deviceId, byte packetNumber) {
- ByteBuf reply = Unpooled.buffer(28);
- reply.writeByte('M');
- reply.writeByte('C');
- reply.writeByte('G');
- reply.writeByte('P');
- reply.writeByte(MSG_SERVER_ACKNOWLEDGE);
- reply.writeIntLE((int) deviceId);
- reply.writeByte(commandCount++);
- reply.writeIntLE(0); // authentication code
- reply.writeByte(0);
- reply.writeByte(packetNumber);
- reply.writeZero(11);
-
- byte checksum = 0;
- for (int i = 4; i < 27; i++) {
- checksum += reply.getByte(i);
- }
- reply.writeByte(checksum);
-
if (channel != null) {
+ ByteBuf reply = Unpooled.buffer(28);
+ reply.writeByte('M');
+ reply.writeByte('C');
+ reply.writeByte('G');
+ reply.writeByte('P');
+ reply.writeByte(MSG_SERVER_ACKNOWLEDGE);
+ reply.writeIntLE((int) deviceId);
+ reply.writeByte(commandCount++);
+ reply.writeIntLE(0); // authentication code
+ reply.writeByte(0);
+ reply.writeByte(packetNumber);
+ reply.writeZero(11);
+
+ byte checksum = 0;
+ for (int i = 4; i < 27; i++) {
+ checksum += reply.getByte(i);
+ }
+ reply.writeByte(checksum);
+
channel.writeAndFlush(new NetworkMessage(reply, remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/DmtProtocolDecoder.java b/src/org/traccar/protocol/DmtProtocolDecoder.java
index 25055d892..637b9f9ca 100644
--- a/src/org/traccar/protocol/DmtProtocolDecoder.java
+++ b/src/org/traccar/protocol/DmtProtocolDecoder.java
@@ -52,7 +52,7 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, int type, ByteBuf content) {
if (channel != null) {
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0x02); response.writeByte(0x55); // header
response.writeByte(type);
response.writeShortLE(content != null ? content.readableBytes() : 0);
@@ -244,7 +244,7 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession = getDeviceSession(
channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII));
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
if (length == 51) {
response.writeByte(0); // reserved
response.writeIntLE(0); // reserved
@@ -257,13 +257,13 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_COMMIT) {
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer(0); // TODO ref count
response.writeByte(1); // flags (success)
sendResponse(channel, MSG_COMMIT_RESPONSE, response);
} else if (type == MSG_CANNED_REQUEST_1) {
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer(0); // TODO ref count
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 df02b8f7f..5b1b49370 100644
--- a/src/org/traccar/protocol/EgtsProtocolDecoder.java
+++ b/src/org/traccar/protocol/EgtsProtocolDecoder.java
@@ -75,12 +75,12 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
Channel channel, int packetType, int index, int serviceType, int type, ByteBuf content) {
if (channel != null) {
- ByteBuf data = Unpooled.buffer(0);
+ ByteBuf data = Unpooled.buffer(); // TODO ref count
data.writeByte(type);
data.writeShortLE(content.readableBytes());
data.writeBytes(content);
- ByteBuf record = Unpooled.buffer(0);
+ ByteBuf record = Unpooled.buffer(); // TODO ref count
if (packetType == PT_RESPONSE) {
record.writeShortLE(index);
record.writeByte(0); // success
@@ -93,7 +93,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
record.writeBytes(data);
int recordChecksum = Checksum.crc16(Checksum.CRC16_CCITT_FALSE, record.nioBuffer());
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer();
response.writeByte(1); // protocol version
response.writeByte(0); // security key id
response.writeByte(0); // flags
@@ -150,7 +150,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
}
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
response.writeShortLE(recordIndex);
response.writeByte(0); // success
sendResponse(channel, PT_RESPONSE, index, serviceType, MSG_RECORD_RESPONSE, response);
@@ -189,7 +189,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII).trim());
}
- response = Unpooled.buffer(0);
+ response = Unpooled.buffer(); // TODO ref count
response.writeByte(0); // success
sendResponse(channel, PT_APPDATA, 0, serviceType, MSG_RESULT_CODE, response);
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index 746e05f5d..7e17ebd93 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -93,10 +93,10 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
}
private void sendReply(Channel channel, int checksum) {
- ByteBuf reply = Unpooled.buffer(3);
- reply.writeByte(0x02);
- reply.writeShortLE((short) checksum);
if (channel != null) {
+ ByteBuf reply = Unpooled.buffer(3);
+ reply.writeByte(0x02);
+ reply.writeShortLE((short) checksum);
channel.writeAndFlush(new NetworkMessage(reply, channel.remoteAddress()));
}
}
diff --git a/src/org/traccar/protocol/Gps056ProtocolDecoder.java b/src/org/traccar/protocol/Gps056ProtocolDecoder.java
index 00010b542..13027142f 100644
--- a/src/org/traccar/protocol/Gps056ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps056ProtocolDecoder.java
@@ -89,8 +89,12 @@ public class Gps056ProtocolDecoder extends BaseProtocolDecoder {
if (type.startsWith("LOGN")) {
- sendResponse(channel, "LGSA" + type.substring(4), imei,
- Unpooled.copiedBuffer("1", StandardCharsets.US_ASCII)); // TODO ref count
+ ByteBuf content = Unpooled.copiedBuffer("1", StandardCharsets.US_ASCII);
+ try {
+ sendResponse(channel, "LGSA" + type.substring(4), imei, content);
+ } finally {
+ content.release();
+ }
} else if (type.startsWith("GPSL")) {
diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java
index 495faef30..d4aa7e6e8 100644
--- a/src/org/traccar/protocol/GranitProtocolDecoder.java
+++ b/src/org/traccar/protocol/GranitProtocolDecoder.java
@@ -58,7 +58,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
}
private static void sendResponseCurrent(Channel channel, int deviceId, long time) {
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer();
response.writeBytes("BB+UGRC~".getBytes(StandardCharsets.US_ASCII));
response.writeShortLE(6); // length
response.writeInt((int) time);
@@ -68,7 +68,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
}
private static void sendResponseArchive(Channel channel, int deviceId, int packNum) {
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer();
response.writeBytes("BB+ARCF~".getBytes(StandardCharsets.US_ASCII));
response.writeShortLE(4); // length
response.writeShortLE(packNum);
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index cc37d5602..22391c750 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -189,7 +189,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private void sendPhotoRequest(Channel channel, int pictureId) {
ByteBuf photo = photos.get(pictureId);
- ByteBuf content = Unpooled.buffer();
+ ByteBuf content = Unpooled.buffer(); // TODO ref count
content.writeInt(pictureId);
content.writeInt(photo.writerIndex());
content.writeShort(Math.min(photo.writableBytes(), 1024));
@@ -437,7 +437,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_ADDRESS_REQUEST) {
String response = "NA&&NA&&0##";
- ByteBuf content = Unpooled.buffer();
+ ByteBuf content = Unpooled.buffer(); // TODO ref count
content.writeByte(response.length());
content.writeInt(0);
content.writeBytes(response.getBytes(StandardCharsets.US_ASCII));
@@ -446,7 +446,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_TIME_REQUEST) {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- ByteBuf content = Unpooled.buffer();
+ ByteBuf content = Unpooled.buffer(); // TODO ref count
content.writeByte(calendar.get(Calendar.YEAR) - 2000);
content.writeByte(calendar.get(Calendar.MONTH) + 1);
content.writeByte(calendar.get(Calendar.DAY_OF_MONTH));
@@ -484,7 +484,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // photo source
buf.readUnsignedByte(); // picture format
- ByteBuf photo = Unpooled.buffer(buf.readInt());
+ ByteBuf photo = Unpooled.buffer(buf.readInt()); // TODO release photo
int pictureId = buf.readInt();
photos.put(pictureId, photo);
sendPhotoRequest(channel, pictureId);
diff --git a/src/org/traccar/protocol/HuaShengFrameDecoder.java b/src/org/traccar/protocol/HuaShengFrameDecoder.java
index bd52aa9e7..f9fbc5554 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());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
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 79ba660ee..7b09b5854 100644
--- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -84,7 +84,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();
+ ByteBuf content = Unpooled.buffer(); // TODO ref count
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 b520f6be9..1e98f9f12 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());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
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 c9868b21e..7546b75a8 100644
--- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -64,11 +64,12 @@ 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();
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
response.writeShort(index);
response.writeShort(type);
response.writeByte(RESULT_SUCCESS);
- channel.writeAndFlush(new NetworkMessage(formatMessage(MSG_GENERAL_RESPONSE, id, response), remoteAddress));
+ channel.writeAndFlush(new NetworkMessage(
+ formatMessage(MSG_GENERAL_RESPONSE, id, response), remoteAddress));
}
}
@@ -118,7 +119,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_TERMINAL_REGISTER) {
if (channel != null) {
- ByteBuf response = Unpooled.buffer();
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
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 752168233..738610cac 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -415,7 +415,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
return null;
} else if (command == MSG_UPLOAD_PHOTO) {
byte imageIndex = buf.readByte();
- photos.put(imageIndex, Unpooled.buffer());
+ photos.put(imageIndex, Unpooled.buffer()); // TODO release photos
ByteBuf response = Unpooled.copiedBuffer(new byte[]{imageIndex});
sendResponse(channel, remoteAddress, id, MSG_UPLOAD_PHOTO_RESPONSE, response);
return null;
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 3f027559a..dcd1b0d91 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();
+ photo = Unpooled.buffer(); // TODO ref count
}
index = index + 1 + type.length() + 1;
@@ -504,7 +504,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
return null;
}
case "D03":
- photo = Unpooled.buffer();
+ photo = Unpooled.buffer(); // TODO ref count
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 d70e92da1..fe6bbaa4d 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());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
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 34cb268d9..986fa542a 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();
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
response.writeByte(device);
response.writeByte(MSG_ACK);
response.writeIntLE((int) id);
@@ -49,7 +49,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
response.writeShortLE(Checksum.crc16(
Checksum.CRC16_XMODEM, response.nioBuffer()));
- ByteBuf encoded = Unpooled.buffer(0);
+ ByteBuf encoded = Unpooled.buffer();
encoded.writeByte(0x01); // header
while (response.isReadable()) {
int b = response.readByte();
diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java
index e71f8e36b..19eb37c27 100644
--- a/src/org/traccar/protocol/NavigilProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java
@@ -75,7 +75,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
header.writeIntLE((int) (System.currentTimeMillis() / 1000) + LEAP_SECONDS_DELTA);
if (channel != null) {
- channel.writeAndFlush(new NetworkMessage(Unpooled.copiedBuffer(header, data), channel.remoteAddress()));
+ channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(header, data), channel.remoteAddress()));
}
}
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index dac8f7ba3..8da94b9aa 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -234,15 +234,15 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
}
private void sendReply(Channel channel, ByteBuf data) {
- ByteBuf header = Unpooled.buffer(16);
- header.writeCharSequence(prefix, StandardCharsets.US_ASCII);
- header.writeIntLE((int) deviceUniqueId);
- header.writeIntLE((int) serverId);
- header.writeShortLE(data.readableBytes());
- header.writeByte(checksum(data));
- header.writeByte(checksum(header));
-
if (channel != null) {
+ ByteBuf header = Unpooled.buffer(16);
+ header.writeCharSequence(prefix, StandardCharsets.US_ASCII);
+ header.writeIntLE((int) deviceUniqueId);
+ header.writeIntLE((int) serverId);
+ header.writeShortLE(data.readableBytes());
+ header.writeByte(checksum(data));
+ header.writeByte(checksum(header));
+
channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(header, data), channel.remoteAddress()));
}
}
diff --git a/src/org/traccar/protocol/ObdDongleProtocolDecoder.java b/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
index dcfba242d..f0704c50c 100644
--- a/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
+++ b/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
@@ -79,7 +79,7 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_TYPE_CONNECT) {
- ByteBuf response = Unpooled.buffer();
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
response.writeByte(1);
response.writeShort(0);
response.writeInt(0);
@@ -113,7 +113,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();
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
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 4d218653b..aec9b0712 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -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);
+ photo = Unpooled.buffer(size); // TODO ref count
requestPhotoFragment(channel);
}
}
diff --git a/src/org/traccar/protocol/RoboTrackProtocolDecoder.java b/src/org/traccar/protocol/RoboTrackProtocolDecoder.java
index 26d6bc4ff..587f9b8f7 100644
--- a/src/org/traccar/protocol/RoboTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/RoboTrackProtocolDecoder.java
@@ -60,7 +60,7 @@ public class RoboTrackProtocolDecoder extends BaseProtocolDecoder {
String imei = buf.readSlice(15).toString(StandardCharsets.US_ASCII);
if (getDeviceSession(channel, remoteAddress, imei) != null && channel != null) {
- ByteBuf response = Unpooled.buffer(0);
+ ByteBuf response = Unpooled.buffer();
response.writeByte(MSG_ACK);
response.writeByte(0x01); // success
response.writeByte(0x66); // checksum
diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
index 5bbbddbef..71e103e15 100644
--- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
@@ -96,7 +96,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
}
if (getDeviceSession(channel, remoteAddress, id) != null) {
- ByteBuf response = Unpooled.buffer();
+ ByteBuf response = Unpooled.buffer(); // TODO ref count
response.writeByte(MODE_GPRS);
response.writeBytes(data);
sendResponse(channel, MSG_LOGIN_RESPONSE, dataSequence, response);
diff --git a/src/org/traccar/protocol/UlbotechFrameDecoder.java b/src/org/traccar/protocol/UlbotechFrameDecoder.java
index f141dc9b7..776400cda 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());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); // TODO ref count
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 0fd83e715..bccdcba08 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();
+ ByteBuf frame = Unpooled.buffer(); // TODO ref count
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 1e2f0cea3..032063408 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();
+ ByteBuf frame = Unpooled.buffer(); // TODO ref count
int endIndex = buf.readerIndex() + payloadIndex + 1 + length + 1;
while (buf.readerIndex() < endIndex) {
byte b = buf.readByte();