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

FileResolver fails when path contains + character #2619

Closed
zaytsev opened this issue Sep 12, 2018 · 5 comments
Closed

FileResolver fails when path contains + character #2619

zaytsev opened this issue Sep 12, 2018 · 5 comments
Milestone

Comments

@zaytsev
Copy link
Contributor

zaytsev commented Sep 12, 2018

Version

  • vert.x core: 3.5.3

Context

io.vertx.core.impl.FileResolver fails to extract content from JARs containing + in a file name (e.g. vertx-static-content-0.0.1+test-fat.jar).
Most likely java.net.URLDecoder.decode(String, String) replaces + with (space)

java -jar vertx-static-content-0.0.1+test-fat.jar
io.vertx.core.Starter
INFO: Succeeded in deploying verticle
io.vertx.ext.web.impl.RoutingContextImplBase
SEVERE: Unexpected exception in route
io.vertx.core.VertxException: java.io.FileNotFoundException: /home/user/workspace/vertx-static-content/target/vertx-static-content-0.0.1 test-fat.jar
        at io.vertx.core.impl.FileResolver.unpackFromJarURL(FileResolver.java:249)
        at io.vertx.core.impl.FileResolver.unpackUrlResource(FileResolver.java:153)
        at io.vertx.core.impl.FileResolver.resolveFile(FileResolver.java:134)
        at io.vertx.core.impl.VertxImpl.resolveFile(VertxImpl.java:776)
        at io.vertx.core.http.impl.HttpServerResponseImpl.doSendFile(HttpServerResponseImpl.java:432)
        at io.vertx.core.http.impl.HttpServerResponseImpl.sendFile(HttpServerResponseImpl.java:352)
        at io.vertx.core.http.HttpServerResponse.sendFile(HttpServerResponse.java:327)
        at io.vertx.core.http.HttpServerResponse.sendFile(HttpServerResponse.java:313)
        at test.Web.lambda$start$1(Web.java:15)

Do you have a reproducer?

https://github.com/zaytsev/vertx-static-content

@vietj vietj self-assigned this Sep 12, 2018
@vietj vietj added this to the 3.6.0 milestone Sep 12, 2018
@vietj
Copy link
Member

vietj commented Sep 12, 2018

your reproducer works for me (OSX), can you give more details about your platform ?

@zaytsev
Copy link
Contributor Author

zaytsev commented Sep 12, 2018

➜  vertx-static-content git:(master) uname -a
Linux desktop 4.18.6-arch1-1-ARCH #1 SMP PREEMPT Wed Sep 5 11:54:09 UTC 2018 x86_64 GNU/Linux
➜  vertx-static-content git:(master) java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
➜  vertx-static-content git:(master) mvn clean verify

...

Caused by: io.vertx.core.VertxException: java.io.FileNotFoundException: /home/user/workspace/vertx-static-content/target/vertx-static-content-0.0.1 test.jar
        at io.vertx.core.impl.FileResolver.unpackFromJarURL(FileResolver.java:249)
        at io.vertx.core.impl.FileResolver.unpackUrlResource(FileResolver.java:153)
        at io.vertx.core.impl.FileResolver.resolveFile(FileResolver.java:134)
        at io.vertx.core.impl.VertxImpl.resolveFile(VertxImpl.java:776)
        at io.vertx.core.file.impl.FileSystemImpl$17.<init>(FileSystemImpl.java:804)
        at io.vertx.core.file.impl.FileSystemImpl.existsInternal(FileSystemImpl.java:803)
        at io.vertx.core.file.impl.FileSystemImpl.exists(FileSystemImpl.java:339)
        at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$isFileExisting$2(StaticHandlerImpl.java:266)
        at io.vertx.ext.web.handler.impl.StaticHandlerImpl.wrapInTCCLSwitch(StaticHandlerImpl.java:249)
        ... 45 more
Caused by: java.io.FileNotFoundException: /home/user/workspace/vertx-static-content/target/vertx-static-content-0.0.1 test.jar
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.zip.ZipFile.<init>(ZipFile.java:169)
        at io.vertx.core.impl.FileResolver.unpackFromJarURL(FileResolver.java:211)
        ... 53 more

[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.452 s <<< FAILURE! - in test.WebIntegrationTest
[ERROR] testPage{Vertx, VertxTestContext}  Time elapsed: 0.307 s  <<< FAILURE!
java.lang.AssertionError: org.opentest4j.AssertionFailedError: expected: <200> but was: <500>
        at test.WebIntegrationTest.lambda$null$1(WebIntegrationTest.java:26)
        at test.WebIntegrationTest.lambda$testPage$2(WebIntegrationTest.java:25)

[ERROR] testJs{Vertx, VertxTestContext}  Time elapsed: 0.023 s  <<< FAILURE!
java.lang.AssertionError: org.opentest4j.AssertionFailedError: expected: <200> but was: <500>
        at test.WebIntegrationTest.lambda$null$3(WebIntegrationTest.java:36)
        at test.WebIntegrationTest.lambda$testJs$4(WebIntegrationTest.java:35)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   WebIntegrationTest.testJs org.opentest4j.AssertionFailedError: expected: <200> but was: <500>
[ERROR]   WebIntegrationTest.testPage org.opentest4j.AssertionFailedError: expected: <200> but was: <500>
[INFO]
[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.0:verify (default) @ vertx-static-content ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

@zaytsev
Copy link
Contributor Author

zaytsev commented Sep 12, 2018

➜  vertx-static-content git:(master) java -jar target/vertx-static-content-0.0.1+test-fat.jar
сен 12, 2018 2:42:09 PM io.vertx.core.Starter
INFO: Succeeded in deploying verticle
curl http://localhost:9999/page
Internal Server Error
=== page
сен 12, 2018 2:42:27 PM io.vertx.ext.web.impl.RoutingContextImplBase
SEVERE: Unexpected exception in route
io.vertx.core.VertxException: java.io.FileNotFoundException: /home/sergey/workspace/vertx-static-content/target/vertx-static-content-0.0.1 test-fat.jar (Нет такого файла или каталога)
        at io.vertx.core.impl.FileResolver.unpackFromJarURL(FileResolver.java:249)
        at io.vertx.core.impl.FileResolver.unpackUrlResource(FileResolver.java:153)
        at io.vertx.core.impl.FileResolver.resolveFile(FileResolver.java:134)
        at io.vertx.core.impl.VertxImpl.resolveFile(VertxImpl.java:776)
        at io.vertx.core.http.impl.HttpServerResponseImpl.doSendFile(HttpServerResponseImpl.java:432)
        at io.vertx.core.http.impl.HttpServerResponseImpl.sendFile(HttpServerResponseImpl.java:352)
        at io.vertx.core.http.HttpServerResponse.sendFile(HttpServerResponse.java:327)
        at io.vertx.core.http.HttpServerResponse.sendFile(HttpServerResponse.java:313)
        at test.Web.lambda$start$1(Web.java:15)

@pmlopes
Copy link
Contributor

pmlopes commented Sep 12, 2018

URLDecoder will replace + with a space, that was the reason that in web there's is a custom urlDecoder https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/impl/Utils.java#L234-L297 . Perhaps we should port it to core.

@vietj
Copy link
Member

vietj commented Sep 12, 2018

+1 @pmlopes

pmlopes added a commit that referenced this issue Sep 13, 2018
@vietj vietj assigned pmlopes and unassigned vietj Sep 13, 2018
vietj pushed a commit that referenced this issue Sep 14, 2018
vietj pushed a commit that referenced this issue Sep 25, 2018
* Fixes #2619: properly handle plus signs when resolving paths

Signed-off-by: Paulo Lopes <[email protected]>

* Fixes #2619: properly handle plus signs when resolving paths

Signed-off-by: Paulo Lopes <[email protected]>

* updates based on review

Signed-off-by: Paulo Lopes <[email protected]>

* Delete URIDecoder.java

Signed-off-by: Paulo Lopes <[email protected]>

* Updates based on the review

Signed-off-by: Paulo Lopes <[email protected]>
vietj pushed a commit that referenced this issue Sep 25, 2018
* Fixes #2619: properly handle plus signs when resolving paths

Signed-off-by: Paulo Lopes <[email protected]>

* Fixes #2619: properly handle plus signs when resolving paths

Signed-off-by: Paulo Lopes <[email protected]>

* updates based on review

Signed-off-by: Paulo Lopes <[email protected]>

* Delete URIDecoder.java

Signed-off-by: Paulo Lopes <[email protected]>

* Updates based on the review

Signed-off-by: Paulo Lopes <[email protected]>
@vietj vietj modified the milestones: 3.6.0, 3.5.4 Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants