Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#215 ByteMessage.readBytes(Byte[]) bug

open
Amir Shevat
API (2)
5
2006-07-06
2006-07-06
Nym
No

it is impossible read byte with a buffer bigger than
the received message size.
Please, in the class MantaBytesMEssage replace the
function:
private synchronized final void readFully(byte b[],
int off, int len) throws IOException {
int count =0;
if(off + len > b.length ||len+
internalOffset >message.length){
throw new IOException
("MNJMS00013 : BUFFER TOO SHORT FOR READING "+
b.length+"
BYTES IN METHOD readFully().");

}
while(count != len){
b[off+count]= message
[internalOffset++];
count++;
}
}

With

private synchronized final void readFully
(byte b[], int off, int len) throws IOException {
int count =0;
//System.out.println("off: "+off+ "
len: "+ len+ " b.lengh: "+b.length+ "
internalOffset: "+internalOffset +"
message.length: "+ message.length);
if(off + len > b.length ||len+
internalOffset <message.length){
throw new IOException
("MNJMS00013 : BUFFER TOO SHORT FOR READING "+
b.length+"
BYTES IN METHOD readFully().");

}
while(count != message.length){
b[off+count]= message
[internalOffset++];
count++;
}
}

Ciao
Francesco

Discussion