Skip to content

Commit 7abc4d4

Browse files
committed
Be nice and close Closeable
1 parent dbd20fe commit 7abc4d4

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,15 @@ static String toHumanReadableAscii(String s) {
280280
if (c > '\u001f' && c < '\u007f')
281281
continue;
282282

283-
Buffer buffer = new Buffer();
284-
buffer.writeUtf8(s, 0, i);
285-
buffer.writeUtf8CodePoint('?');
286-
for (int j = i + Character.charCount(c); j < length; j += Character.charCount(c)) {
287-
c = s.codePointAt(j);
288-
buffer.writeUtf8CodePoint(c > '\u001f' && c < '\u007f' ? c : '?');
283+
try (Buffer buffer = new Buffer()) {
284+
buffer.writeUtf8(s, 0, i);
285+
buffer.writeUtf8CodePoint('?');
286+
for (int j = i + Character.charCount(c); j < length; j += Character.charCount(c)) {
287+
c = s.codePointAt(j);
288+
buffer.writeUtf8CodePoint(c > '\u001f' && c < '\u007f' ? c : '?');
289+
}
290+
return buffer.readUtf8();
289291
}
290-
return buffer.readUtf8();
291292
}
292293
return s;
293294
}

0 commit comments

Comments
 (0)