Author: fschumacher
Date: Thu Jan 22 20:54:47 2015
New Revision: 1654064

URL: http://svn.apache.org/r1654064
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57420
Make UEncoder a local variable in DirContextURLConnection to make it threadsafe.
Based on ideas from kkolinko and violetagg.

Modified:
    
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java?rev=1654064&r1=1654063&r2=1654064&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
 (original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
 Thu Jan 22 20:54:47 2015
@@ -42,6 +42,7 @@ import javax.naming.directory.DirContext
 import org.apache.naming.JndiPermission;
 import org.apache.tomcat.util.buf.UDecoder;
 import org.apache.tomcat.util.buf.UEncoder;
+import org.apache.tomcat.util.buf.UEncoder.SafeCharsSet;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
 
 /**
@@ -57,11 +58,6 @@ import org.apache.tomcat.util.http.FastH
 public class DirContextURLConnection extends URLConnection {
 
     private static final UDecoder URL_DECODER = new UDecoder();
-    private static final UEncoder URL_ENCODER = new UEncoder();
-
-    static{
-        URL_ENCODER.addSafeCharacter('/');
-    }
 
     // ----------------------------------------------------------- Constructors
 
@@ -436,11 +432,12 @@ public class DirContextURLConnection ext
             try {
                 NamingEnumeration<NameClassPair> enumeration =
                     collection.list("/");
+                UEncoder urlEncoder = new UEncoder(SafeCharsSet.WITH_SLASH);
                 while (enumeration.hasMoreElements()) {
                     NameClassPair ncp = enumeration.nextElement();
                     String s = ncp.getName();
                     result.addElement(
-                            URL_ENCODER.encodeURL(s, 0, 
s.length()).toString());
+                            urlEncoder.encodeURL(s, 0, s.length()).toString());
                 }
             } catch (NamingException e) {
                 // Unexpected exception

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1654064&r1=1654063&r2=1654064&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Jan 22 20:54:47 2015
@@ -184,6 +184,11 @@
         (markt)
       </fix>
       <fix>
+        <bug>57420</bug>: Make UEncoder a local variable in
+        DirContextURLConnection to make it threadsafe. Based on ideas from
+        kkolinko and violetagg. (fschumacher)
+      </fix>
+      <fix>
         <bug>57425</bug>: Don't add attributes with null value or name to the
         replicated context. (fschumacher)
       </fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to