Skip to content

Commit b5345e6

Browse files
eamonnmcmanusGoogle Java Core Libraries
authored andcommitted
Use try-with-resources instead of Closer.
RELNOTES=n/a PiperOrigin-RevId: 537940469
1 parent e27cfe2 commit b5345e6

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

service/processor/src/main/java/com/google/auto/service/processor/ServicesFiles.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
*/
1616
package com.google.auto.service.processor;
1717

18-
import static com.google.common.base.Charsets.UTF_8;
18+
import static java.nio.charset.StandardCharsets.UTF_8;
1919

20-
import com.google.common.io.Closer;
2120
import java.io.BufferedReader;
2221
import java.io.BufferedWriter;
2322
import java.io.IOException;
@@ -57,12 +56,9 @@ static String getPath(String serviceName) {
5756
*/
5857
static Set<String> readServiceFile(InputStream input) throws IOException {
5958
HashSet<String> serviceClasses = new HashSet<String>();
60-
Closer closer = Closer.create();
61-
try {
62-
// TODO(gak): use CharStreams
63-
BufferedReader r = closer.register(new BufferedReader(new InputStreamReader(input, UTF_8)));
59+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, UTF_8))) {
6460
String line;
65-
while ((line = r.readLine()) != null) {
61+
while ((line = reader.readLine()) != null) {
6662
int commentStart = line.indexOf('#');
6763
if (commentStart >= 0) {
6864
line = line.substring(0, commentStart);
@@ -73,10 +69,6 @@ static Set<String> readServiceFile(InputStream input) throws IOException {
7369
}
7470
}
7571
return serviceClasses;
76-
} catch (Throwable t) {
77-
throw closer.rethrow(t);
78-
} finally {
79-
closer.close();
8072
}
8173
}
8274

0 commit comments

Comments
 (0)