Community
Participate
Working Groups
Build Identifier: We might have discovered a bug with the way Jetty handles UNC paths. We have a scenario where our jetty instances are deployed (and started) on Windows UNC paths. In such scenario my Spring stack fails as Jetty is unable to resolve the Resources correctly. The suspected culprit is *org.eclipse.jetty.util.resource.Resource* line * 163* File file=new File(resource).getCanonicalFile(); url=new URL(URIUtil.encodePath(file.*toURL()*.toString())); should be File file=new File(resource).getCanonicalFile(); url=new URL(URIUtil.encodePath(file.*toURI().toURL()*.toString())); java.io.File.toURL() is deprecated and it doesn't work correctly. The following code snippet shows what happens: String filestr = "\\\\192.168.150.83\\folder\\a.txt"; java.io.File f = new java.io.File(filestr); System.out.println("1 File: " + f); System.out.println("2 File.toURL: " + f.toURL()); System.out.println("3 File.toURI: " + f.toURI()); System.out.println("4 File.toURI.toURL: " + f.toURI().toURL()); The output is 1 File: \\192.168.150.83\folder\a.txt 2 File.toURL: file://192.168.150.83/folder/a.txt 3 File.toURI: file:////192.168.150.83/folder/a.txt 4 File.toURI.toURL: file:////192.168.150.83/folder/a.txt As you can see 2 is totally wrong - it no longer references a UNC path. Reproducible: Always Steps to Reproduce: 1. See example program provided in the bug details 2. Try to start up a spring-based web app with jetty deploying the server on a UNC share like \\192.168.1.150\d$\jetty\
Thank you very much for reporting this issue. While your assessment of the problem is likely correct, the proposed solution will not work because URI.toURL() method already encodes the special characters in the URI, and as a result URL is double-encoded. However, stripping the operator new and URIUtil.encodePath() call yields the desired result. I'm going to commit my version of the fix and a test that I've written for it. I don't have Windows environment available at the moment, so I'm going to run the build on our Hudson instance tomorrow and see if it works correctly.
hi, could you post your fix here on the bug please? It should be a one line change - that way we can patch our jetty before the official distribution comes out. Many thanks! Michele
Michele, My apologies, it turned out that I only made the change locally, but did not commit it to the repository. I've committed the changes now. -Michael
Committed r3214.
Fixed the UNC path resource test on Windows. Committed r3257.