You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2009/09/29 18:23:48 UTC

svn commit: r820014 - /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java

Author: ivaynberg
Date: Tue Sep 29 16:23:48 2009
New Revision: 820014

URL: http://svn.apache.org/viewvc?rev=820014&view=rev
Log:
WICKET-2451 roll back UTF8 handling for property files as it breaks backwards-compat with existing 8859 encoded property files
Issue: WICKET-2451

Modified:
    wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java

Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java?rev=820014&r1=820013&r2=820014&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java Tue Sep 29 16:23:48 2009
@@ -17,11 +17,7 @@
 package org.apache.wicket.resource;
 
 import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Iterator;
@@ -317,26 +313,11 @@
 	 */
 	public class PropertiesFilePropertiesLoader extends AbstractPropertiesLoader
 	{
-	    /** Can the JDK read properties from Reader ? */
-	    private boolean loadFromReaderAvailable = false;
-
-	    /**
-	     * Buffer size used when reading a properties file.
-	     */
-	    private static final int BUFFER_SIZE = 2000;
-
 		/**
 		 * Construct.
 		 */
 		public PropertiesFilePropertiesLoader()
 		{
-	        try {
-	              Properties.class.getMethod("load", new Class[] {Reader.class});
-	              loadFromReaderAvailable = true;
-	            }
-	            catch (NoSuchMethodException ex) {
-	                loadFromReaderAvailable = false;
-	            }
 		}
 
 		/**
@@ -359,53 +340,9 @@
 		protected java.util.Properties loadProperties(BufferedInputStream in) throws IOException
 		{
 			java.util.Properties properties = new java.util.Properties();
-		    // If we are on JDK 6 we load from Reader
-		    if (loadFromReaderAvailable) {
 			properties.load(in);
-	        // If we are on JDK <=5 then we convert to ASCII
-		    } else {
-	            properties.load(readUTFStreamToEscapedASCII(in));
-		    }
 			return properties;
 		}
-
-	    /**
-	     * Reads a UTF-8 stream, performing a conversion to ASCII (i.e., ISO8859-1 encoding). Characters outside the normal
-	     * range for ISO8859-1 are converted to unicode escapes. In effect, Tapestry is performing native2ascii on the
-	     * files, on the fly.
-	     */
-	    private InputStream readUTFStreamToEscapedASCII(InputStream is) throws IOException
-	    {
-	        Reader reader = new InputStreamReader(is, "UTF-8");
-
-	        StringBuilder builder = new StringBuilder(BUFFER_SIZE);
-	        char[] buffer = new char[BUFFER_SIZE];
-
-	        while (true)
-	        {
-	            int length = reader.read(buffer);
-
-	            if (length < 0) break;
-
-	            for (int i = 0; i < length; i++)
-	            {
-	                char ch = buffer[i];
-
-	                if (ch <= '\u007f')
-	                {
-	                    builder.append(ch);
-	                    continue;
-	                }
-	                builder.append(String.format("\\u%04x", (int) ch));
-	            }
-	        }
-
-	        reader.close();
-
-	        byte[] resourceContent = builder.toString().getBytes();
-	        return new ByteArrayInputStream(resourceContent);
-	    }
-
 	}
 
 	/**