Forum Bugs

Java Library and PrinceControl Interface fail in congested I/O.

yiqiu
When testing the PrinceControl interface with the Java Wrapper 20151017, we found a issue that will fail during high throughput.

Specifically, in Chunk#readChunk
	if (input.read(tagBytes, 0, 3) != 3)
	    throw new IOException("failed to read chunk tag");

where the input is a normal java.io.InputStream.

When there is not enough data in the pipe coming from the prince process, possibly due to high load to the prince process or even the underlying OS.

According to the javadoc of java.io.InputStream, the read will NOT block when there is at least 1 byte available in the pipe. In such case, the readChunk method will throw an exception and propagate all the way up. At that point, there is no way to recover.

The caller of the library will have to catch the exception and stop and start the prince process again.

We found it to be failing quite regularly during high throughput.

One thing we tried was to patched the prince java library and wrap the read call in Apache Common's IOUtils, which will not give up the read early when there is not enough data in the pipe.

The patch seems to be working, but ideally we want to see it working with the official wrapper.
mikeday
Thanks, we will take a look at this issue.
mikeday
This issue is now fixed in prince-java-20160124.zip, which is more careful about how it handles unexpectedly short reads. Hopefully this should resolve the problem! :)