From: David ‘Bombe’ Roden <bombe@pterodactylus.net>
Date: Fri, 15 Oct 2010 08:32:34 +0000 (+0200)
Subject: Don’t create new shells all the time!
X-Git-Tag: 0.1-RC1~338
X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f4898723af3035ce06825266b8aa5a7a6a1bb366;p=Sone.git

Don’t create new shells all the time!
---

diff --git a/src/main/java/net/pterodactylus/sone/data/ShellCache.java b/src/main/java/net/pterodactylus/sone/data/ShellCache.java
index 8c7e4df..7e28285 100644
--- a/src/main/java/net/pterodactylus/sone/data/ShellCache.java
+++ b/src/main/java/net/pterodactylus/sone/data/ShellCache.java
@@ -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);
 	}