summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer <carsten.hammer@t-online.de>2019-04-06 18:16:21 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-04-13 18:53:58 +0200
commitc0268f899e3e600a45f6c028f4d0088b2fb2fce1 (patch)
treea017363ab828ae957cfa1f0c4ce8f72e268b0139
parent3c1af2761f91ec7c17b648c0537e6c7f1847032e (diff)
downloadjgit-c0268f899e3e600a45f6c028f4d0088b2fb2fce1.tar.gz
jgit-c0268f899e3e600a45f6c028f4d0088b2fb2fce1.zip
Join catch sections using multicatch
Change-Id: I1a9112e6a4f938638c599b489cb0858eca27ab91 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java8
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java6
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java19
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java20
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java5
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java5
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java5
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java5
-rw-r--r--org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java5
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java24
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaWindow.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalFetchConnection.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalPushConnection.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java17
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/GSSManagerFactory.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java4
36 files changed, 69 insertions, 223 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
index 8e999da6b3..5bac342b0a 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
@@ -554,13 +554,7 @@ public abstract class LocalDiskRepositoryTestCase {
try {
write(f, body);
return f;
- } catch (Error e) {
- f.delete();
- throw e;
- } catch (RuntimeException e) {
- f.delete();
- throw e;
- } catch (IOException e) {
+ } catch (Error | RuntimeException | IOException e) {
f.delete();
throw e;
}
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
index 95fe18b83c..48d016c064 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
@@ -486,9 +486,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
git.branchCreate().setName(branch).setStartPoint(commit).call();
return commit;
- } catch (IOException e) {
- throw new RuntimeException(e);
- } catch (GitAPIException e) {
+ } catch (IOException | GitAPIException e) {
throw new RuntimeException(e);
}
}
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 dbdccc10e2..b98bf151a5 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
@@ -163,13 +163,9 @@ public class CommandCatalog {
final Class<? extends TextBuiltin> clazz;
try {
clazz = Class.forName(cn, false, ldr).asSubclass(TextBuiltin.class);
- } catch (ClassNotFoundException notBuiltin) {
+ } catch (ClassNotFoundException | ClassCastException notBuiltin) {
// Doesn't exist, even though the service entry is present.
- //
- return;
- } catch (ClassCastException notBuiltin) {
// Isn't really a builtin, even though its listed as such.
- //
return;
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java
index 1773de5d78..85ace3a077 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java
@@ -156,24 +156,19 @@ public class CommandRef {
final Constructor<? extends TextBuiltin> c;
try {
c = impl.getDeclaredConstructor();
- } catch (SecurityException e) {
- throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e));
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e));
+ } catch (SecurityException | NoSuchMethodException e) {
+ throw new RuntimeException(MessageFormat
+ .format(CLIText.get().cannotCreateCommand, getName(), e));
}
c.setAccessible(true);
final TextBuiltin r;
try {
r = c.newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e));
- } catch (IllegalAccessException e) {
- throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e));
- } catch (IllegalArgumentException e) {
- throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e));
- } catch (InvocationTargetException e) {
- throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e));
+ } catch (InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ throw new RuntimeException(MessageFormat
+ .format(CLIText.get().cannotCreateCommand, getName(), e));
}
r.setCommandName(getName());
return r;
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
index 0373aeff58..9952f5cfc1 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
@@ -330,22 +330,12 @@ public class Main {
install("org.eclipse.jgit.console.ConsoleAuthenticator"); //$NON-NLS-1$
install("org.eclipse.jgit.console.ConsoleCredentialsProvider"); //$NON-NLS-1$
return true;
- } catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException | NoClassDefFoundError
+ | UnsupportedClassVersionError e) {
return false;
- } catch (NoClassDefFoundError e) {
- return false;
- } catch (UnsupportedClassVersionError e) {
- return false;
-
- } catch (IllegalArgumentException e) {
- throw new RuntimeException(CLIText.get().cannotSetupConsole, e);
- } catch (SecurityException e) {
- throw new RuntimeException(CLIText.get().cannotSetupConsole, e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(CLIText.get().cannotSetupConsole, e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(CLIText.get().cannotSetupConsole, e);
- } catch (NoSuchMethodException e) {
+ } catch (IllegalArgumentException | SecurityException
+ | IllegalAccessException | InvocationTargetException
+ | NoSuchMethodException e) {
throw new RuntimeException(CLIText.get().cannotSetupConsole, e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
index 0e1b398a73..6165c0aeed 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
@@ -338,12 +338,9 @@ class DiffAlgorithms extends TextBuiltin {
}
}
}
- } catch (IllegalArgumentException e) {
- throw die("Cannot determine names", e); //$NON-NLS-1$
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
throw die("Cannot determine names", e); //$NON-NLS-1$
}
-
return all;
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
index 300a01d246..a2ea8c20b4 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
@@ -403,9 +403,7 @@ class TextHashFunctions extends TextBuiltin {
folds.add(fold);
}
}
- } catch (IllegalArgumentException e) {
- throw new RuntimeException("Cannot determine names", e); //$NON-NLS-1$
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException("Cannot determine names", e); //$NON-NLS-1$
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
index a14f6514fe..213d9875db 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
@@ -133,10 +133,7 @@ public class AbstractTreeIteratorHandler extends
final CanonicalTreeParser p = new CanonicalTreeParser();
try (ObjectReader curs = clp.getRepository().newObjectReader()) {
p.reset(curs, clp.getRevWalk().parseTree(id));
- } catch (MissingObjectException e) {
- throw new CmdLineException(clp,
- CLIText.format(CLIText.get().notATree), name);
- } catch (IncorrectObjectTypeException e) {
+ } catch (MissingObjectException | IncorrectObjectTypeException e) {
throw new CmdLineException(clp,
CLIText.format(CLIText.get().notATree), name);
} catch (IOException e) {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java
index b925e31f85..d4effa3a10 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java
@@ -130,10 +130,7 @@ public class RevCommitHandler extends OptionHandler<RevCommit> {
final RevCommit c;
try {
c = clp.getRevWalk().parseCommit(id);
- } catch (MissingObjectException e) {
- throw new CmdLineException(clp,
- CLIText.format(CLIText.get().notACommit), name);
- } catch (IncorrectObjectTypeException e) {
+ } catch (MissingObjectException | IncorrectObjectTypeException e) {
throw new CmdLineException(clp,
CLIText.format(CLIText.get().notACommit), name);
} catch (IOException e) {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java
index 85922a27ba..19841f633a 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java
@@ -102,10 +102,7 @@ public class RevTreeHandler extends OptionHandler<RevTree> {
final RevTree c;
try {
c = clp.getRevWalk().parseTree(id);
- } catch (MissingObjectException e) {
- throw new CmdLineException(clp,
- CLIText.format(CLIText.get().notATree), name);
- } catch (IncorrectObjectTypeException e) {
+ } catch (MissingObjectException | IncorrectObjectTypeException e) {
throw new CmdLineException(clp,
CLIText.format(CLIText.get().notATree), name);
} catch (IOException e) {
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java
index 7d0e686a28..1e8d7d1e1e 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java
@@ -177,10 +177,7 @@ public class SshdSession implements RemoteSession {
timeoutMillis -= TimeUnit.NANOSECONDS
.toMillis(System.nanoTime() - start);
}
- } catch (IOException e) {
- exec.close(true);
- throw e;
- } catch (RuntimeException e) {
+ } catch (IOException | RuntimeException e) {
exec.close(true);
throw e;
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
index c43bdbd298..9289e5a67b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
@@ -167,9 +167,7 @@ public class GcPackRefsTest extends GcTestCase {
try {
refUpdateLockedRef.await();
packRefsDone.await();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- } catch (BrokenBarrierException e) {
+ } catch (InterruptedException | BrokenBarrierException e) {
Thread.currentThread().interrupt();
}
return super.isForceUpdate();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
index cf3d35fe89..9b8016ce20 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
@@ -282,13 +282,11 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
RevCommit commit = null;
try {
commit = walk.parseCommit(objectId);
- } catch (MissingObjectException e) {
- // ignore: the ref points to an object that does not exist;
- // it should be ignored as traversal starting point.
- } catch (IncorrectObjectTypeException e) {
- // ignore: the ref points to an object that is not a commit
- // (e.g. a tree or a blob);
- // it should be ignored as traversal starting point.
+ } catch (MissingObjectException | IncorrectObjectTypeException e) {
+ // ignore as traversal starting point:
+ // - the ref points to an object that does not exist
+ // - the ref points to an object that is not a commit (e.g. a
+ // tree or a blob)
}
if (commit != null)
add(commit);
@@ -348,9 +346,7 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
} else
walk.markUninteresting(walk.lookupCommit(start));
return this;
- } catch (MissingObjectException e) {
- throw e;
- } catch (IncorrectObjectTypeException e) {
+ } catch (MissingObjectException | IncorrectObjectTypeException e) {
throw e;
} catch (IOException e) {
throw new JGitInternalException(MessageFormat.format(
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
index 0e3d000d3a..9be4c916ba 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -1295,13 +1295,8 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
}
}
return newCommit;
- } catch (RefAlreadyExistsException e) {
- throw new JGitInternalException(e.getMessage(), e);
- } catch (RefNotFoundException e) {
- throw new JGitInternalException(e.getMessage(), e);
- } catch (InvalidRefNameException e) {
- throw new JGitInternalException(e.getMessage(), e);
- } catch (CheckoutConflictException e) {
+ } catch (RefAlreadyExistsException | RefNotFoundException
+ | InvalidRefNameException | CheckoutConflictException e) {
throw new JGitInternalException(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java
index f92455a96a..8908277725 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java
@@ -238,9 +238,7 @@ public class SubmoduleAddCommand extends
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
name, ConfigConstants.CONFIG_KEY_URL, uri);
modulesConfig.save();
- } catch (IOException e) {
- throw new JGitInternalException(e.getMessage(), e);
- } catch (ConfigInvalidException e) {
+ } catch (IOException | ConfigInvalidException e) {
throw new JGitInternalException(e.getMessage(), e);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java
index 2db12b8e25..6fd94052a4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java
@@ -128,9 +128,7 @@ public class SubmoduleInitCommand extends GitCommand<Collection<String>> {
if (!initialized.isEmpty())
config.save();
return initialized;
- } catch (IOException e) {
- throw new JGitInternalException(e.getMessage(), e);
- } catch (ConfigInvalidException e) {
+ } catch (IOException | ConfigInvalidException e) {
throw new JGitInternalException(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java
index 0606c5b8d4..58e59598ed 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java
@@ -108,9 +108,7 @@ public class SubmoduleStatusCommand extends
statuses.put(status.getPath(), status);
}
return statuses;
- } catch (IOException e) {
- throw new JGitInternalException(e.getMessage(), e);
- } catch (ConfigInvalidException e) {
+ } catch (IOException | ConfigInvalidException e) {
throw new JGitInternalException(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
index 7cf4b73af0..52393695d9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
@@ -162,9 +162,7 @@ public class SubmoduleSyncCommand extends GitCommand<Map<String, String>> {
if (!synced.isEmpty())
config.save();
return synced;
- } catch (IOException e) {
- throw new JGitInternalException(e.getMessage(), e);
- } catch (ConfigInvalidException e) {
+ } catch (IOException | ConfigInvalidException e) {
throw new JGitInternalException(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index 14653fe17f..667634f7f8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -253,13 +253,7 @@ public class DirCache {
try {
c.read();
- } catch (IOException e) {
- c.unlock();
- throw e;
- } catch (RuntimeException e) {
- c.unlock();
- throw e;
- } catch (Error e) {
+ } catch (IOException | RuntimeException | Error e) {
c.unlock();
throw e;
}
@@ -636,13 +630,7 @@ public class DirCache {
try (OutputStream o = tmp.getOutputStream();
OutputStream bo = new BufferedOutputStream(o)) {
writeTo(liveFile.getParentFile(), bo);
- } catch (IOException err) {
- tmp.unlock();
- throw err;
- } catch (RuntimeException err) {
- tmp.unlock();
- throw err;
- } catch (Error err) {
+ } catch (IOException | RuntimeException | Error err) {
tmp.unlock();
throw err;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
index b80c58ca9c..f0ee22d57a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
@@ -239,13 +239,7 @@ public class LockFile {
// Don't worry about a file that doesn't exist yet, it
// conceptually has no current content to copy.
//
- } catch (IOException ioe) {
- unlock();
- throw ioe;
- } catch (RuntimeException ioe) {
- unlock();
- throw ioe;
- } catch (Error ioe) {
+ } catch (IOException | RuntimeException | Error ioe) {
unlock();
throw ioe;
}
@@ -299,13 +293,7 @@ public class LockFile {
}
os.close();
os = null;
- } catch (IOException ioe) {
- unlock();
- throw ioe;
- } catch (RuntimeException ioe) {
- unlock();
- throw ioe;
- } catch (Error ioe) {
+ } catch (IOException | RuntimeException | Error ioe) {
unlock();
throw ioe;
}
@@ -353,13 +341,7 @@ public class LockFile {
os.getChannel().force(true);
out.close();
os = null;
- } catch (IOException ioe) {
- unlock();
- throw ioe;
- } catch (RuntimeException ioe) {
- unlock();
- throw ioe;
- } catch (Error ioe) {
+ } catch (IOException | RuntimeException | Error ioe) {
unlock();
throw ioe;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
index e8fac514be..da7250d141 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
@@ -298,13 +298,7 @@ public class WindowCache {
if (mmap)
return pack.mmap(offset, windowSize);
return pack.read(offset, windowSize);
- } catch (IOException e) {
- close(pack);
- throw e;
- } catch (RuntimeException e) {
- close(pack);
- throw e;
- } catch (Error e) {
+ } catch (IOException | RuntimeException | Error e) {
close(pack);
throw e;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaWindow.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaWindow.java
index a047534fbf..d152a392f0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaWindow.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaWindow.java
@@ -365,9 +365,7 @@ final class DeltaWindow {
resObj.setCachedDelta(deltaCache.cache(zbuf, len, deltaLen));
resObj.setCachedSize(deltaLen);
- } catch (IOException err) {
- deltaCache.credit(deltaLen);
- } catch (OutOfMemoryError err) {
+ } catch (IOException | OutOfMemoryError err) {
deltaCache.credit(deltaLen);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
index fd425abf35..84bf214607 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
@@ -97,9 +97,7 @@ class GlobalBundleCache {
bundles.put(type, bundle);
}
return (T) bundle;
- } catch (InstantiationException e) {
- throw new Error(e);
- } catch (IllegalAccessException e) {
+ } catch (InstantiationException | IllegalAccessException e) {
throw new Error(e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java
index cdd7be266f..c41fb416d5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java
@@ -182,9 +182,7 @@ public abstract class TranslationBundle {
field.set(this, translatedText);
} catch (MissingResourceException e) {
throw new TranslationStringMissingException(bundleClass, locale, field.getName(), e);
- } catch (IllegalArgumentException e) {
- throw new Error(e);
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
throw new Error(e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
index fcf78ac7b9..c1ec19e8fb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
@@ -182,10 +182,7 @@ abstract class BasePackConnection extends BaseConnection {
} catch (TransportException err) {
close();
throw err;
- } catch (IOException err) {
- close();
- throw new TransportException(err.getMessage(), err);
- } catch (RuntimeException err) {
+ } catch (IOException | RuntimeException err) {
close();
throw new TransportException(err.getMessage(), err);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
index a729445309..4dd9cc5774 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
@@ -400,10 +400,7 @@ public abstract class BasePackFetchConnection extends BasePackConnection
} catch (CancelledException ce) {
close();
return; // Caller should test (or just know) this themselves.
- } catch (IOException err) {
- close();
- throw new TransportException(err.getMessage(), err);
- } catch (RuntimeException err) {
+ } catch (IOException | RuntimeException err) {
close();
throw new TransportException(err.getMessage(), err);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
index 84a0972723..6cf75031cd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
@@ -112,10 +112,7 @@ class BundleFetchConnection extends BaseFetchConnection {
} catch (TransportException err) {
close();
throw err;
- } catch (IOException err) {
- close();
- throw new TransportException(transport.uri, err.getMessage(), err);
- } catch (RuntimeException err) {
+ } catch (IOException | RuntimeException err) {
close();
throw new TransportException(transport.uri, err.getMessage(), err);
}
@@ -205,10 +202,7 @@ class BundleFetchConnection extends BaseFetchConnection {
packLock = parser.parse(NullProgressMonitor.INSTANCE);
ins.flush();
}
- } catch (IOException err) {
- close();
- throw new TransportException(transport.uri, err.getMessage(), err);
- } catch (RuntimeException err) {
+ } catch (IOException | RuntimeException err) {
close();
throw new TransportException(transport.uri, err.getMessage(), err);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
index 6c26b7026a..53eaa6a7f9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
@@ -78,9 +78,7 @@ public class HMACSHA1NonceGenerator implements NonceGenerator {
SecretKeySpec signingKey = new SecretKeySpec(keyBytes, "HmacSHA1"); //$NON-NLS-1$
mac = Mac.getInstance("HmacSHA1"); //$NON-NLS-1$
mac.init(signingKey);
- } catch (InvalidKeyException e) {
- throw new IllegalStateException(e);
- } catch (NoSuchAlgorithmException e) {
+ } catch (InvalidKeyException | NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalFetchConnection.java
index 9fb9062fbb..dc3dcbc545 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalFetchConnection.java
@@ -107,16 +107,12 @@ class InternalFetchConnection<C> extends BasePackFetchConnection {
try {
final UploadPack rp = uploadPackFactory.create(req, remote);
rp.upload(out_r, in_w, null);
- } catch (ServiceNotEnabledException e) {
+ } catch (ServiceNotEnabledException
+ | ServiceNotAuthorizedException e) {
// Ignored. Client cannot use this repository.
- } catch (ServiceNotAuthorizedException e) {
- // Ignored. Client cannot use this repository.
- } catch (IOException err) {
+ } catch (IOException | RuntimeException err) {
// Client side of the pipes should report the problem.
err.printStackTrace();
- } catch (RuntimeException err) {
- // Client side will notice we went away, and report.
- err.printStackTrace();
} finally {
try {
out_r.close();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalPushConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalPushConnection.java
index f05e0b8c7d..9663de09f4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalPushConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalPushConnection.java
@@ -100,16 +100,14 @@ class InternalPushConnection<C> extends BasePackPushConnection {
try {
final ReceivePack rp = receivePackFactory.create(req, remote);
rp.receive(out_r, in_w, System.err);
- } catch (ServiceNotEnabledException e) {
- // Ignored. Client cannot use this repository.
- } catch (ServiceNotAuthorizedException e) {
+ } catch (ServiceNotEnabledException
+ | ServiceNotAuthorizedException e) {
// Ignored. Client cannot use this repository.
} catch (IOException e) {
- // Since the InternalPushConnection
- // is used in tests, we want to avoid hiding exceptions
- // because they can point to programming errors on the server
- // side. By rethrowing, the default handler will dump it
- // to stderr.
+ // Since the InternalPushConnection is used in tests, we
+ // want to avoid hiding exceptions because they can point to
+ // programming errors on the server side. By rethrowing, the
+ // default handler will dump it to stderr.
throw new UncheckedIOException(e);
} finally {
try {
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 b6307ad6bb..0b7907035e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
@@ -180,10 +180,7 @@ public abstract class Transport implements AutoCloseable {
TransportProtocol proto;
try {
proto = (TransportProtocol) f.get(null);
- } catch (IllegalArgumentException e) {
- // If we cannot access the field, don't.
- continue;
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
// If we cannot access the field, don't.
continue;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
index 9dacaec881..b752a65275 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
@@ -363,9 +363,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
try (InputStream in = openInputStream(c)) {
return getConnection(c, in, service);
}
- } catch (NotSupportedException err) {
- throw err;
- } catch (TransportException err) {
+ } catch (NotSupportedException | TransportException err) {
throw err;
} catch (IOException err) {
throw new TransportException(uri, JGitText.get().errorReadingInfoRefs, err);
@@ -449,9 +447,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
throw new NotSupportedException(msg);
}
}
- } catch (NotSupportedException err) {
- throw err;
- } catch (TransportException err) {
+ } catch (NotSupportedException | TransportException err) {
throw err;
} catch (IOException err) {
throw new TransportException(uri, JGitText.get().errorReadingInfoRefs, err);
@@ -575,9 +571,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
String err = status + " " + conn.getResponseMessage(); //$NON-NLS-1$
throw new TransportException(uri, err);
}
- } catch (NotSupportedException e) {
- throw e;
- } catch (TransportException e) {
+ } catch (NotSupportedException | TransportException e) {
throw e;
} catch (SSLHandshakeException e) {
handleSslFailure(e);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index 8ebaec132f..fb50a533f4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -2002,21 +2002,12 @@ public class UploadPack {
} catch (ServiceMayNotContinueException noPack) {
// This was already reported on (below).
throw noPack;
- } catch (IOException err) {
- if (reportInternalServerErrorOverSideband())
+ } catch (IOException | RuntimeException | Error err) {
+ if (reportInternalServerErrorOverSideband()) {
throw new UploadPackInternalServerErrorException(err);
- else
- throw err;
- } catch (RuntimeException err) {
- if (reportInternalServerErrorOverSideband())
- throw new UploadPackInternalServerErrorException(err);
- else
- throw err;
- } catch (Error err) {
- if (reportInternalServerErrorOverSideband())
- throw new UploadPackInternalServerErrorException(err);
- else
+ } else {
throw err;
+ }
}
} else {
sendPack(false, req, accumulator, allTags, unshallowCommits, deepenNots);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
index 60acd2f8ae..b4a7af094d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
@@ -127,11 +127,7 @@ public class FileResolver<C> implements RepositoryResolver<C> {
} else
throw new ServiceNotEnabledException();
- } catch (RuntimeException e) {
- db.close();
- throw new RepositoryNotFoundException(name, e);
-
- } catch (IOException e) {
+ } catch (RuntimeException | IOException e) {
db.close();
throw new RepositoryNotFoundException(name, e);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/GSSManagerFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/GSSManagerFactory.java
index da57999e29..5927b33355 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/GSSManagerFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/GSSManagerFactory.java
@@ -145,13 +145,8 @@ public abstract class GSSManagerFactory {
return (GSSManager) GSS_MANAGER_IMPL_CONSTRUCTOR
.newInstance(httpCaller);
- } catch (InstantiationException e) {
- throw new Error(e);
- } catch (IllegalAccessException e) {
- throw new Error(e);
- } catch (IllegalArgumentException e) {
- throw new Error(e);
- } catch (InvocationTargetException e) {
+ } catch (InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
throw new Error(e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
index 9190a5915a..54e4ee01fd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
@@ -303,9 +303,7 @@ public class HttpSupport {
try {
conn.configure(null, trustAllCerts, null);
conn.setHostnameVerifier(new DummyHostnameVerifier());
- } catch (KeyManagementException e) {
- throw new IOException(e.getMessage());
- } catch (NoSuchAlgorithmException e) {
+ } catch (KeyManagementException | NoSuchAlgorithmException e) {
throw new IOException(e.getMessage());
}
}