From 5c6a4302bb8ea3280d2f6633bd1017f9c6d21abd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 14 Apr 2017 12:08:32 +1200 Subject: Fix FindBugs issues --- src/org/traccar/protocol/EnforaProtocolEncoder.java | 6 ++---- src/org/traccar/protocol/PricolProtocolDecoder.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/EnforaProtocolEncoder.java b/src/org/traccar/protocol/EnforaProtocolEncoder.java index e7da87388..3dca1b9b3 100644 --- a/src/org/traccar/protocol/EnforaProtocolEncoder.java +++ b/src/org/traccar/protocol/EnforaProtocolEncoder.java @@ -30,13 +30,11 @@ public class EnforaProtocolEncoder extends StringProtocolEncoder { ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - byte[] contentBytes = content.getBytes(); - - buf.writeShort(contentBytes.length + 6); + buf.writeShort(content.length() + 6); buf.writeShort(0); // index buf.writeByte(0x04); // command type buf.writeByte(0); // optional header - buf.writeBytes(content.getBytes(StandardCharsets.UTF_8)); + buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII)); return buf; } diff --git a/src/org/traccar/protocol/PricolProtocolDecoder.java b/src/org/traccar/protocol/PricolProtocolDecoder.java index a33e19b90..dd804d8bd 100644 --- a/src/org/traccar/protocol/PricolProtocolDecoder.java +++ b/src/org/traccar/protocol/PricolProtocolDecoder.java @@ -63,11 +63,11 @@ public class PricolProtocolDecoder extends BaseProtocolDecoder { position.setValid(true); - double lat = buf.getUnsignedShort(buf.readerIndex()) / 100; + double lat = (double) (buf.getUnsignedShort(buf.readerIndex()) / 100); lat += (buf.readUnsignedShort() % 100 * 10000 + buf.readUnsignedShort()) / 600000.0; position.setLatitude(buf.readUnsignedByte() == 'S' ? -lat : lat); - double lon = buf.getUnsignedMedium(buf.readerIndex()) / 100; + double lon = (double) (buf.getUnsignedMedium(buf.readerIndex()) / 100); lon += (buf.readUnsignedMedium() % 100 * 10000 + buf.readUnsignedShort()) / 600000.0; position.setLongitude(buf.readUnsignedByte() == 'W' ? -lon : lon); -- cgit v1.2.3