This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 67fb8d2  OWB-1372 deactivate() is a no-op if RQ was active
67fb8d2 is described below

commit 67fb8d2225dab1a50405c562dc7102da5e506379
Author: Mark Struberg <[email protected]>
AuthorDate: Sun Feb 28 09:34:07 2021 +0100

    OWB-1372 deactivate() is a no-op if RQ was active
    
    According to the spec the deactive() method of the RequestContextController 
is
    a no-op if it did not actually activate any RequestContext.
---
 .../webbeans/context/control/OwbRequestContextController.java  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git 
a/webbeans-impl/src/main/java/org/apache/webbeans/context/control/OwbRequestContextController.java
 
b/webbeans-impl/src/main/java/org/apache/webbeans/context/control/OwbRequestContextController.java
index 3dd4383..1c45dd5 100644
--- 
a/webbeans-impl/src/main/java/org/apache/webbeans/context/control/OwbRequestContextController.java
+++ 
b/webbeans-impl/src/main/java/org/apache/webbeans/context/control/OwbRequestContextController.java
@@ -31,6 +31,7 @@ import javax.enterprise.context.spi.Context;
 public class OwbRequestContextController implements RequestContextController
 {
     private final ContextsService contextsService;
+    private boolean didActivate = false;
 
     OwbRequestContextController(WebBeansContext context)
     {
@@ -44,6 +45,7 @@ public class OwbRequestContextController implements 
RequestContextController
         if (ctx == null || !ctx.isActive())
         {
             contextsService.startContext(RequestScoped.class, null);
+            didActivate = true;
             return true;
         }
         return false;
@@ -52,7 +54,11 @@ public class OwbRequestContextController implements 
RequestContextController
     @Override
     public void deactivate() throws ContextNotActiveException
     {
-        contextsService.endContext(RequestScoped.class, null);
-        RequestScopedBeanInterceptorHandler.removeThreadLocals();
+        // spec says we only must deactivate the RequestContest "f it was 
activated by this context controller"
+        if (didActivate)
+        {
+            contextsService.endContext(RequestScoped.class, null);
+            RequestScopedBeanInterceptorHandler.removeThreadLocals();
+        }
     }
 }

Reply via email to