首页 > 代码库 > netty上传文件bug
netty上传文件bug
之前公司有个同事离职,然后我交接了他的一些项目,其中有一个日志项目,主要就是业务部门调用Client往服务器上传日志文件,这个过程使用了netty,问题很奇怪大致如下:
1:一天中总有那么几个文件会上传失败报的异常信息是:
20:08:03.937] WARN DefaultPromise - An exception was thrown by io.netty.handler.stream.ChunkedWriteHandler$2.operationComplete() [20:08:03.937] java.lang.IllegalStateException: complete already: DefaultChannelPromise@4dd2405f(failure(io.netty.handler.codec.EncoderException: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1) [20:08:03.937] at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:393) [DefaultPromise.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelPromise.setSuccess(DefaultChannelPromise.java:76) [DefaultChannelPromise.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelPromise.setSuccess(DefaultChannelPromise.java:71) [DefaultChannelPromise.class:4.0.15.Final] [20:08:03.937] at io.netty.handler.stream.ChunkedWriteHandler$PendingWrite.success(ChunkedWriteHandler.java:352) ~[ChunkedWriteHandler$PendingWrite.class:4.0.15.Final] [20:08:03.937] at io.netty.handler.stream.ChunkedWriteHandler$2.operationComplete(ChunkedWriteHandler.java:273) ~[ChunkedWriteHandler$2.class:4.0.15.Final] [20:08:03.937] at io.netty.handler.stream.ChunkedWriteHandler$2.operationComplete(ChunkedWriteHandler.java:269) ~[ChunkedWriteHandler$2.class:4.0.15.Final] [20:08:03.937] at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:631) [DefaultPromise.class:4.0.15.Final] [20:08:03.937] at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:558) [DefaultPromise.class:4.0.15.Final] [20:08:03.937] at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:399) [DefaultPromise.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82) [DefaultChannelPromise.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:270) [ChannelOutboundBuffer.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.nio.AbstractNioByteChannel.doWrite(AbstractNioByteChannel.java:216) [AbstractNioByteChannel.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:231) [NioSocketChannel.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:682) [AbstractChannel$AbstractUnsafe.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:283) [AbstractNioChannel$AbstractNioUnsafe.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:651) [AbstractChannel$AbstractUnsafe.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelPipeline$HeadHandler.flush(DefaultChannelPipeline.java:1038) [DefaultChannelPipeline$HeadHandler.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelHandlerContext.invokeFlush(DefaultChannelHandlerContext.java:675) [DefaultChannelHandlerContext.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelHandlerContext.flush(DefaultChannelHandlerContext.java:656) [DefaultChannelHandlerContext.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) [ChannelOutboundHandlerAdapter.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:198) [CombinedChannelDuplexHandler.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelHandlerContext.invokeFlush(DefaultChannelHandlerContext.java:675) [DefaultChannelHandlerContext.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelHandlerContext.flush(DefaultChannelHandlerContext.java:656) [DefaultChannelHandlerContext.class:4.0.15.Final] [20:08:03.937] at io.netty.handler.stream.ChunkedWriteHandler.doFlush(ChunkedWriteHandler.java:311) [ChunkedWriteHandler.class:4.0.15.Final] [20:08:03.937] at io.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:141) [ChunkedWriteHandler.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelHandlerContext.invokeFlush(DefaultChannelHandlerContext.java:675) [DefaultChannelHandlerContext.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelHandlerContext.access$1600(DefaultChannelHandlerContext.java:29) [DefaultChannelHandlerContext.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:908) [DefaultChannelHandlerContext$WriteTask.class:4.0.15.Final] [20:08:03.937] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) [SingleThreadEventExecutor.class:4.0.15.Final] [20:08:03.937] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353) [NioEventLoop.class:4.0.15.Final] [20:08:03.937] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [SingleThreadEventExecutor$2.class:4.0.15.Final] [20:08:03.937] at java.lang.Thread.run(Thread.java:662) [na:1.6.0_23]
无论重传多少次都是一样的信息,而且服务器也没有收到连接请求。
2:后续针对这种情况修改了一些代码,前面的问题解决了,但是偶尔会有那么几个文件内容传不到服务器,也就是服务器接收的是空文件。
之后再gitgub上open issue地址为:
https://github.com/netty/netty/issues/3303
本文出自 “陈砚羲” 博客,请务必保留此出处http://chenyanxi.blog.51cto.com/4599355/1599335
netty上传文件bug
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。