I have been having a problem using altrmi with the instrument
manager/client where I would
get occasional corrupted stream errors. This was happening because the
stream was not being
read fully each time. Seems to be a problem is cases where the block of
data is large. Around
6200 bytes in this case.
I made the following change to ClientCustomStreamReadWriter, which seems
to have cleared
up the problem. I tried wrapping the inputStream in a
BufferedInputStream, but it made no
difference.
I wanted to make sure that this change A) was not going to cause any
problems, B) that it is
not going to get stuck waiting for data that may never show up, and C)
that this is the only
place in the altrmi package where a problem like this could arise.
Cheers,
Leif
Here is the committed diff:
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/ClientCustomStreamReadWriter.java,v
retrieving revision 1.1
diff -r1.1 ClientCustomStreamReadWriter.java
86,87c86,101
<
< mDataInputStream.read(byteArray);
---
> int pos = 0;
> int cnt = 0;
> // Loop here until the entire array has been read in.
> while( pos < byteArraySize )
> {
> int read = mDataInputStream.read( byteArray, pos, byteArraySize - pos );
> pos += read;
> cnt++;
> }
> /*
> if (cnt > 1)
> {
> System.out.println( "ClientCustomStreamWriter.readReply took " + cnt +
> " reads to read all, " + byteArraySize + ", required bytes." );
> }
> */
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>