From 5a165314a65da34476dd6d6f70700eebf97d87a7 Mon Sep 17 00:00:00 2001 From: Alex Almanza <115671044+earocorn@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:19:42 -0500 Subject: [PATCH] Create single Timer thread for all purge policies --- .../sensorhub/impl/database/system/SystemDriverDatabase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sensorhub-core/src/main/java/org/sensorhub/impl/database/system/SystemDriverDatabase.java b/sensorhub-core/src/main/java/org/sensorhub/impl/database/system/SystemDriverDatabase.java index 4e24155e8..9257b8ec3 100644 --- a/sensorhub-core/src/main/java/org/sensorhub/impl/database/system/SystemDriverDatabase.java +++ b/sensorhub-core/src/main/java/org/sensorhub/impl/database/system/SystemDriverDatabase.java @@ -80,6 +80,9 @@ protected void doStart() throws SensorHubException { throw new DataStoreException("Cannot instantiate underlying database " + config.dbConfig.moduleClass, e); } + + if(!config.autoPurgeConfig.isEmpty()) + autoPurgeTimer = new Timer(); // start auto-purge timer thread if policy is specified and enabled for(var autoPurgeConfig : config.autoPurgeConfig) @@ -88,7 +91,6 @@ protected void doStart() throws SensorHubException { var uids = Collections.unmodifiableCollection(autoPurgeConfig.systemUIDs); final IObsSystemDbAutoPurgePolicy policy = autoPurgeConfig.getPolicy(); - autoPurgeTimer = new Timer(); TimerTask task = new TimerTask() { public void run() {