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

ChunkedStream returns null on EOF causing ChunkedWriteHandler to fail, 4.0.2.Final #1671

Closed
tantaman opened this issue Jul 29, 2013 · 1 comment
Assignees
Milestone

Comments

@tantaman
Copy link

Using ChunkedStream to read an empty file and ChunkedWriteHandler to write it to a channel results in a null pointer exception.

It appears that the problem is that ChunkedStream returns null once it reaches the end of the stream: https://github.com/netty/netty/blob/netty-4.0.2.Final/handler/src/main/java/io/netty/handler/stream/ChunkedStream.java#L99

and ChunkedWriteHandler then attempts to write the null message to the channel: https://github.com/netty/netty/blob/netty-4.0.2.Final/handler/src/main/java/io/netty/handler/stream/ChunkedWriteHandler.java#L260

Of course this is only a problem for empty files otherwise a non-null chunk is returned and subsequent reads in the ChunkedWriteHandler are correctly guarded by the isEndOfInput check.

This problem also occurs with ChunkedNioStream.

java.lang.NullPointerException: msg
    at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:674)
    at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:668)
    at io.netty.handler.stream.ChunkedWriteHandler.doFlush(ChunkedWriteHandler.java:260)
    at io.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:145)
    at io.netty.channel.DefaultChannelHandlerContext.invokeFlush0(DefaultChannelHandlerContext.java:730)
    at io.netty.channel.DefaultChannelHandlerContext.invokeFlush(DefaultChannelHandlerContext.java:713)
    at io.netty.channel.DefaultChannelHandlerContext.flush(DefaultChannelHandlerContext.java:706)
    at com.tantaman.ferox.priv.Response$FineGrainedControl.write(Response.java:253)
    at com.tantaman.ferox.remotestorage.route_handlers.ReadRouteHandler.returnDocument(ReadRouteHandler.java:133)
    at com.tantaman.ferox.remotestorage.route_handlers.ReadRouteHandler.respondWithResource(ReadRouteHandler.java:89)
    at com.tantaman.ferox.remotestorage.route_handlers.ReadRouteHandler.access$2(ReadRouteHandler.java:85)
    at com.tantaman.ferox.remotestorage.route_handlers.ReadRouteHandler$2.run(ReadRouteHandler.java:76)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:353)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:366)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
    at java.lang.Thread.run(Thread.java:722)
@normanmaurer
Copy link
Member

@tantaman thanks for reporting. Could you please retest with 4.0.5.Final-SNAPSHOT ? I just fixed it here...

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

2 participants