From 7933e79e708792569b7dade228f8642392978141 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 15 Jun 2016 15:49:53 +0500 Subject: Fix rare Stack Overflow while server idle --- src/org/traccar/database/DataManager.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/org/traccar/database') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index f5df1b84b..a530399c7 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -150,13 +150,18 @@ public class DataManager implements IdentityManager { if (force || System.currentTimeMillis() - devicesLastUpdate > dataRefreshDelay) { devicesById.clear(); devicesByUniqueId.clear(); + ConnectionManager connectionManager = Context.getConnectionManager(); + GeofenceManager geofenceManager = Context.getGeofenceManager(); for (Device device : getAllDevices()) { devicesById.put(device.getId(), device); devicesByUniqueId.put(device.getUniqueId(), device); - } - GeofenceManager geofenceManager = Context.getGeofenceManager(); - if (geofenceManager != null) { - geofenceManager.refresh(); + if (connectionManager != null && geofenceManager != null) { + Position lastPosition = Context.getConnectionManager().getLastPosition(device.getId()); + if (lastPosition != null) { + device.setGeofenceIds(Context.getGeofenceManager() + .getCurrentDeviceGeofences(lastPosition)); + } + } } devicesLastUpdate = System.currentTimeMillis(); } -- cgit v1.2.3