aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-13 15:50:27 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2018-03-13 22:21:35 +0100
commit7392d3b30474a9ea9eeb28a7be1590c4751bca5e (patch)
tree71c7d71fb48ed7176688aaf1517251a9c2947b5d
parentda3d76f00ede01a976dbe1089f073a9c0f1c13a7 (diff)
downloadjgit-7392d3b30474a9ea9eeb28a7be1590c4751bca5e.tar.gz
jgit-7392d3b30474a9ea9eeb28a7be1590c4751bca5e.zip
Transport: 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: I536d682f1017c5088b94ff9f98ffa2b7c783d8bf Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java25
1 files changed, 4 insertions, 21 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
index ce321b014a..0a8091faaa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
@@ -51,7 +51,6 @@ import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -145,17 +144,8 @@ public abstract class Transport implements AutoCloseable {
}
private static void scan(ClassLoader ldr, URL url) {
- BufferedReader br;
- try {
- InputStream urlIn = url.openStream();
- br = new BufferedReader(new InputStreamReader(urlIn, CHARSET));
- } catch (IOException err) {
- // If we cannot read from the service list, go to the next.
- //
- return;
- }
-
- try {
+ try (BufferedReader br = new BufferedReader(
+ new InputStreamReader(url.openStream(), CHARSET))) {
String line;
while ((line = br.readLine()) != null) {
line = line.trim();
@@ -168,15 +158,8 @@ public abstract class Transport implements AutoCloseable {
line = line.substring(0, comment).trim();
load(ldr, line);
}
- } catch (IOException err) {
- // If we failed during a read, ignore the error.
- //
- } finally {
- try {
- br.close();
- } catch (IOException e) {
- // Ignore the close error; we are only reading.
- }
+ } catch (IOException e) {
+ // Ignore errors
}
}