From 85d1addd04151318bd624ae8b07fb3f072f87669 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 9 Jun 2022 17:16:02 +0100 Subject: [PATCH] Continue shutdown if an exception is thrown. --- .../lifecycle/LifecycleManagerImpl.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/bramble-core/src/main/java/org/briarproject/bramble/lifecycle/LifecycleManagerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/lifecycle/LifecycleManagerImpl.java index b55115fb7..a1ca7dd6a 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/lifecycle/LifecycleManagerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/lifecycle/LifecycleManagerImpl.java @@ -198,11 +198,15 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener { state = STOPPING; eventBus.broadcast(new LifecycleEvent(STOPPING)); for (Service s : services) { - long start = now(); - s.stopService(); - if (LOG.isLoggable(FINE)) { - logDuration(LOG, "Stopping service " - + s.getClass().getSimpleName(), start); + try { + long start = now(); + s.stopService(); + if (LOG.isLoggable(FINE)) { + logDuration(LOG, "Stopping service " + + s.getClass().getSimpleName(), start); + } + } catch (ServiceException e) { + logException(LOG, WARNING, e); } } for (ExecutorService e : executors) { @@ -212,12 +216,14 @@ class LifecycleManagerImpl implements LifecycleManager, MigrationListener { } e.shutdownNow(); } - long start = now(); - db.close(); - logDuration(LOG, "Closing database", start); + try { + long start = now(); + db.close(); + logDuration(LOG, "Closing database", start); + } catch (DbException e) { + logException(LOG, WARNING, e); + } shutdownLatch.countDown(); - } catch (DbException | ServiceException e) { - logException(LOG, WARNING, e); } finally { startStopSemaphore.release(); }