]> WPIA git - gigi.git/commitdiff
chg: Make synchronization on the Database layer explicit
authorBenny Baumann <BenBE1987@gmx.net>
Sun, 19 Mar 2017 18:18:47 +0000 (19:18 +0100)
committerBenny Baumann <BenBE1987@gmx.net>
Wed, 22 Mar 2017 21:01:29 +0000 (22:01 +0100)
This avoids a synchronization issue when closing the connection - even though that code is single-threaded ATM.

Change-Id: I9a57ce72664ffce42239f6d1199195bfe72b216b

tests/club/wpia/gigi/testUtils/ConfiguredTest.java

index cdacf6922f0f4af08d51e5484f210211fa96b654..711007a047eafe94703507f2ddac532650e8a8eb 100644 (file)
@@ -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;
+            }
         }
     }