Menu

#31 XML failure when no enough bytes are available immediately

open
nobody
Other (7)
5
2010-10-19
2010-10-19
Anonymous
No

Piccolo fails to decode an InputStream (with a valid XML document) when no enough bytes (to decode the header) are available immediately.
The issue is here (XMLStreamHeader.java):
int bytesAvailable = in.available();
if (bytesAvailable == 0 && bytesLeft == 0) {
bytesAvailable = 1; // But always get at least 1 byte
}

When in.available() returns 0 (it happens very often for network streams), Piccolo reads only one byte and tries to decode the header from it and then fails.
Actually, it should block until reading enough bytes to decode the header.

Discussion


Log in to post a comment.