mina 多线程解码问题

zerochen 发布于 2013/12/06 10:39
阅读 1K+
收藏 0
自己用mina写了个 http的解析器,发现,在模拟多线程访问的时候,出现如下错误:
org.apache.mina.filter.codec.ProtocolDecoderException: java.lang.IllegalStateException: doDecode() can't return true when buffer is not consumed. (Hexdump: 48 54 54 50 2F 31 2E 31 20 32 30 30 20 20 4F 4B 0D 0A 41 63 63 65 70 74 3A 20 69 6D 61 67 65 2F 67 69 66 2C 20 69 6D 61 67 65 2F 78 2D 78 62 69 74 6D 61 70 2C 20 69 6D 61 67 65 2F 6A 70 65 67 2C 20 69 6D 61 67 65 2F 70 6A 70 65 67 2C 20 2A 2F 2A 0D 0A 55 73 65 72 2D 41 67 65 6E 74 3A 20 4D 6F 7A 69 6C 6C 61 2F 34 2E 30 20 28 63 6F 6D 70 61 74 69 62 6C 65 3B 20 4D 53 49 45 20 36 2E 30 3B 20 57 69 6E 64 6F 77 73 20 4E 54 20 35 2E 31 29 0D 0A 48 6F 73 74 3A 20 31 32 37 2E 30 2E 30 2E 31 0D 0A 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 4B 65 65 70 2D 41 6C 69 76 65 0D 0A 43 6F 6E 74 65 6E 74 2D 4C 65 6E 67 74 68 3A 20 36 0D 0A 0D 0A 31 32 33 62 62 62 48 54 54 50 2F 31 2E 31 20 32 30 30 20 20 4F 4B 0D 0A 41 63 63 65 70 74 3A 20 69 6D 61 67 65 2F 67 69 66 2C 20 69 6D 61 67 65 2F 78 2D 78 62 69 74 6D 61 70 2C 20 69 6D 61 67 65 2F 6A 70 65 67 2C 20 69 6D 61 67 65 2F 70 6A 70 65 67 2C 20 2A 2F 2A 0D 0A 55 73 65 72 2D 41 67 65 6E 74 3A 20 4D 6F 7A 69 6C 6C 61 2F 34 2E 30 20 28 63 6F 6D 70 61 74 69 62 6C 65 3B 20 4D 53 49 45 20 36 2E 30 3B 20 57 69 6E 64 6F 77 73 20 4E 54 20 35 2E 31 29 0D 0A 48 6F 73 74 3A 20 31 32 37 2E 30 2E 30 2E 31 0D 0A 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 4B 65 65 70 2D 41 6C 69 76 65 0D 0A 43 6F 6E 74 65 6E 74 2D 4C 65 6E 67 74 68 3A 20 36 0D 0A 0D 0A 31 32 33 62 62 62)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:242)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:410)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:710)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:664)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:653)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:67)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1124)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: doDecode() can't return true when buffer is not consumed.
at org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:179)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:232)
... 15 more
加载中
0
wad12302
wad12302
是不是2边字符编码不一样GBK 或者UTF-8
wad12302
wad12302
回复 @颖辉小居 : 客户端或服务器2边编码不对,换下试试
颖辉小居
颖辉小居
回复 @zerochen : 怎么处理的吗
zerochen
zerochen
回复 @wad12302 : 已经处理好了,是粘包的问题
wad12302
wad12302
回复 @zerochen : 有时候不同的平台2边用不同的编码 就是mina 用UTF-8 客户端用GBk看看
zerochen
zerochen
不是,我统一采用的是utf8编码
返回顶部
顶部