Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return properly encoded URLs from JarResource#getResourceURL() #15360

Merged
merged 1 commit into from
Mar 2, 2021
Merged

Return properly encoded URLs from JarResource#getResourceURL() #15360

merged 1 commit into from
Mar 2, 2021

Conversation

jaikiran
Copy link
Member

Fixes #15358

The commit here fixes the issue reported in #15358. The change involves, using the URI constructor to first properly encode (any special characters in) the resource name and then use the URI.toURL() to allow for the encoded path part to be used in the newly constructed URL.

This also include a test case which reproduces this issue and verifies the fix.

P.S: The test uses some special characters for directory and file names. These characters work fine on Linux, but I don't know if they are all allowed on Windows. So if this test case does indeed fail on Windows while trying to create a file or a directory, I will modify the test case to have it run only on *nix and maybe come up with some other characters for the file/directory for Windows.

@quarkus-bot quarkus-bot bot added the area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins label Feb 28, 2021
@jaikiran
Copy link
Member Author

jaikiran commented Mar 1, 2021

The failures are these (and look unrelated):

2021-02-28T16:02:14.1144584Z Executing [docker, run, --rm, -p, 8081:8081, -p, 8444:8444, --env, QUARKUS_HTTP_PORT=8081, --env, QUARKUS_HTTP_SSL_PORT=8444, --env, TEST_URL=http://localhost:8081, runner/quarkus-integration-test-container-image-standard:999-SNAPSHOT]
2021-02-28T16:02:16.5932798Z [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.328 s <<< FAILURE! - in io.quarkus.it.container.image.GreetingResourceIT
2021-02-28T16:02:16.5953611Z [ERROR] io.quarkus.it.container.image.GreetingResourceIT.testHelloEndpoint  Time elapsed: 2.396 s  <<< ERROR!
2021-02-28T16:02:16.5955398Z javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
2021-02-28T16:02:16.5957383Z 	at sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1310)
2021-02-28T16:02:16.5959020Z 	at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1151)
2021-02-28T16:02:16.5968115Z 	at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1054)
2021-02-28T16:02:16.5969857Z 	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394)
2021-02-28T16:02:16.5971903Z 	at org.apache.http.conn.ssl.SSLSocketFactory.createLayeredSocket(SSLSocketFactory.java:570)
2021-02-28T16:02:16.5974568Z 	at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:554)
2021-02-28T16:02:16.5979737Z 	at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:415)
2021-02-28T16:02:16.5983103Z 	at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
2021-02-28T16:02:16.5986887Z 	at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:326)
2021-02-28T16:02:16.5989628Z 	at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)
2021-02-28T16:02:16.5992234Z 	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)
2021-02-28T16:02:16.5994623Z 	at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
2021-02-28T16:02:16.5996879Z 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
2021-02-28T16:02:16.5999144Z 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
2021-02-28T16:02:16.6000856Z 	at org.apache.http.client.HttpClient$execute$0.call(Unknown Source)

and this one on Windows:

2021-02-28T14:33:20.1949722Z [ERROR] Tests run: 11, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 133.915 s <<< FAILURE! - in io.quarkus.maven.it.PackageIT
2021-02-28T14:33:20.1951427Z [ERROR] io.quarkus.maven.it.PackageIT.testCustomPackaging  Time elapsed: 16.785 s  <<< FAILURE!
2021-02-28T14:33:20.1952943Z org.opentest4j.AssertionFailedError: 
2021-02-28T14:33:20.1953654Z 
2021-02-28T14:33:20.1972645Z expected: 0
2021-02-28T14:33:20.1973478Z but was : 1
2021-02-28T14:33:20.1975081Z 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2021-02-28T14:33:20.1980310Z 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
2021-02-28T14:33:20.1983765Z 	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2021-02-28T14:33:20.1986560Z 	at io.quarkus.maven.it.PackageIT.testCustomPackaging(PackageIT.java:146)

I'll take a look at the PackageIT test later today to see if it's related to the change in this PR.

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@rsvoboda rsvoboda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproducer from #15358 now passes

@stuartwdouglas stuartwdouglas merged commit 39ab3db into quarkusio:master Mar 2, 2021
@quarkus-bot quarkus-bot bot added this to the 1.13 - master milestone Mar 2, 2021
@jaikiran jaikiran deleted the qk-15358 branch March 2, 2021 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MalformedURLException with Quarkus 1.12 (or master) when the app in ,;~!@#$%^&() directory
4 participants