Exception when writing DefaultFileRegion in 4.0.22

89 views
Skip to first unread message

Reynold Xin

unread,
Aug 19, 2014, 5:12:26 PM8/19/14
to ne...@googlegroups.com
Code snippet: 

        val region = new DefaultFileRegion(fileChannel, segment.offset, segment.length)
        ctx.writeAndFlush(region).addListener(new ChannelFutureListener {
          override def operationComplete(future: ChannelFuture) {
            if (future.isSuccess) {
              logTrace(s"Sent block $blockId (${segment.length} B) back to $client")
            } else {
              logError(s"Error sending block $blockId to $client; closing connection", future.cause)
              ctx.close()
            }
          }
        })



This used to work in 4.0.21, but in 4.0.22 I saw the following exception:


java.lang.ClassCastException: io.netty.channel.DefaultFileRegion cannot be cast to io.netty.buffer.ByteBuf
at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:303)
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:707)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:315)
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:676)
at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1059)
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:688)
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:669)
at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115)
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:688)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:718)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741)
at org.apache.spark.network.netty.server.BlockServerHandler.writeFileSegment$1(BlockServerHandler.scala:93)
at org.apache.spark.network.netty.server.BlockServerHandler.channelRead0(BlockServerHandler.scala:135)
at org.apache.spark.network.netty.server.BlockServerHandler.channelRead0(BlockServerHandler.scala:38)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at java.lang.Thread.run(Thread.java:744)

Trustin Lee

unread,
Aug 19, 2014, 5:14:15 PM8/19/14
to Netty Discussions

4.0.23 should fix the problem. Could you confirm?

2014. 8. 20. 오전 6:12에 "Reynold Xin" <rx...@databricks.com>님이 작성:
--

---
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reynold Xin

unread,
Aug 19, 2014, 5:15:59 PM8/19/14
to ne...@googlegroups.com
Let me try.

Any chance you guys can send release announcements via an announcement email?

Reynold Xin

unread,
Aug 19, 2014, 5:43:17 PM8/19/14
to ne...@googlegroups.com
Yes, 4.0.23 fixed the problem. Thanks.

Norman Maurer

unread,
Aug 20, 2014, 12:20:22 AM8/20/14
to ne...@googlegroups.com, Reynold Xin
Doesn’t it work for you to use rss with netty.io ? We do all announcements there.

-- 
Norman Maurer
Principal Software Engineer
Red Hat

Reynold Xin

unread,
Aug 20, 2014, 12:43:32 AM8/20/14
to Norman Maurer, ne...@googlegroups.com
It's quite common for projects to have an announcement list that posts project release info. It is pretty low overhead. Maybe it is just me, but I stopped using rss when Google Reader was terminated. 

Anyway, feel free to do whatever you see fit. Just raising a small request here, but I don't feel strongly towards that.

Ngoc

unread,
Aug 20, 2014, 10:53:13 PM8/20/14
to ne...@googlegroups.com, nma...@redhat.com
> It's quite common for projects to have an announcement list that posts project release info. It is pretty low overhead. Maybe it is just me, but I stopped using rss when Google Reader was terminated.

I second that.
Please also post announcement to this mailing list.
I subscribe to immediately receive mail about
every new message in this mailing list.

Every time, after all your great effort to release a new release,
why not take one more minute to post an announcement?

Up to now, I usually know about new Netty versions after a few days late, sometimes a week:
* Via Twitter (I don't check Twitter very often).
* Access Netty homepage to read Javadoc, and sometimes click the "News" link to see if there's anything new. (I think new news should be right on the top page.)
Reply all
Reply to author
Forward
0 new messages