You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/01/30 06:16:55 UTC
svn commit: r501311 - in /harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/
main/java/org/apache/harmony/luni/util/ test/java/tests/api/java/net/
Author: pyang
Date: Mon Jan 29 21:16:49 2007
New Revision: 501311
URL: http://svn.apache.org/viewvc?view=rev&rev=501311
Log:
Apply patch for HARMONY-1700 ([classlib][archive] URL.openStream() should throw FileNotFoundEx if file not exists in jar file)
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java?view=diff&rev=501311&r1=501310&r2=501311
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java Mon Jan 29 21:16:49 2007
@@ -188,6 +188,11 @@
URL jarFileURL = getJarFileURL();
if (jarFileURL.getProtocol().equals("file")) { //$NON-NLS-1$
String fileName = jarFileURL.getFile();
+ if(!new File(Util.decode(fileName,false)).exists()){
+ // KA026=JAR entry {0} not found in {1}
+ throw new FileNotFoundException(Msg.getString("KA026", //$NON-NLS-1$
+ getEntryName(), fileName));
+ }
String host = jarFileURL.getHost();
if (host != null && host.length() > 0) {
fileName = "//" + host + fileName; //$NON-NLS-1$
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?view=diff&rev=501311&r1=501310&r2=501311
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties Mon Jan 29 21:16:49 2007
@@ -318,3 +318,4 @@
KA023=Proxy is null or invalid type
KA024=One of urls is null
KA025=Method has not been implemented
+KA026=JAR entry {0} not found in {1}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java?view=diff&rev=501311&r1=501310&r2=501311
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java Mon Jan 29 21:16:49 2007
@@ -143,7 +143,7 @@
out.closeEntry();
out.close();
- JarURLConnection conn = (JarURLConnection) new URL("jar:file:/"
+ JarURLConnection conn = (JarURLConnection) new URL("jar:file://"
+ jarFile.getAbsolutePath().replaceAll(" ", "%20") + "!/")
.openConnection();
conn.getJarFile().entries();
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java?view=diff&rev=501311&r1=501310&r2=501311
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java Mon Jan 29 21:16:49 2007
@@ -35,6 +35,7 @@
import java.security.Permission;
import java.util.ArrayList;
import java.util.List;
+
import tests.support.Support_Configuration;
import tests.support.resource.Support_Resources;
@@ -831,9 +832,23 @@
}
/**
+ * @throws MalformedURLException
* @tests java.net.URL#openStream()
*/
- public void test_openStream() {
+ public void test_openStream() throws MalformedURLException {
+ // Regression test for Harmony-1700
+ URL BASE = URLTest.class.getClassLoader().getResource(
+ URLTest.class.getPackage().getName().replace('.',
+ File.separatorChar)
+ + "/hello.jar");
+ URL url = new URL("jar:" + BASE + "!/foo.jar!/Bugs/HelloWorld.class");
+ try {
+ url.openStream();
+ fail("should throw FNFE.");
+ } catch (Exception e){
+ assertEquals("java.io.FileNotFoundException", e.getClass().getName());
+ }
+
// Test for method java.io.InputStream java.net.URL.openStream()
File resources = Support_Resources.createTempFolder();
try {