java.io.IOException:Bogus块大小

时间:2011-11-11 07:17:53

标签: java http ioexception httpconnection

  

任何人都可以告诉我为什么会发生Bogus块大小错误。

     
    

swingToSvlt方法的异常:java.io.IOException:Bogus块大小// - > java.io.IOException:Bogus块大小     at sun.net.www.http.ChunkedInputStream.processRaw(Unknown Source)>> at sun.net.www.http.ChunkedInputStream.readAheadBlocking(Unknown Source)>> at sun.net.www.http.ChunkedInputStream .readAhead(Unknown Source)>> at sun.net.www.http.ChunkedInputStream.read(Unknown Source)>> at java.io.FilterInputStream.read(Unknown Source)>> at sun.net .protocol.http.HttpURLConnection $ HttpInputStream.read(Unknown Source)>> at java.io.ObjectInputStream $ PeekInputStream.read(Unknown Source)>> at java.io.ObjectInputStream $ PeekInputStream.readFully(Unknown来源)>> at java.io.ObjectInputStream $ BlockDataInputStream.readUTFBody(Unknown Source)>> at java.io.ObjectInputStream $ BlockDataInputStream.readUTF(Unknown Source)>> at java.io.ObjectInputStream.readString (未知来源)>> at java.io.ObjectInputStream.readObject0(未知来源)>> at java.io.ObjectInputStream.defaultReadFields(未知来源)>> at java.io.ObjectInputStream.readSerialData(Un java.io.ObjectInputStream.readObject(java.io.ObjectInputStream.readObject) )>> at java.util.ArrayList.readObject(Unknown Source)>> at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&gt ;> at java.lang.reflect.Method.invoke(Unknown Source)>> at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)>> at java.io.ObjectInputStream.readSerialData(Unknown Source)> ;> at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)>> at java.io.ObjectInputStream.readObject0(Unknown Source)>> at java.io.ObjectInputStream.readObject(Unknown Source)>> ; at java.util.Hashtable.readObject(Unknown Source)>> at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown So urce)>> at java.lang.reflect.Method.invoke(Unknown Source)>> at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)>> at java.io.ObjectInputStream.readSerialData(Unknown)源代码>> at java.io.ObjectInputStream.readOrdinaryObject(未知来源)>> at java.io.ObjectInputStream.readObject0(未知来源)>> at java.io.ObjectInputStream.readObject(未知来源)

  

3 个答案:

答案 0 :(得分:2)

从代码ChunkedInputStream#processRaw,第306行,我们有:

/*
 * Extract the chunk size from the header (ignoring extensions).
 */
String header = new String(rawData, rawPos, pos-rawPos+1, "US-ASCII");
for (i=0; i < header.length(); i++) {
    if (Character.digit(header.charAt(i), 16) == -1)
        break;
}
try {
    chunkSize = Integer.parseInt(header.substring(0, i), 16);
} catch (NumberFormatException e) {
    error = true;
    throw new IOException("Bogus chunk size");
}

看起来服务器发送的标头不正确,我会看到发送的确切内容,并开始在那里找到问题。

答案 1 :(得分:1)

似乎有与此问题相关的错误。据推测,这与数据编码和输入流使用的编码不匹配有关。请参阅下面的错误链接

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6502503

答案 2 :(得分:0)

我遇到此错误是因为我的 Java 应用程序正在与配置错误的服务器进行通信。

似乎配置错​​误的服务器在预期发送 HTTP/1.1 响应时发送了 HTTP/1.0 响应。这是一个错误,因为分块编码仅在 HTTP/1.1 中引入。

您可以通过使用带有 --http1.1--http1.0 参数的 cURL 来查看这是否是您的问题。