Use try with close

See gh-33987
This commit is contained in:
Krzysztof Krason
2023-01-26 18:29:35 -08:00
committed by Phillip Webb
parent 0e68cae57f
commit d3efd7e091
10 changed files with 33 additions and 66 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -196,7 +196,7 @@ class JsonReader {
}
private JSONObject readJson(InputStream in, Charset charset) throws Exception {
try {
try (in) {
StringBuilder out = new StringBuilder();
InputStreamReader reader = new InputStreamReader(in, charset);
char[] buffer = new char[BUFFER_SIZE];
@@ -206,9 +206,6 @@ class JsonReader {
}
return new JSONObject(out.toString());
}
finally {
in.close();
}
}
}