Handle IOException in readUnexpectedStderr
This commit is contained in:
@@ -107,12 +107,16 @@ class RootServer {
|
|||||||
if (!this::process.isInitialized) return null
|
if (!this::process.isInitialized) return null
|
||||||
var available = process.errorStream.available()
|
var available = process.errorStream.available()
|
||||||
return if (available <= 0) null else String(ByteArrayOutputStream().apply {
|
return if (available <= 0) null else String(ByteArrayOutputStream().apply {
|
||||||
while (available > 0) {
|
try {
|
||||||
val bytes = ByteArray(available)
|
while (available > 0) {
|
||||||
val len = process.errorStream.read(bytes)
|
val bytes = ByteArray(available)
|
||||||
if (len < 0) throw EOFException() // should not happen
|
val len = process.errorStream.read(bytes)
|
||||||
write(bytes, 0, len)
|
if (len < 0) throw EOFException() // should not happen
|
||||||
available = process.errorStream.available()
|
write(bytes, 0, len)
|
||||||
|
available = process.errorStream.available()
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Logger.me.w("Reading stderr was cut short", e)
|
||||||
}
|
}
|
||||||
}.toByteArray())
|
}.toByteArray())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user