You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by as...@apache.org on 2013/03/29 18:28:16 UTC

svn commit: r1462548 - /incubator/onami/trunk/converters/system/src/main/java/org/apache/onami/converters/system/PropertiesConverter.java

Author: ash2k
Date: Fri Mar 29 17:28:16 2013
New Revision: 1462548

URL: http://svn.apache.org/r1462548
Log:
[ONAMI-89]  Avoid re-encoding chars in PropertiesConverter

Modified:
    incubator/onami/trunk/converters/system/src/main/java/org/apache/onami/converters/system/PropertiesConverter.java

Modified: incubator/onami/trunk/converters/system/src/main/java/org/apache/onami/converters/system/PropertiesConverter.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/converters/system/src/main/java/org/apache/onami/converters/system/PropertiesConverter.java?rev=1462548&r1=1462547&r2=1462548&view=diff
==============================================================================
--- incubator/onami/trunk/converters/system/src/main/java/org/apache/onami/converters/system/PropertiesConverter.java (original)
+++ incubator/onami/trunk/converters/system/src/main/java/org/apache/onami/converters/system/PropertiesConverter.java Fri Mar 29 17:28:16 2013
@@ -19,8 +19,8 @@ package org.apache.onami.converters.syst
  * under the License.
  */
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.StringReader;
 import java.util.Properties;
 
 import org.apache.onami.converters.core.AbstractConverter;
@@ -39,43 +39,20 @@ public final class PropertiesConverter
 {
 
     /**
-     * Default properties encoding {@code ISO-8859-1}.
-     *
-     * Properties.load(stream) expects it.
-     */
-    private static final String PROPERTIES_ENCODING = "ISO-8859-1";
-
-    /**
      * {@inheritDoc}
      */
     public Object convert( String value, TypeLiteral<?> toType )
     {
         Properties properties = new Properties();
-        ByteArrayInputStream bais = null;
 
         try
         {
-            bais = new ByteArrayInputStream( value.getBytes( PROPERTIES_ENCODING ) );
-            properties.load( bais );
+            properties.load( new StringReader( value ) );
         }
         catch ( IOException e )
         {
             // Should never happen.
-            throw new ProvisionException( "Failed to parse " + value + "' into Properties", e );
-        }
-        finally
-        {
-            if ( bais != null )
-            {
-                try
-                {
-                    bais.close();
-                }
-                catch ( IOException e )
-                {
-                    // close quietly
-                }
-            }
+            throw new ProvisionException( "Failed to parse '" + value + "' into Properties", e );
         }
 
         return properties;