From 6808b11cd6d97c71a2eed754ed4f955acd789086 Mon Sep 17 00:00:00 2001 From: Jozef Hartinger Date: Mon, 1 Dec 2014 17:48:56 +0100 Subject: [PATCH] WELD-1802 RequestScopedCache - Make sure each request is ended before a new one is started --- .../java/org/jboss/weld/context/cache/RequestScopedCache.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/impl/src/main/java/org/jboss/weld/context/cache/RequestScopedCache.java b/impl/src/main/java/org/jboss/weld/context/cache/RequestScopedCache.java index 27d6664f27f..3eae118ab30 100644 --- a/impl/src/main/java/org/jboss/weld/context/cache/RequestScopedCache.java +++ b/impl/src/main/java/org/jboss/weld/context/cache/RequestScopedCache.java @@ -71,6 +71,8 @@ public void invalidate() { } public static void beginRequest() { + // if the previous request was not ended properly for some reason, make sure it is ended now + endRequest(); CACHE.set(new LinkedList()); } @@ -80,8 +82,8 @@ public static void beginRequest() { */ public static void endRequest() { final List result = CACHE.get(); - CACHE.remove(); if (result != null) { + CACHE.remove(); for (final RequestScopedItem item : result) { item.invalidate(); }