From: Benny Baumann Date: Sun, 19 Mar 2017 18:18:47 +0000 (+0100) Subject: chg: Make synchronization on the Database layer explicit X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=402feee6f7743e0baf17c13f2dab8f25ece4f04b;ds=sidebyside chg: Make synchronization on the Database layer explicit This avoids a synchronization issue when closing the connection - even though that code is single-threaded ATM. Change-Id: I9a57ce72664ffce42239f6d1199195bfe72b216b --- diff --git a/tests/club/wpia/gigi/testUtils/ConfiguredTest.java b/tests/club/wpia/gigi/testUtils/ConfiguredTest.java index cdacf692..711007a0 100644 --- a/tests/club/wpia/gigi/testUtils/ConfiguredTest.java +++ b/tests/club/wpia/gigi/testUtils/ConfiguredTest.java @@ -93,7 +93,9 @@ public abstract class ConfiguredTest { if ( !DatabaseConnection.isInited()) { DatabaseConnection.init(testProps); try { - l = DatabaseConnection.newLink(false); + synchronized (ConfiguredTest.class) { + l = DatabaseConnection.newLink(false); + } } catch (InterruptedException e) { throw new Error(e); } @@ -104,9 +106,11 @@ public abstract class ConfiguredTest { @AfterClass public static void closeDBLink() { - if (l != null) { - l.close(); - l = null; + synchronized (ConfiguredTest.class) { + if (l != null) { + l.close(); + l = null; + } } }