commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r902421 - /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
Date Sat, 23 Jan 2010 15:26:03 GMT
Author: oheger
Date: Sat Jan 23 15:26:03 2010
New Revision: 902421

URL: http://svn.apache.org/viewvc?rev=902421&view=rev
Log:
Replaced deprecated decode() method.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java?rev=902421&r1=902420&r2=902421&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationUtils.java
Sat Jan 23 15:26:03 2010
@@ -21,6 +21,7 @@
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
@@ -59,6 +60,9 @@
     /** Constant for the name of the clone() method.*/
     private static final String METHOD_CLONE = "clone";
 
+    /** Constant for the encoding for URLs. */
+    private static final String ENCODING = "UTF-8";
+
     /** The logger.*/
     private static Log log = LogFactory.getLog(ConfigurationUtils.class.getName());
 
@@ -583,7 +587,15 @@
     {
         if (PROTOCOL_FILE.equals(url.getProtocol()))
         {
-            return new File(URLDecoder.decode(url.getPath()));
+            try
+            {
+                return new File(URLDecoder.decode(url.getPath(), ENCODING));
+            }
+            catch (UnsupportedEncodingException uex)
+            {
+                // should not happen because UTF-8 should be supported
+                throw new AssertionError("Encoding not supported: " + uex);
+            }
         }
         else
         {



Mime
View raw message