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 43364

Summary: SimpleAntArtifact throws URISyntaxException when ArtifactLocation contains spaces
Product: projects Reporter: David Konecny <dkonecny>
Component: AntAssignee: David Konecny <dkonecny>
Status: CLOSED FIXED    
Severity: blocker CC: jglick
Priority: P3 Keywords: API, SPACE_IN_PATH
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 41535    

Description David Konecny 2004-05-17 14:04:24 UTC
If you replace "dist/proj3.jar" with "d i s t/p r
o j 3.jar" in ReferenceHelperTest unit test you
will get the %SUBJ% exception.

Jesse, why AntArtifact.getArtifactLocation()
returns URI? Is that necessary? I think the String
would be more appropriate.

Otherwise the String must be encoded to be usable
for URI construction. AFAIK there is not method
for this conversion.

Unless you want to fix this yourself I can do it.
Just let me know your preference.
Comment 1 Jesse Glick 2004-05-17 16:44:02 UTC
Please do fix it.

The reason for using URI is that it could be either relative
("dist/foo.jar") or absolute ("file:/tmp/foo.jar") and URI provides a
reliable way of differentiating these. Note
AntArtifact.getArtifactFile impl. I suppose it could also be a String,
either a relative or absolute path, though it is less reliable to tell
which you have in that case I think. No strong opinion.

For "d i s t/p r o j 3.jar" the URI should be "d%20i%20.....3.jar".

For "/tmp/f o o.jar" the URI should be "file:/tmp/f%20o%20o.jar".
Comment 2 David Konecny 2004-05-17 16:47:19 UTC
If it is just a matter of replacing " " with "%20" I would leave there
URI and fix it.
Comment 3 Jesse Glick 2004-05-17 16:55:31 UTC
Well, ' ' -> "%20" and other substitutions for illegal URI characters...

For absolute paths you should be using new File(path).toURI(). For
relative paths, maybe there is some kind of utility method to encode
special characters properly? Can't you do this with a special URI
constructor, perhaps?
Comment 4 David Konecny 2004-05-17 17:43:37 UTC
You say URI with special constructor, hmmm, that was pretty easy. I
should think twice next time before asking dumb questions. Sorry.

Fixed:
src/org/netbeans/spi/project/support/ant/ReferenceHelper.java;
new revision: 1.9; previous revision: 1.8
src/org/netbeans/spi/project/support/ant/SimpleAntArtifact.java;
new revision: 1.6; previous revision: 1.5
test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java;
new revision: 1.9; previous revision: 1.8
Comment 5 Jaromir Uhrik 2005-07-14 16:19:28 UTC
Verified.