Re: svn commit: r882008 - /tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
Konstantin Kolinko wrote: > 2009/11/19 Mark Thomas : >> Konstantin Kolinko wrote: >>> twice the same condition >> Thanks - I'll fix that. >> > > OK, seen that. > > On second thought: > it is strange to synchronize on "this" to set a static field. That should be > synchronized(getClass()) Fair point, although I doubt this code is ever actually called in Tomcat... Fixed. Mark - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: svn commit: r882008 - /tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
2009/11/19 Mark Thomas : > Konstantin Kolinko wrote: >> >> twice the same condition > > Thanks - I'll fix that. > OK, seen that. On second thought: it is strange to synchronize on "this" to set a static field. That should be synchronized(getClass()) Best regards, Konstantin Kolinko - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: svn commit: r882008 - /tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
Konstantin Kolinko wrote: > 2009/11/19 : >> Author: markt >> Date: Wed Nov 18 23:54:24 2009 >> New Revision: 882008 >> >> +// If the thread is not bound, return a shared writable context >> +if (initialContext == null) { >> +if (initialContext == null) { >> +synchronized(this) { > > twice the same condition Thanks - I'll fix that. Mark > > You meant > >> +if (initialContext == null) { >> +synchronized(this) { >> +if (initialContext == null) { > > - > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: svn commit: r882008 - /tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
2009/11/19 : > Author: markt > Date: Wed Nov 18 23:54:24 2009 > New Revision: 882008 > > + // If the thread is not bound, return a shared writable context > + if (initialContext == null) { > + if (initialContext == null) { > + synchronized(this) { twice the same condition You meant > +if (initialContext == null) { > +synchronized(this) { > +if (initialContext == null) { - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
svn commit: r882008 - /tomcat/trunk/java/org/apache/naming/java/javaURLContextFactory.java
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)environment); -} else { -return null; } +return null; } @@ -100,13 +99,18 @@ // Redirect the request to the bound initial context return new SelectorContext( (Hashtable)environment, true); -} else { -// If the thread is not bound, return a shared writable context -if (initialContext == null) -initialContext = new NamingContext( -(Hashtable)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)environment, MAIN); +} +} +} +return initialContext; } - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org