mirror of https://github.com/sbt/sbt.git
Fix detection of truncation (so messages exactly max length aren't flagged truncated)
This commit is contained in:
parent
1b21f200b5
commit
20ca549612
|
|
@ -209,13 +209,18 @@ class GigahorseUrlHandler(http: OkHttpClient) extends AbstractURLHandler {
|
||||||
val os = new ByteArrayOutputStream(ErrorBodyTruncateLen)
|
val os = new ByteArrayOutputStream(ErrorBodyTruncateLen)
|
||||||
var count = 0
|
var count = 0
|
||||||
var b = is.read()
|
var b = is.read()
|
||||||
while (b >= 0 && count < ErrorBodyTruncateLen) {
|
var truncated = false
|
||||||
os.write(b)
|
while (!truncated && b >= 0) {
|
||||||
count += 1
|
if (count >= ErrorBodyTruncateLen) {
|
||||||
b = is.read()
|
truncated = true
|
||||||
|
} else {
|
||||||
|
os.write(b)
|
||||||
|
count += 1
|
||||||
|
b = is.read()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
Some((os.toByteArray, count >= ErrorBodyTruncateLen))
|
Some((os.toByteArray, truncated))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue