From 4696ccf25ac020842b6072cc11a93b1555542013 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 15 Oct 2010 06:34:27 +0200 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20store=20a=20Shell=20if=20there?= =?utf8?q?=20is=20already=20the=20real=20thing,=20always=20return=20the=20?= =?utf8?q?most=20real=20thing.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/data/ShellCache.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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; } /** -- 2.7.4