“IOException: Strange I/O stream” in CXF service client

℡╲_俬逩灬. 提交于 2019-12-25 02:08:22

问题


We are seeing an intermittent error in CXF. The response is fairly large (several hundred KB), MTOM is enabled, and enabling DEBUG for the CXF request/response logging interceptors fixes the issue, similarly to this post (which is unresolved). Our project is leveraging CXF version 2.2.9.

javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: [was class java.io.IOException] Strange I/O stream, returned 0 bytes on read 
                at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146)
                at com.sun.proxy.$Proxy751.browseFiles(Unknown Source)
…
                at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: [was class java.io.IOException] Strange I/O stream, returned 0 bytes on read
                at com.ctc.wstx.util.ExceptionUtil.throwRuntimeException(ExceptionUtil.java:18)
                at com.ctc.wstx.sr.StreamScanner.throwLazyError(StreamScanner.java:731)
                at com.ctc.wstx.sr.BasicStreamReader.safeFinishToken(BasicStreamReader.java:3657)
                at com.ctc.wstx.sr.BasicStreamReader.getTextCharacters(BasicStreamReader.java:830)
                at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleCharacters(StAXStreamConnector.java:323)
…
                at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
                ... 51 more
Caused by: java.io.IOException: Strange I/O stream, returned 0 bytes on read
                at com.ctc.wstx.io.BaseReader.reportStrangeStream(BaseReader.java:148)
                at com.ctc.wstx.io.UTF8Reader.loadMore(UTF8Reader.java:373)
…

I initially thought this was caused by a bad/invalid character (encoding?) in the response data; however, it is now looking more like a network issue. It is very odd, the service has been operating for a long time (years) without issue prior to running into this problem.

Why does this error occur? Is there a way to resolve this without enabling debug logging?


回答1:


Likely an upgrade to a newer version of CXF may fix this. There were some bugs in the CXF mime streams. In particular, this looks very similar to:

https://issues.apache.org/jira/browse/CXF-3068




回答2:


Based on this and considering the source code of com.ctc.wstx.io.UTF8Reader.loadMore, the problem is possible when the buffer passed to mBuffer through BaseReader(ReaderConfig, InputStream, byte[], int, int) is zero length.

Is the loadMore() method implementation correct? Should they do that if read() return 0?



来源:https://stackoverflow.com/questions/16198778/ioexception-strange-i-o-stream-in-cxf-service-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!