You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2008/11/08 22:11:52 UTC
svn commit: r712432 - in
/commons/proper/configuration/branches/configuration2_experimental:
src/main/java/org/apache/commons/configuration2/
src/test/java/org/apache/commons/configuration2/ xdocs/
Author: oheger
Date: Sat Nov 8 13:11:52 2008
New Revision: 712432
URL: http://svn.apache.org/viewvc?rev=712432&view=rev
Log:
CONFIGURATION-345: Ensure that "ISO-8859-1" is used as default encoding, even by the constructors of the super class. Ported the fix to the configuration2 branch.
Modified:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml
Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java?rev=712432&r1=712431&r2=712432&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java Sat Nov 8 13:11:52 2008
@@ -215,11 +215,6 @@
/** Allow file inclusion or not */
private boolean includesAllowed;
- // initialization block to set the encoding before loading the file in the constructors
- {
- setEncoding(DEFAULT_ENCODING);
- }
-
/**
* Creates an empty PropertyConfiguration object which can be
* used to synthesize a new Properties file by adding values and
@@ -346,6 +341,20 @@
}
/**
+ * Returns the encoding to be used when loading or storing configuration
+ * data. This implementation ensures that the default encoding will be used
+ * if none has been set explicitly.
+ *
+ * @return the encoding
+ */
+ @Override
+ public String getEncoding()
+ {
+ String enc = super.getEncoding();
+ return (enc != null) ? enc : DEFAULT_ENCODING;
+ }
+
+ /**
* Returns the associated layout object.
*
* @return the associated layout object
Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java?rev=712432&r1=712431&r2=712432&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java Sat Nov 8 13:11:52 2008
@@ -21,6 +21,7 @@
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
@@ -822,6 +823,37 @@
}
/**
+ * Tests whether the correct default encoding is used when loading a
+ * properties file. This test is related to CONFIGURATION-345.
+ */
+ public void testLoadWithDefaultEncoding() throws ConfigurationException
+ {
+ class PropertiesConfigurationTestImpl extends PropertiesConfiguration
+ {
+ String loadEncoding;
+
+ public PropertiesConfigurationTestImpl(String fileName)
+ throws ConfigurationException
+ {
+ super(fileName);
+ }
+
+ @Override
+ public void load(InputStream in, String encoding)
+ throws ConfigurationException
+ {
+ loadEncoding = encoding;
+ super.load(in, encoding);
+ }
+ }
+
+ PropertiesConfigurationTestImpl testConf = new PropertiesConfigurationTestImpl(
+ testProperties);
+ assertEquals("Default encoding not used", "ISO-8859-1",
+ testConf.loadEncoding);
+ }
+
+ /**
* Creates a configuration that can be used for testing copy operations.
*
* @return the configuration to be copied
Modified: commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml?rev=712432&r1=712431&r2=712432&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml (original)
+++ commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml Sat Nov 8 13:11:52 2008
@@ -85,6 +85,10 @@
</release>
<release version="1.6" date="in SVN" description="">
+ <action dev="oheger" type="fix" issue="CONFIGURATION-345">
+ PropertiesConfiguration now per default uses the encoding "ISO-8859-1"
+ for loading properties files.
+ </action>
<action dev="oheger" type="fix" issue="CONFIGURATION-341">
The "force reload check" mechanism of CombinedConfiguration now also
works with sub configurations created by configurationAt().