harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r477777 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/ main/java/org/apache/harmony/luni/internal/net/www/protocol/file/ test/java/org/apache/harmony/luni/tests/java/lang/ test/resources/org/apache/harmony/luni/...
Date Tue, 21 Nov 2006 17:38:37 GMT
Author: pyang
Date: Tue Nov 21 09:38:35 2006
New Revision: 477777

URL: http://svn.apache.org/viewvc?view=rev&rev=477777
Log:
Apply patch for HARMONY-2074 ([classlib][luni]ClassLoader.getResourceAsStream() fails to get
property file with special char in its name)

Added:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/test#.properties
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java?view=diff&rev=477777&r1=477776&r2=477777
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java
Tue Nov 21 09:38:35 2006
@@ -59,6 +59,9 @@
 			return;
 		}
 		entryName = file.substring(sepIdx + 2, file.length());
+		if (null != url.getRef()) {
+			entryName += "#" + url.getRef();
+		}
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java?view=diff&rev=477777&r1=477776&r2=477777
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/file/FileURLConnection.java
Tue Nov 21 09:38:35 2006
@@ -58,8 +58,12 @@
      */
     public FileURLConnection(URL url) {
         super(url);
-        if ((fileName = url.getFile()) == null) {
-            fileName = "";
+        fileName = url.getFile(); 
+        if (url.getRef() != null) { 
+            fileName += "#" + url.getRef(); 
+        } 
+        if (fileName == null) { 
+            fileName = ""; 
         }
         String host = url.getHost();
         if (host != null && host.length() > 0) {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java?view=diff&rev=477777&r1=477776&r2=477777
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassLoaderTest.java
Tue Nov 21 09:38:35 2006
@@ -18,6 +18,7 @@
 package org.apache.harmony.luni.tests.java.lang;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.security.CodeSource;
 import java.security.Permission;
@@ -115,6 +116,15 @@
         assertNotNull("Failed to find resource: hyts_Foo.c", ClassLoader
                 .getSystemResource("hyts_Foo.c"));
     }
+    
+    
+    //Regression Test for JIRA-2047
+    public void test_getResourceAsStream_withSharpChar() throws Exception {
+		InputStream in = this.getClass().getClassLoader().getResourceAsStream(
+				ClassTest.FILENAME);
+		assertNotNull(in);
+		in.close();
+	}
 }
 
 class DynamicPolicy extends Policy {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java?view=diff&rev=477777&r1=477776&r2=477777
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
Tue Nov 21 09:38:35 2006
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
@@ -43,6 +44,8 @@
 
 public class ClassTest extends junit.framework.TestCase {
 
+    public static final String FILENAME = ClassTest.class.getPackage().getName().replace('.',
'/')+"/test#.properties";
+    
     static class StaticMember$Class {
         class Member2$A {
         }
@@ -712,4 +715,20 @@
         assertEquals("Class toString printed wrong value",
                      "class [Ljava.lang.Object;", clazz.toString());
     }
+    
+    
+    // Regression Test for JIRA-2047
+	public void test_getResourceAsStream_withSharpChar() throws Exception{
+		InputStream in = getClass().getResourceAsStream("/"+FILENAME);
+		assertNotNull(in);
+		in.close();
+        
+        in = getClass().getResourceAsStream(FILENAME);
+        assertNull(in);
+		
+		in = this.getClass().getClassLoader().getResourceAsStream(
+				FILENAME);
+		assertNotNull(in);
+		in.close();		
+	}
 }

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/test#.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/test%23.properties?view=auto&rev=477777
==============================================================================
    (empty)

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/java/lang/test#.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message