3

Can any one tell me why the Bogus chunk size error occurs.

Exception at the swingToSvlt method:java.io.IOException:Bogus chunk size//->java.io.IOException: Bogus chunk size 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.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)>>at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)>>at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)>>at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(Unknown Source)>>at java.io.ObjectInputStream$BlockDataInputStream.readUTF(Unknown Source)>>at java.io.ObjectInputStream.readString(Unknown Source)>>at java.io.ObjectInputStream.readObject0(Unknown Source)>>at java.io.ObjectInputStream.defaultReadFields(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.ArrayList.readObject(Unknown Source)>>at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)>>at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)>>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 Source)>>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)

vairam
  • 471
  • 1
  • 11
  • 26

3 Answers3

3

From the code ChunkedInputStream#processRaw, line 306, we have:

/*
 * 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");
}

It looks like the server is sending incorrect headers, I'd see exactly what is being sent, and start to find the problem there.

Matthew Farwell
  • 60,889
  • 18
  • 128
  • 171
  • From what I can tell, the only way it is possible is if the line that is supposed to contain the chunk size has its first character as non-valid hexadecimal (see the loop just above what you posted). –  Nov 11 '11 at 08:08
  • You're right, I've added the loop above. So the chunk isn't prefixed by the chunk size or the chunk is empty. Sounds like a server/network problem to me. – Matthew Farwell Nov 11 '11 at 08:23
1

There seemed to be bug related to this issue. Supposedly this is related to the mismatch in the encoding of the data and the encoding used by the Inputstream. Refer the bug link below

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

Drona
  • 6,886
  • 1
  • 29
  • 35
  • That bug was fixed in 6u12. You can see in the code Matthew Farwell posted that it now uses the correct encoding as mentioned in that bug's evaluation. –  Nov 11 '11 at 08:26
0

I experienced this error because my Java application was communicating with a misconfigured server.

It seems the misconfigured server sent an HTTP/1.0 response when it was expected to send an HTTP/1.1 response. This is an error because chunked encoding was only introduced in HTTP/1.1.

You can see if this is your problem by using cURL with the --http1.1 or --http1.0 arguments.

diachedelic
  • 2,195
  • 1
  • 24
  • 28