diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-24 18:13:53 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-24 18:20:03 +0500 |
commit | 870a919f53986724c023bcde9d0eddf8888e9007 (patch) | |
tree | 9e3e191f3ff7cd05bbec00730519439b789595e5 /src/org/traccar | |
parent | 4e2fe7bc908e0288345a4aef2f31c357215a7586 (diff) | |
download | trackermap-server-870a919f53986724c023bcde9d0eddf8888e9007.tar.gz trackermap-server-870a919f53986724c023bcde9d0eddf8888e9007.tar.bz2 trackermap-server-870a919f53986724c023bcde9d0eddf8888e9007.zip |
Fix order of objects constructions
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/database/DriversManager.java | 13 | ||||
-rw-r--r-- | src/org/traccar/database/SimpleObjectManager.java | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/org/traccar/database/DriversManager.java b/src/org/traccar/database/DriversManager.java index 349e5dccf..14b74bab1 100644 --- a/src/org/traccar/database/DriversManager.java +++ b/src/org/traccar/database/DriversManager.java @@ -24,16 +24,23 @@ import org.traccar.model.BaseModel; public class DriversManager extends ExtendedObjectManager { - private final Map<String, Driver> driversByUniqueId = new ConcurrentHashMap<>(); + private Map<String, Driver> driversByUniqueId; public DriversManager(DataManager dataManager) { super(dataManager, Driver.class); } + private void putUniqueDriverId(Driver driver) { + if (driversByUniqueId == null) { + driversByUniqueId = new ConcurrentHashMap<>(); + } + driversByUniqueId.put(driver.getUniqueId(), driver); + } + @Override protected void addNewItem(BaseModel item) { super.addNewItem(item); - driversByUniqueId.put(((Driver) item).getUniqueId(), (Driver) item); + putUniqueDriverId((Driver) item); } @Override @@ -44,7 +51,7 @@ public class DriversManager extends ExtendedObjectManager { if (!driver.getUniqueId().equals(cachedDriver.getUniqueId())) { driversByUniqueId.remove(cachedDriver.getUniqueId()); cachedDriver.setUniqueId(driver.getUniqueId()); - driversByUniqueId.put(cachedDriver.getUniqueId(), cachedDriver); + putUniqueDriverId(cachedDriver); } cachedDriver.setAttributes(driver.getAttributes()); } diff --git a/src/org/traccar/database/SimpleObjectManager.java b/src/org/traccar/database/SimpleObjectManager.java index 0f6a9e6a4..6cb7ff260 100644 --- a/src/org/traccar/database/SimpleObjectManager.java +++ b/src/org/traccar/database/SimpleObjectManager.java @@ -162,7 +162,7 @@ public abstract class SimpleObjectManager { return result; } - public Set<Long> getAllItems() { + public final Set<Long> getAllItems() { return items.keySet(); } |