]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/Domain.java
FIX: synchronization for IDCachable-Objects
[gigi.git] / src / org / cacert / gigi / dbObjects / Domain.java
index b481e76fe5868bb3c09a15616bdc2e6a22c95d4a..3685de1b37fb2c68e77a76697d317730a9735be7 100644 (file)
@@ -15,15 +15,15 @@ public class Domain implements IdCachable {
 
     public class DomainPingExecution {
 
-        String state;
+        private String state;
 
-        String type;
+        private String type;
 
-        String info;
+        private String info;
 
-        String result;
+        private String result;
 
-        DomainPingConfiguration config;
+        private DomainPingConfiguration config;
 
         public DomainPingExecution(ResultSet rs) throws SQLException {
             state = rs.getString(1);
@@ -134,6 +134,7 @@ public class Domain implements IdCachable {
         return owner;
     }
 
+    @Override
     public int getId() {
         return id;
     }
@@ -221,13 +222,11 @@ public class Domain implements IdCachable {
 
     private static ObjectCache<Domain> myCache = new ObjectCache<>();
 
-    public static Domain getById(int id) throws IllegalArgumentException {
+    public static synchronized Domain getById(int id) throws IllegalArgumentException {
         Domain em = myCache.get(id);
         if (em == null) {
             try {
-                synchronized (Domain.class) {
-                    myCache.put(em = new Domain(id));
-                }
+                myCache.put(em = new Domain(id));
             } catch (SQLException e1) {
                 throw new IllegalArgumentException(e1);
             }