aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/session/ConnectionManager.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java
index 1461c66ea..121b876c5 100644
--- a/src/main/java/org/traccar/session/ConnectionManager.java
+++ b/src/main/java/org/traccar/session/ConnectionManager.java
@@ -188,17 +188,19 @@ public class ConnectionManager implements BroadcastInterface {
public void deviceDisconnected(Channel channel, boolean supportsOffline) {
SocketAddress remoteAddress = channel.remoteAddress();
- Map<String, DeviceSession> endpointSessions = sessionsByEndpoint.remove(remoteAddress);
- if (endpointSessions != null) {
- for (DeviceSession deviceSession : endpointSessions.values()) {
- if (supportsOffline) {
- updateDevice(deviceSession.getDeviceId(), Device.STATUS_OFFLINE, null);
+ if (remoteAddress != null) {
+ Map<String, DeviceSession> endpointSessions = sessionsByEndpoint.remove(remoteAddress);
+ if (endpointSessions != null) {
+ for (DeviceSession deviceSession : endpointSessions.values()) {
+ if (supportsOffline) {
+ updateDevice(deviceSession.getDeviceId(), Device.STATUS_OFFLINE, null);
+ }
+ sessionsByDeviceId.remove(deviceSession.getDeviceId());
+ cacheManager.removeDevice(deviceSession.getDeviceId());
}
- sessionsByDeviceId.remove(deviceSession.getDeviceId());
- cacheManager.removeDevice(deviceSession.getDeviceId());
}
+ unknownByEndpoint.remove(remoteAddress);
}
- unknownByEndpoint.remove(remoteAddress);
}
public void deviceUnknown(long deviceId) {