diff options
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 13 | ||||
-rw-r--r-- | test/org/traccar/protocol/OsmAndProtocolDecoderTest.java | 3 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index f9f04d7e3..c5884a4d0 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -73,9 +73,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { case "deviceid": DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value); if (deviceSession == null) { - if (channel != null) { - sendResponse(channel, HttpResponseStatus.BAD_REQUEST); - } + sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } position.setDeviceId(deviceSession.getDeviceId()); @@ -132,11 +130,14 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date()); } - if (channel != null) { + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession != null) { sendResponse(channel, HttpResponseStatus.OK); + return position; + } else { + sendResponse(channel, HttpResponseStatus.BAD_REQUEST); + return null; } - - return position; } } diff --git a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java index d035ba7ef..6ec885058 100644 --- a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java +++ b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class OsmAndProtocolDecoderTest extends ProtocolTest { OsmAndProtocolDecoder decoder = new OsmAndProtocolDecoder(new OsmAndProtocol()); + verifyNothing(decoder, request( + "/?timestamp=1377177267&lat=60.0&lon=30.0")); + verifyPosition(decoder, request( "/?id=902064&lat=42.06288&lon=-88.23412×tamp=2016-01-27T18%3A55%3A47Z&hdop=6.0&altitude=224.0&speed=0.0")); |