]> source.dussan.org Git - jgit.git/commitdiff
Join catch sections using multicatch 53/140153/18
authorCarsten Hammer <carsten.hammer@t-online.de>
Sat, 6 Apr 2019 16:16:21 +0000 (18:16 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Sat, 13 Apr 2019 16:53:58 +0000 (18:53 +0200)
Change-Id: I1a9112e6a4f938638c599b489cb0858eca27ab91
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
36 files changed:
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleInitCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleStatusCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaWindow.java
org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
org.eclipse.jgit/src/org/eclipse/jgit/nls/TranslationBundle.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalFetchConnection.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/InternalPushConnection.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
org.eclipse.jgit/src/org/eclipse/jgit/util/GSSManagerFactory.java
org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java

index 8e999da6b3dcc1126a67fdf07943ccdada4ffde1..5bac342b0a2f5aa33e22748ccddc70b00fc04f18 100644 (file)
@@ -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;
                }
index 95fe18b83c76870922d5f457756c483d77aaf289..48d016c064e36ef2c0fe75458b6ad69b374b4119 100644 (file)
@@ -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);
                }
        }
index dbdccc10e2fa0c78fc0b12c5e7f422a84710f0ab..b98bf151a52f84b0db3fe5a0c1443dd7342d904e 100644 (file)
@@ -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;
                }
 
index 1773de5d78036dd575e5eb0d21dd03a0e3e2da98..85ace3a077b52ac9633c3be2c2ddd596d385ef30 100644 (file)
@@ -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;
index 0373aeff5824358874a84d23ea31627c8e28d92e..9952f5cfc185f69d2884d5dd0b190057511da64e 100644 (file)
@@ -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);
                }
        }
index 0e1b398a738c5cff6651c3783b5563dec4208708..6165c0aeed575a64cf9fbab577db28b28297414a 100644 (file)
@@ -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;
        }
 
index 300a01d246ff1309f398c3cdc72995632b20d66c..a2ea8c20b49fdae9de553129e4841590afb8de9d 100644 (file)
@@ -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$
                }
 
index a14f6514feb4bcdf754ead5c0d4cd0883a92ec9e..213d9875db2b3871c24a40a52eb7161844083585 100644 (file)
@@ -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) {
index b925e31f8508105808b29f5a984045dcd8da02cc..d4effa3a102fc286ef6085da36763ac603556306 100644 (file)
@@ -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) {
index 85922a27ba288547ff6a1aa9dac9f50258e7b9ff..19841f633a56ecdd0e5fe31d5976231eac9a78de 100644 (file)
@@ -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) {
index 7d0e686a289207c0ab904ff3e0e11b3c525e20fe..1e8d7d1e1e0f30c45bfcbcaab6cf9beb9538926c 100644 (file)
@@ -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;
                }
index c43bdbd298edf8f3819368f2698e393de8373910..9289e5a67ba1d93d01d8aadfa758ea1c49b9624b 100644 (file)
@@ -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();
index cf3d35fe8952c4f89201b1d25d9f946ff9f8cc46..9b8016ce2021f609eb9725b78cbd17687f274c51 100644 (file)
@@ -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(
index 0e3d000d3a42a76cbe7d0f3e0ef191f7c26be88b..9be4c916ba02127a0f26782b7201475d005234fc 100644 (file)
@@ -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);
                }
        }
index f92455a96a17ed88a5b06f8d180a405f6331b2c9..89082777252c89d6986c6ae0240a8521115a18bc 100644 (file)
@@ -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);
                }
 
index 2db12b8e2561afda38f8fb11f5836682bcd19436..6fd94052a423c5112623f79d67f6946fc81cf041 100644 (file)
@@ -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);
                }
        }
index 0606c5b8d42de3004093f8a73970164c817ba8cf..58e59598edb76281eb439693d456cf17c4c91462 100644 (file)
@@ -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);
                }
        }
index 7cf4b73af0f468cf6936226de97389865740b9db..52393695d967f2b15877e918ddab7cf070132349 100644 (file)
@@ -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);
                }
        }
index 14653fe17f3f2f734a16425febcda3738bca152a..667634f7f87eb1f2ba56de6c2af30c40a1e72e02 100644 (file)
@@ -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;
                }
index b80c58ca9c463ca18a2954e2ee24d60c15d8273a..f0ee22d57a6a73d0935290716e4d61ef9338601a 100644 (file)
@@ -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;
                                }
index e8fac514be2d02d587cea14075299592ca410de5..da7250d1412fbddb5620617a3d52be4a238f3c91 100644 (file)
@@ -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;
                }
index a047534fbf52f79b682be30d0a0a4aa24b16b28b..d152a392f08e9a60b56b65deb9c674ef0fed202c 100644 (file)
@@ -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);
                        }
                }
index fd425abf350165a46cb5b38cd6d84923a5819e07..84bf214607464dcbde2661f778b9137690ca07e1 100644 (file)
@@ -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);
                }
        }
index cdd7be266fed7dd5dd7fc0fe5ec3affd6d987fb7..c41fb416d56c2bc5b3f6843ac47eb4ffe370a657 100644 (file)
@@ -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);
                                }
                        }
index fcf78ac7b9a7cce22afae205101d196c0a628d3a..c1ec19e8fb33f4864f46b875e86170454c3830cf 100644 (file)
@@ -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);
                }
index a729445309340c08dc08f4dd74fa68e47ec6b44d..4dd9cc57744ac2c4c77958f5e2447ce5c918f4f7 100644 (file)
@@ -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);
                }
index 84a0972723a349fe742a623ad98cf31ad0c6e5bc..6cf75031cd993e3a562cbbb2cada4130fa1237dd 100644 (file)
@@ -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);
                }
index 6c26b7026add7183da3ccdf55813f767206f9785..53eaa6a7f9151e4c23e0f9a59190ff86ccd4b61d 100644 (file)
@@ -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);
                }
        }
index 9fb9062fbb8460be347bc5c36357f6bfcc139a8d..dc3dcbc545dc7b69dce00415f7126a476db989f6 100644 (file)
@@ -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();
index f05e0b8c7d8231a521871d5be9254101ee4e4cc9..9663de09f48904fe7c6e8e2bcb8d9e7bd3a2886a 100644 (file)
@@ -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 {
index b6307ad6bbfb81bd31fc7b2c5b93064b3ad053c0..0b7907035e30c5ae61baddd0a5675e96e84a848c 100644 (file)
@@ -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;
                                }
index 9dacaec881289c01353c8df510c90730bd7e06c0..b752a652750ac80407bd69b701b8f57a602b8c9b 100644 (file)
@@ -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);
index 8ebaec132f80d1cad508349f74590567ada3044e..fb50a533f48fdb28d8e3d7880763067656fc1383 100644 (file)
@@ -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);
index 60acd2f8aed9a16609ca836be5c8fcc555ba005e..b4a7af094d38fe11ffb0761aa8fe3bcf00b6b39d 100644 (file)
@@ -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);
 
index da57999e29081a051ba521880385d273114fee0b..5927b33355fdd1d949d3550017192904b6e1a84f 100644 (file)
@@ -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);
                        }
                }
index 9190a5915a75922a4c83eebc7f7afda454f610c3..54e4ee01fd8844fd27aabf4ac85747ef14f1c780 100644 (file)
@@ -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());
                }
        }