correct implementation of singleton
authorFelix Schumacher <felix.schumacher@internetallee.de>
Tue, 24 Aug 2010 18:28:06 +0000 (20:28 +0200)
committerFelix Schumacher <felix.schumacher@internetallee.de>
Tue, 24 Aug 2010 18:28:06 +0000 (20:28 +0200)
src/org/mcb/services/passwordservices.java

index d292693..aa8f273 100644 (file)
@@ -17,7 +17,7 @@ import java.security.NoSuchAlgorithmException;
 import sun.misc.BASE64Encoder;
 
 public final class passwordservices {
-       private static passwordservices instance;
+       private static passwordservices instance = new passwordservices();
 
        private passwordservices() {
        }
@@ -41,10 +41,6 @@ public final class passwordservices {
 
        public static synchronized passwordservices getInstance() // step 1
        {
-               if (instance == null) {
-                       return new passwordservices();
-               } else {
-                       return instance;
-               }
+               return instance;
        }
 }