You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2009/06/22 09:23:03 UTC
svn commit: r787156 - in /harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/util/Properties.java
test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java
Author: qiuxx
Date: Mon Jun 22 07:23:02 2009
New Revision: 787156
URL: http://svn.apache.org/viewvc?rev=787156&view=rev
Log:
Properties can't load a empty key-value pair while following a blank key. Adding the empty key-value pair while it preceding a blank line.
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java?rev=787156&r1=787155&r2=787156&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java Mon Jun 22 07:23:02 2009
@@ -388,7 +388,7 @@
case '\r':
mode = NONE;
firstChar = true;
- if (offset > 0) {
+ if (offset > 0 || (offset == 0 && keyLength == 0)) {
if (keyLength == -1) {
keyLength = offset;
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java?rev=787156&r1=787155&r2=787156&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java Mon Jun 22 07:23:02 2009
@@ -238,6 +238,25 @@
prop.load(new ByteArrayInputStream("a=\\q".getBytes()));
assertEquals("Failed to read slash value #3", expected, prop);
}
+
+ /**
+ * @tests java.util.Properties#load(java.io.InputStream)
+ */
+ public void test_loadLjava_io_InputStream_Special() throws IOException {
+ // Test for method void java.util.Properties.load(java.io.InputStream)
+ Properties prop = null;
+ prop = new Properties();
+ prop.load(new ByteArrayInputStream("=".getBytes()));
+ assertTrue("Failed to add empty key", prop.get("").equals(""));
+
+ prop = new Properties();
+ prop.load(new ByteArrayInputStream("=\r\n".getBytes()));
+ assertTrue("Failed to add empty key", prop.get("").equals(""));
+
+ prop = new Properties();
+ prop.load(new ByteArrayInputStream("=\n\r".getBytes()));
+ assertTrue("Failed to add empty key", prop.get("").equals(""));
+ }
/**
* @tests java.util.Properties#load(java.io.InputStream)