diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-08-20 08:21:30 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-08-20 08:21:30 -0700 |
commit | b9875d4076a6c88b4da6d6b296f9496f525091fe (patch) | |
tree | a747930ee37087663eb75c0499ada9062c60940d | |
parent | 5a62b28e205186358bf45349d31f53c95b5f8a1e (diff) | |
download | trackermap-server-b9875d4076a6c88b4da6d6b296f9496f525091fe.tar.gz trackermap-server-b9875d4076a6c88b4da6d6b296f9496f525091fe.tar.bz2 trackermap-server-b9875d4076a6c88b4da6d6b296f9496f525091fe.zip |
Fix commands response crash
-rw-r--r-- | src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java | 8 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java index 0f815ca7b..ec4f97919 100644 --- a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java @@ -209,8 +209,12 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { } private Object decodeLowAltitude( - Channel channel, SocketAddress remoteAddress, String sentence) throws Exception { - String deviceId = sentence.substring(0, sentence.indexOf("$")); + Channel channel, SocketAddress remoteAddress, String sentence) { + int separator = sentence.indexOf("$"); + if (separator < 0) { + return null; + } + String deviceId = sentence.substring(0, separator); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, deviceId); if (deviceSession == null) { diff --git a/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java index 605a02b92..22f0974ec 100644 --- a/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class MictrackProtocolDecoderTest extends ProtocolTest { MictrackProtocolDecoder decoder = new MictrackProtocolDecoder(null); + verifyNull(decoder, text( + "mode=Success!")); + verifyPosition(decoder, text( "MT;6;866425031361423;R0;10+190109091803+22.63827+114.02922+2.14+69+2+3744+113"), position("2019-01-09 09:18:03.000", true, 22.63827, 114.02922)); |