From: David ‘Bombe’ Roden Date: Fri, 15 Oct 2010 04:34:27 +0000 (+0200) Subject: Don’t store a Shell if there is already the real thing, always return the most real... X-Git-Tag: 0.1-RC1~350 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4696ccf25ac020842b6072cc11a93b1555542013;p=Sone.git Don’t store a Shell if there is already the real thing, always return the most real thing. --- diff --git a/src/main/java/net/pterodactylus/sone/data/ShellCache.java b/src/main/java/net/pterodactylus/sone/data/ShellCache.java index fd3d6bc..33e033c 100644 --- a/src/main/java/net/pterodactylus/sone/data/ShellCache.java +++ b/src/main/java/net/pterodactylus/sone/data/ShellCache.java @@ -65,13 +65,17 @@ public class ShellCache { * The object to store */ @SuppressWarnings("unchecked") - public void put(String id, T object) { + public T put(String id, T object) { if (!(object instanceof Shell)) { objectCache.put(id, object); shellCache.remove(id); - } else { - shellCache.put(id, (Shell) object); + return object; } + if (objectCache.containsKey(id)) { + return objectCache.get(id); + } + shellCache.put(id, (Shell) object); + return object; } /**