]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/EmailAddress.java
FIX: synchronization for IDCachable-Objects
[gigi.git] / src / org / cacert / gigi / dbObjects / EmailAddress.java
index f0ce010f5ed4fedd559906832c44ff4f04a67de3..1191952f7e236ee93c1ab09fe8facfd3f8d5bfe5 100644 (file)
@@ -37,7 +37,7 @@ public class EmailAddress implements IdCachable {
         rs.close();
     }
 
-    public EmailAddress(String address, User owner) {
+    public EmailAddress(User owner, String address) {
         if ( !EmailProvider.MAIL.matcher(address).matches()) {
             throw new IllegalArgumentException("Invalid email.");
         }
@@ -106,13 +106,11 @@ public class EmailAddress implements IdCachable {
 
     private static ObjectCache<EmailAddress> myCache = new ObjectCache<>();
 
-    public static EmailAddress getById(int id) throws IllegalArgumentException {
+    public static synchronized EmailAddress getById(int id) throws IllegalArgumentException {
         EmailAddress em = myCache.get(id);
         if (em == null) {
             try {
-                synchronized (EmailAddress.class) {
-                    myCache.put(em = new EmailAddress(id));
-                }
+                myCache.put(em = new EmailAddress(id));
             } catch (SQLException e1) {
                 throw new IllegalArgumentException(e1);
             }