summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-13 15:56:47 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2018-03-13 22:21:35 +0100
commit9450a55f76461b2b6d28f332b922d6dbc3247a64 (patch)
treeb9723bc719549bfab09fa81471ec5939437da026 /org.eclipse.jgit.pgm
parent7392d3b30474a9ea9eeb28a7be1590c4751bca5e (diff)
downloadjgit-9450a55f76461b2b6d28f332b922d6dbc3247a64.tar.gz
jgit-9450a55f76461b2b6d28f332b922d6dbc3247a64.zip
CommandCatalog: Simplify scan method using try-with-resource
The IOExceptions caught in the nested try blocks are all ignored, so we can just wrap them all up into a single try-with-resource block. Change-Id: Id85850b3f54c408af73063220e6fead20cb0fd80 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java25
1 files changed, 4 insertions, 21 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
index 0bc80f7d31..510daecd3d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
@@ -47,7 +47,6 @@ import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
@@ -148,31 +147,15 @@ public class CommandCatalog {
}
private void scan(final URL cUrl) {
- final BufferedReader cIn;
- try {
- final InputStream in = cUrl.openStream();
- cIn = new BufferedReader(new InputStreamReader(in, CHARSET));
- } catch (IOException err) {
- // If we cannot read from the service list, go to the next.
- //
- return;
- }
-
- try {
+ try (BufferedReader cIn = new BufferedReader(
+ new InputStreamReader(cUrl.openStream(), CHARSET))) {
String line;
while ((line = cIn.readLine()) != null) {
if (line.length() > 0 && !line.startsWith("#")) //$NON-NLS-1$
load(line);
}
- } catch (IOException err) {
- // If we failed during a read, ignore the error.
- //
- } finally {
- try {
- cIn.close();
- } catch (IOException e) {
- // Ignore the close error; we are only reading.
- }
+ } catch (IOException e) {
+ // Ignore errors
}
}