[jboss-svn-commits] JBL Code SVN: r34995 - labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Sep 3 07:13:27 EDT 2010


Author: kcbabo
Date: 2010-09-03 07:13:27 -0400 (Fri, 03 Sep 2010)
New Revision: 34995

Modified:
   labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java
Log:
JBESB-3470 : SOAPProcessor isn't thread safe

Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java	2010-09-03 09:05:45 UTC (rev 34994)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java	2010-09-03 11:13:27 UTC (rev 34995)
@@ -225,16 +225,8 @@
                 Thread.currentThread().setContextClassLoader(initCL);
 
                 // Provide ENC for newer versions of JBossWS
-                final Context ctx = new InitialContext();
-                try {
-                    ctx.lookup("java:comp/env");
-                } catch (NameNotFoundException nnfe) {
-                    final Context enc = (Context)ctx.lookup("java:comp");
-                    enc.createSubcontext("env");
-                }
-
+                setENC();
                 requestHandler.handleHttpRequest(endpoint, servletRequest, servletResponse, servletContext) ;
-                ctx.close();
             }
             finally
             {
@@ -322,6 +314,25 @@
         }
         return soapMessage;
     }
+    
+    /**
+     * Checks to see if the java:comp and java:comp/env names have been bound
+     * in JNDI.  The ENC is anchored to the TCCL, which in SOAPProcessor is
+     * shared by multiple threads during request dispatch, so this method 
+     * must be synchronized to prevent duplicate binding of java:comp/env.
+     * @throws javax.naming.NamingException failed to access naming context
+     */
+    private synchronized void setENC() throws javax.naming.NamingException {
+    	Context enc = (Context)new InitialContext().lookup("java:comp");
+    	
+    	try { 
+    		enc.lookup("env");
+    	}
+    	catch (javax.naming.NameNotFoundException nnfEx) {
+    		enc.createSubcontext("env");
+    	}
+    }
+   
 
     /**
      * Set the {@link org.jboss.soa.esb.message.Message} instance for this invocation context.



More information about the jboss-svn-commits mailing list