Hi, first thank you all for this open source lib.
The problem: The method WinPTYInputStream.read returns all kind of negative values and even worse it can return -1 without the stream having reached the end. This is not meeting the InputStream specification stated below:
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end
of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an
exception is thrown.
from https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/io/InputStream.html#read()
Proposed Fix:
// proposed fix
@Override
public int read() throws IOException {
byte b[] = new byte[1];
if (1 != read(b, 0, 1)) {
return -1;
}
return Byte.toUnsignedInt(b[0]); // the original code returns the byte directly
}
Hi, first thank you all for this open source lib.
The problem: The method WinPTYInputStream.read returns all kind of negative values and even worse it can return -1 without the stream having reached the end. This is not meeting the InputStream specification stated below:
Proposed Fix: