You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "David Jencks (JIRA)" <ji...@apache.org> on 2010/04/01 02:56:27 UTC

[jira] Created: (OPENEJB-1252) Dont use URLDecoder on file paths, it doesn't work

Dont use URLDecoder on file paths, it doesn't work
--------------------------------------------------

                 Key: OPENEJB-1252
                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
             Project: OpenEJB
          Issue Type: Bug
    Affects Versions: 3.1.3
            Reporter: David Jencks
            Assignee: David Jencks
             Fix For: 3.1.3


URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.

Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "Kevan Miller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858894#action_12858894 ] 

Kevan Miller commented on OPENEJB-1252:
---------------------------------------

Tried your patch. Seeing the following failure:

2010-04-20 09:59:43,718 ERROR [Deployer] Deployment failed due to
java.lang.IllegalArgumentException: bad url file:/C:/Program Files/geronimo-tomcat6-javaee5-2.2.1-SNAPSHOT/var/temp/geronimo-deployer26481.tmpdir/geronimo-activemq-ra-2.2.1-SNAPSHOT/META-INF/ra.xml
        at org.apache.openejb.util.URLs.toFile(URLs.java:48)
        at org.apache.openejb.util.URLs.toFilePath(URLs.java:56)
        at org.apache.openejb.config.DeploymentLoader.createConnectorModule(DeploymentLoader.java:943)
        at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:155)
        at org.apache.geronimo.openejb.deployment.EjbModuleBuilder.createModule(EjbModuleBuilder.java:234)
        at org.apache.geronimo.openejb.deployment.EjbModuleBuilder.createModule(EjbModuleBuilder.java:218)
        at org.apache.geronimo.j2ee.deployment.EARConfigBuilder.getDeploymentPlan(EARConfigBuilder.java:301)
        at org.apache.geronimo.deployment.Deployer.deploy(Deployer.java:229)
        at org.apache.geronimo.deployment.Deployer.deploy(Deployer.java:136)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.geronimo.gbean.runtime.ReflectionMethodInvoker.invoke(ReflectionMethodInvoker.java:34)
        at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:130)
        at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:851)
        at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:237)
        at org.apache.geronimo.kernel.KernelGBean.invoke(KernelGBean.java:342)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.geronimo.gbean.runtime.ReflectionMethodInvoker.invoke(ReflectionMethodInvoker.java:34)
        at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:130)
        at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:851)
        at org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:237)
        at org.apache.geronimo.system.jmx.MBeanGBeanBridge.invoke(MBeanGBeanBridge.java:172)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
        at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1426)
        at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
        at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1264)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1366)
        at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
        at sun.rmi.transport.Transport$1.run(Transport.java:159)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.URISyntaxException: Illegal character in path at index 16: file:/C:/Program Files/geronimo-tomcat6-javaee5-2.2.1-SNAPSHOT/var/temp/geronimo-deployer26481.tmpdir/geronimo-activemq-ra-2.2.1-SNAPSHOT/META-INF/ra.xml
        at java.net.URI$Parser.fail(URI.java:2809)
        at java.net.URI$Parser.checkChars(URI.java:2982)
        at java.net.URI$Parser.parseHierarchical(URI.java:3066)
        at java.net.URI$Parser.parse(URI.java:3014)
        at java.net.URI.<init>(URI.java:578)
        at java.net.URL.toURI(URL.java:918)
        at org.apache.openejb.util.URLs.toFile(URLs.java:46)
        ... 48 more



> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Jencks
>             Fix For: 3.1.3
>
>         Attachments: OPENEJB-1252.diff
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "David Jencks (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12852420#action_12852420 ] 

David Jencks commented on OPENEJB-1252:
---------------------------------------

I'm mystified by your change.  My copy of harmony luni calls the decode method you copied during URI.getPath(), so I assume any java implementing URI will too.  Why do you want your own copy of this method to maintain?

> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Blevins
>             Fix For: 3.1.3
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "David Jencks (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858727#action_12858727 ] 

David Jencks commented on OPENEJB-1252:
---------------------------------------

I think most of the problems are due to use of file.toURL() which is deprecated for a good reason... it doesn't work, it produces URLs with invalid characters in them.  When you call toURI() on them you get an exception.

Calling file.toURI().toURL() is what you are supposed to do and seems to result in a valid encoded URL.  I'm going to try changing all the toURL() s to toURI().toURL() and see what happens.

> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Jencks
>             Fix For: 3.1.3
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "David Blevins (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Blevins closed OPENEJB-1252.
----------------------------------

    Resolution: Fixed

> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Jencks
>             Fix For: 3.1.3
>
>         Attachments: OPENEJB-1252.diff
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "David Jencks (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Jencks updated OPENEJB-1252:
----------------------------------

    Attachment: OPENEJB-1252.diff

This converts all file.toURL() to file.toURI().toURL() which should avoid us introducing invalid URLS.  It also changes   container/openejb-core/src/main/java/org/apache/openejb/core/cmp/jpa/JpaCmpEngine.java to fix something unrelated.

I haven't got a clean build with this patch yet, it's here for experiment.

> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Jencks
>             Fix For: 3.1.3
>
>         Attachments: OPENEJB-1252.diff
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "David Blevins (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Blevins reopened OPENEJB-1252:
------------------------------------

      Assignee: David Jencks  (was: David Blevins)

I just wish the VM would offer a symmetrical method to file.toURL().  There really should be a url.toFile() method even if it throws an exception for all URL schemes except "file:".  The trick is a URL can't always be converted to a URI.

This will fail:

    URL url = new URL("file://some file.txt");
    new File(url.toURI().getPath());

As will this:

    new File("some file.txt").toURL().toURI();

Happy to let some else deal with this one.  So far I haven't found a solution that doesn't make another scenario fail.  The harmony code was the best I could come up with.

> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Jencks
>             Fix For: 3.1.3
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "David Blevins (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Blevins closed OPENEJB-1252.
----------------------------------

    Resolution: Fixed

$ svn ci
Sending        container/openejb-core/src/main/java/org/apache/openejb/util/URLs.java
Sending        container/openejb-loader/src/main/java/org/apache/openejb/loader/JarLocation.java
Transmitting file data ..
Committed revision 929938.


> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Blevins
>             Fix For: 3.1.3
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (OPENEJB-1252) Dont use URLDecoder on file paths, it doesn't work

Posted by "David Blevins (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Blevins reopened OPENEJB-1252:
------------------------------------


We still need to do some decoding, just not the plus.  Windows will encode paths in jar URLs which has made this a hard problem to solve (see the tuscany-related https://issues.apache.org/jira/browse/OPENEJB-1068 which basically proposed the same solution you came up with).

I dug through harmony to see what they do to open streams to URLs in their file and jar url handlers.  Looks like the code does do the %hex decoding, but not + decoding.  Grabbing that code, cleaning it up, and will check that in shortly.

> Dont use URLDecoder on file paths, it doesn't work
> --------------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Jencks
>             Fix For: 3.1.3
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (OPENEJB-1252) Dont use URLDecoder on file paths, it doesn't work

Posted by "David Jencks (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Jencks closed OPENEJB-1252.
---------------------------------

    Resolution: Fixed

rev 929764.

> Dont use URLDecoder on file paths, it doesn't work
> --------------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Jencks
>             Fix For: 3.1.3
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENEJB-1252) URL->File decoding should avoid "+" in paths

Posted by "David Blevins (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENEJB-1252?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Blevins updated OPENEJB-1252:
-----------------------------------

    Assignee: David Blevins  (was: David Jencks)
     Summary: URL->File decoding should avoid "+" in paths  (was: Dont use URLDecoder on file paths, it doesn't work)

> URL->File decoding should avoid "+" in paths
> --------------------------------------------
>
>                 Key: OPENEJB-1252
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1252
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.3
>            Reporter: David Jencks
>            Assignee: David Blevins
>             Fix For: 3.1.3
>
>
> URLS tries to use URLDecoder on a file path.  This converts the "+" characters mac os x likes to put in temp file names into " " (space) which causes disasters.  The javadoc says its not for paths, just form content encoded in a url.
> Use URI.create instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.