This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 198039 - URLsAreEqualTest and similar fails on space in path
Summary: URLsAreEqualTest and similar fails on space in path
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Module System (show other bugs)
Version: 7.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: SPACE_IN_PATH
Depends on:
Blocks:
 
Reported: 2011-04-24 05:56 UTC by Jaroslav Tulach
Modified: 2011-05-03 05:23 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2011-04-24 05:56:38 UTC
Some tests from o.n.bootstrap and core.startup fail on space in path. Following modification to 2ec9db219998 makes the test fail:


diff -r 2ec9db219998 o.n.bootstrap/test/unit/src/org/netbeans/URLsAreEqualTest.java
--- a/o.n.bootstrap/test/unit/src/org/netbeans/URLsAreEqualTest.java    Sat Apr 23 17:28:21 2011 +0200
+++ b/o.n.bootstrap/test/unit/src/org/netbeans/URLsAreEqualTest.java    Sun Apr 24 07:55:47 2011 +0200
@@ -64,7 +64,10 @@
     }
     
     public void testURLsAreEqual() throws Exception {
-        File jar = new File(getWorkDir(), "default-package-resource.jar");
+        final File wd = new File(getWorkDir(), "work dir");
+        wd.mkdirs();
+        
+        File jar = new File(wd, "default-package-resource.jar");
         
         URL orig = new URL("jar:" + jar.toURI() + "!/package/resource.txt");
         URLConnection conn = orig.openConnection();
Comment 1 Jaroslav Tulach 2011-04-25 06:03:04 UTC
ergonomics#baccf434c55d
Comment 2 Quality Engineering 2011-04-26 04:56:29 UTC
Integrated into 'main-golden', will be available in build *201104260000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/baccf434c55d
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #198039: Convert '%20' to ' '
Comment 3 Jesse Glick 2011-04-26 12:36:47 UTC
This does not look like a complete fix; you are only handling the special case of "%20", not other escapable characters. Demonstration:


diff --git a/o.n.bootstrap/test/unit/src/org/netbeans/URLsAreEqualTest.java b/o.n.bootstrap/test/unit/src/org/netbeans/URLsAreEqualTest.java
--- a/o.n.bootstrap/test/unit/src/org/netbeans/URLsAreEqualTest.java
+++ b/o.n.bootstrap/test/unit/src/org/netbeans/URLsAreEqualTest.java
@@ -64,7 +64,7 @@
     }
     
     public void testURLsAreEqual() throws Exception {
-        final File wd = new File(getWorkDir(), "work dir");
+        final File wd = new File(getWorkDir(), "work dir #1");
         wd.mkdirs();
         
         File jar = new File(wd, "default-package-resource.jar");


The following would work except possibly on UNC paths:


diff --git a/o.n.bootstrap/src/org/netbeans/JarClassLoader.java b/o.n.bootstrap/src/org/netbeans/JarClassLoader.java
--- a/o.n.bootstrap/src/org/netbeans/JarClassLoader.java
+++ b/o.n.bootstrap/src/org/netbeans/JarClassLoader.java
@@ -87,7 +87,6 @@
 import java.util.logging.Logger;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipException;
-import org.openide.util.Utilities;
 
 /**
  * A ProxyClassLoader capable of loading classes from a set of jar files
@@ -848,14 +847,12 @@
             if (bang == -1) {
                 throw new IOException("Malformed JAR-protocol URL: " + u);
             }
-            int from;
-            if (url.startsWith("file:")) {
-                from = Utilities.isWindows() ? 6 : 5;
-            } else {
-                from = 0;
+            String jar;
+            try {
+                jar = new File(new URI(url.substring(0, bang))).getAbsolutePath();
+            } catch (URISyntaxException x) {
+                throw new IOException(x);
             }
-            String jar = url.substring(from, bang).replace('/', File.separatorChar)
-                    .replace("%20", " ");
             Source _src = Source.sources.get(jar);
             LOGGER.log(Level.FINER, "openConnection for {0} jar: {1} src: {2}", new Object[]{u, jar, _src});
             if (_src == null) {


Anyway this is not even a partial fix of bug #195730, which is about something different (handling of Class-Path headers).
Comment 4 Jaroslav Tulach 2011-04-27 16:06:56 UTC
Thanks Jesse: ergonomics#0928450a313b
Comment 5 Quality Engineering 2011-05-03 05:23:47 UTC
Integrated into 'main-golden', will be available in build *201105030000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/0928450a313b
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #198039: Using URI to convert to File name. Thanks Jesse.