Skip to content

Commit

Permalink
(fix) minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jiachun.fjc committed Jun 25, 2019
1 parent d3134ab commit 33ae75e
Showing 1 changed file with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
Expand Down Expand Up @@ -172,29 +173,16 @@ private int parseLine(Class<?> service, URL u, BufferedReader r, int lc, List<St
return lc + 1;
}

@SuppressWarnings("all")
private Iterator<String> parse(Class<?> service, URL url) {
InputStream in = null;
BufferedReader r = null;
ArrayList<String> names = Lists.newArrayList();
try {
in = url.openStream();
r = new BufferedReader(new InputStreamReader(in, "utf-8"));
ArrayList<String> names = new ArrayList<>();
try (InputStream in = url.openStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
int lc = 1;
while ((lc = parseLine(service, url, r, lc, names)) >= 0) ;
// noinspection StatementWithEmptyBody
while ((lc = parseLine(service, url, r, lc, names)) >= 0)
;
} catch (IOException x) {
throw fail(service, "error reading configuration file", x);
} finally {
try {
if (r != null) {
r.close();
}
if (in != null) {
in.close();
}
} catch (IOException y) {
throw fail(service, "error closing configuration file", y);
}
}
return names.iterator();
}
Expand Down

0 comments on commit 33ae75e

Please sign in to comment.