diff --git a/service/processor/src/main/java/com/google/auto/service/processor/ServicesFiles.java b/service/processor/src/main/java/com/google/auto/service/processor/ServicesFiles.java index 75d6cca747..b08431e809 100644 --- a/service/processor/src/main/java/com/google/auto/service/processor/ServicesFiles.java +++ b/service/processor/src/main/java/com/google/auto/service/processor/ServicesFiles.java @@ -15,9 +15,8 @@ */ package com.google.auto.service.processor; -import static com.google.common.base.Charsets.UTF_8; +import static java.nio.charset.StandardCharsets.UTF_8; -import com.google.common.io.Closer; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -57,12 +56,9 @@ static String getPath(String serviceName) { */ static Set readServiceFile(InputStream input) throws IOException { HashSet serviceClasses = new HashSet(); - Closer closer = Closer.create(); - try { - // TODO(gak): use CharStreams - BufferedReader r = closer.register(new BufferedReader(new InputStreamReader(input, UTF_8))); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, UTF_8))) { String line; - while ((line = r.readLine()) != null) { + while ((line = reader.readLine()) != null) { int commentStart = line.indexOf('#'); if (commentStart >= 0) { line = line.substring(0, commentStart); @@ -73,10 +69,6 @@ static Set readServiceFile(InputStream input) throws IOException { } } return serviceClasses; - } catch (Throwable t) { - throw closer.rethrow(t); - } finally { - closer.close(); } }