Don’t create new shells all the time!
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 15 Oct 2010 08:32:34 +0000 (10:32 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 15 Oct 2010 08:32:34 +0000 (10:32 +0200)
src/main/java/net/pterodactylus/sone/data/ShellCache.java

index 8c7e4df..7e28285 100644 (file)
@@ -89,9 +89,11 @@ public class ShellCache<T> {
         */
        public T get(String id) {
                if (!objectCache.containsKey(id)) {
-                       Shell<T> shell = shellCreator.createShell(id);
-                       shellCache.put(id, shell);
-                       return shell.getShelled();
+                       if (!shellCache.containsKey(id)) {
+                               Shell<T> shell = shellCreator.createShell(id);
+                               shellCache.put(id, shell);
+                       }
+                       return shellCache.get(id).getShelled();
                }
                return objectCache.get(id);
        }