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

StaticHandlerImpl is trying to write to response that is closed #1123

Closed
juddgaddie opened this issue Dec 26, 2018 · 3 comments
Closed

StaticHandlerImpl is trying to write to response that is closed #1123

juddgaddie opened this issue Dec 26, 2018 · 3 comments
Assignees
Milestone

Comments

@juddgaddie
Copy link

Version

This occurs in vertx-web version 3.5.2 and 3.6.2 (with corresponding vertx core)

Context

I encountered an exception in my CI environment, while it does not result in unexpected behaviour it does fill my logs with errors. This error occurs in the VertX provided StaticHandlerImpl when Firefox 57.0.4 is attempting to download /thirdparty/fonts/glyphicons-halflings-regular.woff

java.lang.IllegalStateException: Response is closed
	at io.vertx.core.http.impl.HttpServerResponseImpl.checkValid(HttpServerResponseImpl.java:564)
	at io.vertx.core.http.impl.HttpServerResponseImpl.putHeader(HttpServerResponseImpl.java:158)
	at io.vertx.core.http.impl.HttpServerResponseImpl.putHeader(HttpServerResponseImpl.java:55)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendFile$11(StaticHandlerImpl.java:423)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.wrapInTCCLSwitch(StaticHandlerImpl.java:261)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.sendFile(StaticHandlerImpl.java:412)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$null$0(StaticHandlerImpl.java:227)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.getFileProps(StaticHandlerImpl.java:312)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:204)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:284)
	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320)
	at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:474)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
@juddgaddie
Copy link
Author

Additionally this exception from the StaticHandler is thrown which may be related. Just guessing here but if the Channel (TCP socket) is closed but close() is not called on HTTPServerResponseImpl then when the response is attempted to be written the channel is closed and hence the exception below.

java.nio.channels.ClosedChannelException
	at io.netty.handler.stream.ChunkedWriteHandler.discard(ChunkedWriteHandler.java:172)
	at io.netty.handler.stream.ChunkedWriteHandler.doFlush(ChunkedWriteHandler.java:198)
	at io.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:135)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749)
	at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:802)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814)
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794)
	at io.vertx.core.net.impl.ConnectionBase.write(ConnectionBase.java:102)
	at io.vertx.core.net.impl.ConnectionBase.writeToChannel(ConnectionBase.java:112)
	at io.vertx.core.http.impl.Http1xServerConnection.writeToChannel(Http1xServerConnection.java:298)
	at io.vertx.core.net.impl.ConnectionBase.sendFile(ConnectionBase.java:312)
	at io.vertx.core.http.impl.Http1xServerConnection.sendFile(Http1xServerConnection.java:522)
	at io.vertx.core.http.impl.HttpServerResponseImpl.doSendFile(HttpServerResponseImpl.java:459)
	at io.vertx.core.http.impl.HttpServerResponseImpl.sendFile(HttpServerResponseImpl.java:378)
	at io.vertx.core.http.HttpServerResponse.sendFile(HttpServerResponse.java:329)
	at io.vertx.core.http.HttpServerResponse.sendFile(HttpServerResponse.java:315)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendFile$11(StaticHandlerImpl.java:477)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.wrapInTCCLSwitch(StaticHandlerImpl.java:261)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.sendFile(StaticHandlerImpl.java:412)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$null$0(StaticHandlerImpl.java:227)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.getFileProps(StaticHandlerImpl.java:312)
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:204)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:284)
	at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320)
	at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:474)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

@pmlopes
Copy link
Member

pmlopes commented Feb 13, 2019

A check should be added before the call:

at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendFile$11(StaticHandlerImpl.java:477)

slinkydeveloper added a commit that referenced this issue Apr 15, 2019
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
@slinkydeveloper slinkydeveloper added this to the 3.7.1 milestone Apr 15, 2019
@slinkydeveloper slinkydeveloper self-assigned this Apr 15, 2019
pmlopes added a commit that referenced this issue May 1, 2019
@pmlopes pmlopes closed this as completed May 1, 2019
@juddgaddie
Copy link
Author

Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants