diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-02-28 17:25:22 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-02-28 17:28:20 +0100 |
commit | d6f40cdbbd3d9b11159d7ef18dff9528a948c1f6 (patch) | |
tree | 78f30f1ed0bb7307d372ea017ffe95000314a3ee /sonar-core | |
parent | a19dd2091cc398ccfda8af250b18e391cb8d2f1e (diff) | |
download | sonarqube-d6f40cdbbd3d9b11159d7ef18dff9528a948c1f6.tar.gz sonarqube-d6f40cdbbd3d9b11159d7ef18dff9528a948c1f6.zip |
SONAR-2965 Disable autocommit on DBCP and improve semaphore logs
autocommit=true on DBCP seemed to conflict with MyBatis autocommit=false:
connection validation was not working when MyBatis was trying to change autocommit mode
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreUpdater.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreUpdater.java b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreUpdater.java index 771529c3ddd..6231460bb2f 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreUpdater.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreUpdater.java @@ -48,8 +48,13 @@ public class SemaphoreUpdater { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable updater = new Runnable() { public void run() { - LOG.debug("Updating semaphore " + semaphore.getName()); - dao.update(semaphore); + try { + LOG.debug("Updating semaphore " + semaphore.getName()); + dao.update(semaphore); + } catch (Exception e) { + LOG.error("Unable to update semaphore", e); + } + } }; scheduler.scheduleWithFixedDelay(updater, updatePeriodInSeconds, updatePeriodInSeconds, TimeUnit.SECONDS); @@ -58,7 +63,16 @@ public class SemaphoreUpdater { public void stopUpdate(final String name) { if (handlers.containsKey(name)) { - handlers.get(name).shutdownNow(); + handlers.get(name).shutdown(); + try { + if (!handlers.get(name).awaitTermination(1, TimeUnit.SECONDS)) { + LOG.error("Unable to cancel semaphore updater in 1 second"); + } + } catch (InterruptedException e) { + LOG.error("Unable to cancel semaphore updater", e); + } finally { + handlers.remove(name); + } } } } |