Author: markt Date: Wed Nov 18 23:54:24 2009 New Revision: 882008 URL: http://svn.apache.org/viewvc?rev=882008&view=rev Log: Fix theorectical sync issue and soem Eclipse warnings
Modified: tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java Modified: tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java?rev=882008&r1=882007&r2=882008&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java (original) +++ tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java Wed Nov 18 23:54:24 2009 @@ -66,7 +66,7 @@ /** * Initial context. */ - protected static Context initialContext = null; + protected static volatile Context initialContext = null; // --------------------------------------------------------- Public Methods @@ -84,9 +84,8 @@ if ((ContextBindings.isThreadBound()) || (ContextBindings.isClassLoaderBound())) { return new SelectorContext((Hashtable<String,Object>)environment); - } else { - return null; } + return null; } @@ -100,13 +99,18 @@ // Redirect the request to the bound initial context return new SelectorContext( (Hashtable<String,Object>)environment, true); - } else { - // If the thread is not bound, return a shared writable context - if (initialContext == null) - initialContext = new NamingContext( - (Hashtable<String,Object>)environment, MAIN); - return initialContext; } + + // If the thread is not bound, return a shared writable context + if (initialContext == null) { + if (initialContext == null) { + synchronized(this) { + initialContext = new NamingContext( + (Hashtable<String,Object>)environment, MAIN); + } + } + } + return initialContext; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org