tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1538900 - /tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
Date Tue, 05 Nov 2013 08:02:23 GMT
Author: rmannibucau
Date: Tue Nov  5 08:02:23 2013
New Revision: 1538900

URL: http://svn.apache.org/r1538900
Log:
cleanup + npe

Modified:
    tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java

Modified: tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java?rev=1538900&r1=1538899&r2=1538900&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
(original)
+++ tomee/tomee/trunk/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/BeginWebBeansListener.java
Tue Nov  5 08:02:23 2013
@@ -28,6 +28,7 @@ import org.apache.webbeans.util.WebBeans
 
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Context;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 import javax.servlet.ServletRequestEvent;
@@ -78,9 +79,11 @@ public class BeginWebBeansListener imple
      * {@inheritDoc}
      */
     @Override
-    public void requestInitialized(ServletRequestEvent event) {
+    public void requestInitialized(final ServletRequestEvent event) {
         final Object oldContext = ThreadSingletonServiceImpl.enter(this.webBeansContext);
-        event.getServletRequest().setAttribute(contextKey, oldContext);
+        if (event != null) {
+            event.getServletRequest().setAttribute(contextKey, oldContext);
+        }
 
         try {
             if (logger.isDebugEnabled()) {
@@ -95,7 +98,7 @@ public class BeginWebBeansListener imple
             // we don't initialise the Session here but do it lazily if it gets requested
             // the first time. See OWB-457
 
-        } catch (Exception e) {
+        } catch (final Exception e) {
             logger.error(OWBLogConst.ERROR_0019, event == null ? "null" : event.getServletRequest());
             WebBeansUtil.throwRuntimeExceptions(e);
         }
@@ -105,7 +108,7 @@ public class BeginWebBeansListener imple
      * {@inheritDoc}
      */
     @Override
-    public void sessionCreated(HttpSessionEvent event) {
+    public void sessionCreated(final HttpSessionEvent event) {
         try {
             if (logger.isDebugEnabled()) {
                 logger.debug("Starting a session with session id : [{0}]", event.getSession().getId());
@@ -114,7 +117,7 @@ public class BeginWebBeansListener imple
                 ((WebappWebBeansContext) webBeansContext).getParent().getContextsService().startContext(SessionScoped.class,
event.getSession());
             }
             this.webBeansContext.getContextsService().startContext(SessionScoped.class, event.getSession());
-        } catch (Exception e) {
+        } catch (final Exception e) {
             logger.error(OWBLogConst.ERROR_0020, event.getSession());
             WebBeansUtil.throwRuntimeExceptions(e);
         }
@@ -129,7 +132,8 @@ public class BeginWebBeansListener imple
     }
 
     private void ensureRequestScope() {
-        if (!webBeansContext.getContextsService().getCurrentContext(RequestScoped.class).isActive())
{
+        final Context reqCtx = webBeansContext.getContextsService().getCurrentContext(RequestScoped.class);
+        if (reqCtx == null || !webBeansContext.getContextsService().getCurrentContext(RequestScoped.class).isActive())
{
             requestInitialized(null);
             EndWebBeansListener.FAKE_REQUEST.set(true);
         }



Mime
View raw message