Committed by
Gerrit Code Review
Cancelling timer at close to prevent attempts to commit closed DB.
Change-Id: I01d2984e69ea8329c06a6fc3610d4a419f9bd6a2
Showing
1 changed file
with
3 additions
and
1 deletions
... | @@ -60,12 +60,13 @@ public class PersistenceManager implements PersistenceService { | ... | @@ -60,12 +60,13 @@ public class PersistenceManager implements PersistenceService { |
60 | 60 | ||
61 | private static final int FLUSH_FREQUENCY_MILLIS = 3000; | 61 | private static final int FLUSH_FREQUENCY_MILLIS = 3000; |
62 | 62 | ||
63 | - private final Timer timer = new Timer(); | 63 | + private Timer timer; |
64 | 64 | ||
65 | private final CommitTask commitTask = new CommitTask(); | 65 | private final CommitTask commitTask = new CommitTask(); |
66 | 66 | ||
67 | @Activate | 67 | @Activate |
68 | public void activate() { | 68 | public void activate() { |
69 | + timer = new Timer(); | ||
69 | Path dbPath = Paths.get(DATABASE_PATH); | 70 | Path dbPath = Paths.get(DATABASE_PATH); |
70 | Path dbFolderPath = Paths.get(ENCLOSING_FOLDER); | 71 | Path dbFolderPath = Paths.get(ENCLOSING_FOLDER); |
71 | //Make sure the directory exists, if it does not, make it. | 72 | //Make sure the directory exists, if it does not, make it. |
... | @@ -96,6 +97,7 @@ public class PersistenceManager implements PersistenceService { | ... | @@ -96,6 +97,7 @@ public class PersistenceManager implements PersistenceService { |
96 | 97 | ||
97 | @Deactivate | 98 | @Deactivate |
98 | public void deactivate() { | 99 | public void deactivate() { |
100 | + timer.cancel(); | ||
99 | for (Map.Entry<String, Object> entry : localDB.getAll().entrySet()) { | 101 | for (Map.Entry<String, Object> entry : localDB.getAll().entrySet()) { |
100 | String key = entry.getKey(); | 102 | String key = entry.getKey(); |
101 | Object value = entry.getValue(); | 103 | Object value = entry.getValue(); | ... | ... |
-
Please register or login to post a comment