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

StaticFileHandler with cache throws java.nio.file.NoSuchFileException #12

Open
witoldsz opened this issue Oct 22, 2013 · 0 comments
Open

Comments

@witoldsz
Copy link

Hi,
I am using StaticFileHandler in my application (to serve static content), like this:

vertx.createHttpServer().websocketHandler(socket -> {
[...]
})
.requestHandler(new StaticFileHandler(vertx, "...path..."))
.listen(config.getHttpPort());

When webapp requests a document which does not exist, the StaticFileHandler throws an exception and browser waits forever:

SEVERE: Exception in Java verticle
java.lang.IllegalStateException: Failed to check file: java.nio.file.NoSuchFileException: ...path...
    at org.vertx.mods.web.StaticFileHandler.handle(StaticFileHandler.java:184)
    at org.vertx.mods.web.StaticFileHandler.handle(StaticFileHandler.java:37)
    at org.vertx.java.core.http.impl.ServerConnection.handleRequest(ServerConnection.java:180)
[...]

The problem does not exist when caching is disabled. My workaround is this:

.requestHandler(new StaticFileHandler(vertx, "...path...") {
            @Override
            public void handle(HttpServerRequest req) {
                try {super.handle(req);} catch (Exception e) {
                    req.response().setStatusCode(404).setStatusMessage("").end();
                }
            }
        }).listen(config.getHttpPort());

It does look like a bug to me, doesn't it?

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

1 participant