mirror of https://github.com/sbt/sbt.git
Fix SimpleInputStream reads into array
When the read methods of InputStream that take an Array[Byte] as input are called, they are supposed to return -1 if there are no bytes available due to an EOF. Previously it was incorrectly writing the -1 as a byte in the array and returning 1. Now it correctly returns -1. The condition for closing the WriteableInputStream was also incorrect. We should only close the input stream if it returns -1 in raw mode. Fixes #5999
This commit is contained in:
parent
f35675286b
commit
50f649c3c9
|
|
@ -486,7 +486,7 @@ object Terminal {
|
|||
val _ = readQueue.take
|
||||
val b = in.read
|
||||
buffer.put(b)
|
||||
if (Thread.interrupted() || (b != -1 && !isRaw.get)) closed.set(true)
|
||||
if (Thread.interrupted() || (b == -1 && isRaw.get)) closed.set(true)
|
||||
else impl()
|
||||
}
|
||||
try impl()
|
||||
|
|
@ -596,9 +596,12 @@ object Terminal {
|
|||
private[sbt] trait SimpleInputStream extends InputStream {
|
||||
override def read(b: Array[Byte]): Int = read(b, 0, b.length)
|
||||
override def read(b: Array[Byte], off: Int, len: Int): Int = {
|
||||
val byte = read()
|
||||
b(off) = byte.toByte
|
||||
1
|
||||
read() match {
|
||||
case -1 => -1
|
||||
case byte =>
|
||||
b(off) = byte.toByte
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
private[this] object proxyInputStream extends SimpleInputStream {
|
||||
|
|
|
|||
Loading…
Reference in New Issue