From 731020440991a53034dd2e980add2a08cb9a19de Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 8 Jul 2017 14:33:25 +1200 Subject: Fix code check issues --- src/org/traccar/GeocoderHandler.java | 11 +++++------ src/org/traccar/database/MediaManager.java | 5 ++++- src/org/traccar/protocol/TramigoProtocolDecoder.java | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/GeocoderHandler.java b/src/org/traccar/GeocoderHandler.java index 2742ff1a7..a211d1a23 100644 --- a/src/org/traccar/GeocoderHandler.java +++ b/src/org/traccar/GeocoderHandler.java @@ -60,12 +60,11 @@ public class GeocoderHandler implements ChannelUpstreamHandler { if (processInvalidPositions || position.getValid()) { if (geocoderReuseDistance != 0) { Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId()); - if (lastPosition != null && lastPosition.getAddress() != null) { - if (position.getDouble(Position.KEY_DISTANCE) <= geocoderReuseDistance) { - position.setAddress(lastPosition.getAddress()); - Channels.fireMessageReceived(ctx, position, event.getRemoteAddress()); - return; - } + if (lastPosition != null && lastPosition.getAddress() != null + && position.getDouble(Position.KEY_DISTANCE) <= geocoderReuseDistance) { + position.setAddress(lastPosition.getAddress()); + Channels.fireMessageReceived(ctx, position, event.getRemoteAddress()); + return; } } diff --git a/src/org/traccar/database/MediaManager.java b/src/org/traccar/database/MediaManager.java index 4b5930642..2c448a20c 100644 --- a/src/org/traccar/database/MediaManager.java +++ b/src/org/traccar/database/MediaManager.java @@ -40,7 +40,10 @@ public class MediaManager { private File createFile(String uniqueId, String name) throws IOException { Path filePath = Paths.get(path, uniqueId, name); - Files.createDirectories(filePath.getParent()); + Path directoryPath = filePath.getParent(); + if (directoryPath != null) { + Files.createDirectories(directoryPath); + } return filePath.toFile(); } diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java index 8a6f49ef0..b39e3eab1 100644 --- a/src/org/traccar/protocol/TramigoProtocolDecoder.java +++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java @@ -88,7 +88,7 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder { position.set("gpsAntennaStatus", buf.readUnsignedShort()); position.setSpeed(buf.readUnsignedShort() * 0.194384); - position.setCourse((double) buf.readUnsignedShort()); + position.setCourse(buf.readUnsignedShort()); position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); -- cgit v1.2.3