harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r555547 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Properties.java test/api/common/tests/api/java/util/PropertiesTest.java
Date Thu, 12 Jul 2007 09:36:57 GMT
Author: pyang
Date: Thu Jul 12 02:36:53 2007
New Revision: 555547

URL: http://svn.apache.org/viewvc?view=rev&rev=555547
Log:
Fix a bug in Properties#load(InputStream) with regression test, when the bytes read have no
\r\n neither '=', for example, a single word, it should be considered as 1 item, former Harmony
implementation just ignore it. 

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Properties.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/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?view=diff&rev=555547&r1=555546&r2=555547
==============================================================================
--- 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 Thu
Jul 12 02:36:53 2007
@@ -401,6 +401,9 @@
 			}
 			buf[offset++] = nextChar;
 		}
+        if(keyLength==-1 && offset>0){
+            keyLength = offset;
+        }
 		if (keyLength >= 0) {
 			String temp = new String(buf, 0, offset);
 			put(temp.substring(0, keyLength), temp.substring(keyLength));

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/PropertiesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/PropertiesTest.java?view=diff&rev=555547&r1=555546&r2=555547
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/PropertiesTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/PropertiesTest.java
Thu Jul 12 02:36:53 2007
@@ -369,6 +369,17 @@
                     .getProperty(nextKey).equals(myProps.getProperty(nextKey)));
         }
     }
+ 
+    /**
+     * if loading from single line like "hello" without "\n\r" neither "=", it should be
same 
+     * as loading from "hello="
+     */
+    public void testLoadSingleLine() throws Exception{
+        Properties props = new Properties();
+        InputStream sr = new ByteArrayInputStream("hello".getBytes());
+        props.load(sr);
+        assertEquals(1, props.size());
+    }
 
     /**
      * Sets up the fixture, for example, open a network connection. This method



Mime
View raw message