From 0e3c39e9d6f165c65e6156e05edc048bad9f57bc Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 24 Jul 2017 17:51:01 +0500 Subject: Fix initial cache fill --- src/org/traccar/database/DriversManager.java | 5 ++--- src/org/traccar/database/SimpleObjectManager.java | 8 ++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/database/DriversManager.java b/src/org/traccar/database/DriversManager.java index e3ae07a65..f843568b4 100644 --- a/src/org/traccar/database/DriversManager.java +++ b/src/org/traccar/database/DriversManager.java @@ -16,7 +16,6 @@ */ package org.traccar.database; -import java.sql.SQLException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -32,8 +31,8 @@ public class DriversManager extends ExtendedObjectManager { } @Override - public void addItem(BaseModel item) throws SQLException { - super.addItem(item); + protected void addNewItem(BaseModel item) { + super.addNewItem(item); driversByUniqueId.put(((Driver) item).getUniqueId(), (Driver) item); } diff --git a/src/org/traccar/database/SimpleObjectManager.java b/src/org/traccar/database/SimpleObjectManager.java index 031f91fc5..0f6a9e6a4 100644 --- a/src/org/traccar/database/SimpleObjectManager.java +++ b/src/org/traccar/database/SimpleObjectManager.java @@ -99,7 +99,7 @@ public abstract class SimpleObjectManager { if (items.containsKey(item.getId())) { updateCachedItem(item); } else { - items.put(item.getId(), item); + addNewItem(item); } } for (Long cachedItemId : items.keySet()) { @@ -127,9 +127,13 @@ public abstract class SimpleObjectManager { } } + protected void addNewItem(BaseModel item) { + items.put(item.getId(), item); + } + public void addItem(BaseModel item) throws SQLException { dataManager.addObject(item); - items.put(item.getId(), item); + addNewItem(item); } protected void updateCachedItem(BaseModel item) { -- cgit v1.2.3