summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2020-01-27 09:47:05 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2020-01-27 14:40:08 +0100
commit4cc13297ccf1fa3e982bbb5638162b3bad63f93c (patch)
tree3f0b0c0aead716773d569e0b2eb1efb3b6f02081
parent0e4a717870f64e667e657650f12e93d477d369c3 (diff)
downloadjgit-4cc13297ccf1fa3e982bbb5638162b3bad63f93c.tar.gz
jgit-4cc13297ccf1fa3e982bbb5638162b3bad63f93c.zip
ErrorProne: Enable and fix UnusedException check
Enable UnusedException at ERROR level which causes the build to fail in many places with: [UnusedException] This catch block catches an symbol and re-throws another, but swallows the caught symbol rather than setting it as a cause. This can make debugging harder. Fix it by setting the caught exception as cause on the subsequently thrown exception. Note: The grammatically incorrect error message is copy-pasted as-is from the version of ErrorProne currently used in Bazel; it has been fixed by [1] in the latest version. [1] https://github.com/google/error-prone/commit/d57a39c Change-Id: I11ed38243091fc12f64f1b2db404ba3f1d2e98b5 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java3
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java2
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java2
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectId.java7
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/LongObjectId.java8
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/MutableLongObjectId.java8
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java8
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfig.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TestProtocol.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java15
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java17
-rw-r--r--tools/BUILD1
52 files changed, 187 insertions, 94 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java
index 9b17132d0a..1769832fba 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java
@@ -298,7 +298,8 @@ public class GitFilter extends MetaFilter {
try {
return StringUtils.toBoolean(n);
} catch (IllegalArgumentException err) {
- throw new ServletException(MessageFormat.format(HttpServerText.get().invalidBoolean, param, n));
+ throw new ServletException(MessageFormat.format(
+ HttpServerText.get().invalidBoolean, param, n), err);
}
}
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index d68c5c891b..a5b3b1f3ac 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -973,7 +973,7 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
try {
lck.write(bin);
} catch (IOException ioe) {
- throw new ObjectWritingException("Can't write " + p);
+ throw new ObjectWritingException("Can't write " + p, ioe);
}
if (!lck.commit())
throw new ObjectWritingException("Can't write " + p);
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
index c4a51c7b93..55d2cfa6ec 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
@@ -18,7 +18,6 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
-import java.nio.charset.UnsupportedCharsetException;
import java.util.Locale;
import org.eclipse.jgit.annotations.Nullable;
@@ -110,7 +109,6 @@ public class LfsPointer implements Comparable<LfsPointer> {
ps.print(size + "\n"); //$NON-NLS-1$
} catch (UnsupportedEncodingException e) {
// should not happen, we are using a standard charset
- throw new UnsupportedCharsetException(UTF_8.name());
}
}
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectId.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectId.java
index a2bcc35eeb..9016e53940 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectId.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectId.java
@@ -121,8 +121,11 @@ public final class AbbreviatedLongObjectId implements Serializable {
final long c = hexUInt64(bs, ptr + 32, end);
final long d = hexUInt64(bs, ptr + 48, end);
return new AbbreviatedLongObjectId(end - ptr, a, b, c, d);
- } catch (ArrayIndexOutOfBoundsException e1) {
- throw new InvalidLongObjectIdException(bs, ptr, end - ptr);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ InvalidLongObjectIdException e1 = new InvalidLongObjectIdException(
+ bs, ptr, end - ptr);
+ e1.initCause(e);
+ throw e1;
}
}
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/LongObjectId.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/LongObjectId.java
index 000e9b206d..15b3ca4c62 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/LongObjectId.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/LongObjectId.java
@@ -223,9 +223,11 @@ public class LongObjectId extends AnyLongObjectId implements Serializable {
final long c = RawParseUtils.parseHexInt64(bs, p + 32);
final long d = RawParseUtils.parseHexInt64(bs, p + 48);
return new LongObjectId(a, b, c, d);
- } catch (ArrayIndexOutOfBoundsException e1) {
- throw new InvalidLongObjectIdException(bs, p,
- Constants.LONG_OBJECT_ID_STRING_LENGTH);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ InvalidLongObjectIdException e1 = new InvalidLongObjectIdException(
+ bs, p, Constants.LONG_OBJECT_ID_STRING_LENGTH);
+ e1.initCause(e);
+ throw e1;
}
}
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/MutableLongObjectId.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/MutableLongObjectId.java
index 368f6af7ed..012e4ae915 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/MutableLongObjectId.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/MutableLongObjectId.java
@@ -213,9 +213,11 @@ public class MutableLongObjectId extends AnyLongObjectId {
w2 = RawParseUtils.parseHexInt64(bs, p + 16);
w3 = RawParseUtils.parseHexInt64(bs, p + 32);
w4 = RawParseUtils.parseHexInt64(bs, p + 48);
- } catch (ArrayIndexOutOfBoundsException e1) {
- throw new InvalidLongObjectIdException(bs, p,
- Constants.LONG_OBJECT_ID_STRING_LENGTH);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ InvalidLongObjectIdException e1 = new InvalidLongObjectIdException(
+ bs, p, Constants.LONG_OBJECT_ID_STRING_LENGTH);
+ e1.initCause(e);
+ throw e1;
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
index 455abcd37c..98724bfceb 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
@@ -100,7 +100,7 @@ class Checkout extends TextBuiltin {
.format(CLIText.get().pathspecDidNotMatch, name), e);
} catch (RefAlreadyExistsException e) {
throw die(MessageFormat
- .format(CLIText.get().branchAlreadyExists, name));
+ .format(CLIText.get().branchAlreadyExists, name), e);
} catch (CheckoutConflictException e) {
StringBuilder builder = new StringBuilder();
builder.append(CLIText.get().checkoutConflict);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
index 243e99fdf2..8f80d6d70e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
@@ -110,7 +110,7 @@ class Clone extends AbstractFetchCommand implements CloneCommand.Callback {
outw.println(CLIText.get().clonedEmptyRepository);
} catch (InvalidRemoteException e) {
throw die(MessageFormat.format(CLIText.get().doesNotExist,
- sourceUri));
+ sourceUri), e);
} finally {
if (db != null)
db.close();
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
index cbb5d846ba..f570f7f99b 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
@@ -42,7 +42,7 @@ class ReceivePack extends TextBuiltin {
db = key.open(true /* must exist */);
} catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository,
- dstGitdir.getPath()));
+ dstGitdir.getPath()), notFound);
} catch (IOException e) {
throw die(e.getMessage(), e);
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
index 8c39886031..b408b78f3c 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
@@ -74,7 +74,7 @@ class Tag extends TextBuiltin {
command.call();
} catch (RefAlreadyExistsException e) {
throw die(MessageFormat.format(
- CLIText.get().tagAlreadyExists, tagName));
+ CLIText.get().tagAlreadyExists, tagName), e);
}
}
} else {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
index 69c8eb5701..36103f2e6f 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
@@ -50,7 +50,7 @@ class UploadPack extends TextBuiltin {
up.upload(ins, outs, errs);
} catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository,
- srcGitdir.getPath()));
+ srcGitdir.getPath()), notFound);
} catch (IOException e) {
throw die(e.getMessage(), e);
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
index ddd48da466..8d884c12db 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
@@ -235,7 +235,9 @@ class RebuildCommitGraph extends TextBuiltin {
try {
lck.write(content);
} catch (IOException ioe) {
- throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file));
+ throw new ObjectWritingException(
+ MessageFormat.format(CLIText.get().cantWrite, file),
+ ioe);
}
if (!lck.commit())
throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file));
@@ -266,7 +268,9 @@ class RebuildCommitGraph extends TextBuiltin {
errw.println(MessageFormat.format(CLIText.get().skippingObject, type, name));
continue;
}
- throw new MissingObjectException(id, type);
+ MissingObjectException mue1 = new MissingObjectException(id, type);
+ mue1.initCause(mue);
+ throw mue1;
}
refs.put(name, new ObjectIdRef.Unpeeled(Ref.Storage.PACKED,
name, id));
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java
index 6f0aba377e..49f7ada457 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java
@@ -57,7 +57,7 @@ class ShowPackDelta extends TextBuiltin {
if (BinaryDelta.getResultSize(delta) != size)
throw die("Object " + obj.name() + " is not a delta"); //$NON-NLS-1$ //$NON-NLS-2$
} catch (ArrayIndexOutOfBoundsException bad) {
- throw die("Object " + obj.name() + " is not a delta"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw die("Object " + obj.name() + " is not a delta", bad); //$NON-NLS-1$ //$NON-NLS-2$
}
outw.println(BinaryDelta.format(delta));
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 07a1bb801f..d8604726ab 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
@@ -101,8 +101,10 @@ public class AbstractTreeIteratorHandler extends
try (ObjectReader curs = clp.getRepository().newObjectReader()) {
p.reset(curs, clp.getRevWalk().parseTree(id));
} catch (MissingObjectException | IncorrectObjectTypeException e) {
- throw new CmdLineException(clp,
+ CmdLineException cle = new CmdLineException(clp,
CLIText.format(CLIText.get().notATree), name);
+ cle.initCause(e);
+ throw cle;
} catch (IOException e) {
throw new CmdLineException(clp,
CLIText.format(CLIText.get().cannotReadBecause), name,
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 f521775c7c..8b2bed36a7 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
@@ -98,8 +98,10 @@ public class RevCommitHandler extends OptionHandler<RevCommit> {
try {
c = clp.getRevWalk().parseCommit(id);
} catch (MissingObjectException | IncorrectObjectTypeException e) {
- throw new CmdLineException(clp,
+ CmdLineException cle = new CmdLineException(clp,
CLIText.format(CLIText.get().notACommit), name);
+ cle.initCause(e);
+ throw cle;
} catch (IOException e) {
throw new CmdLineException(clp,
CLIText.format(CLIText.get().cannotReadBecause), name,
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 fa96361681..357886d0fa 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
@@ -70,8 +70,10 @@ public class RevTreeHandler extends OptionHandler<RevTree> {
try {
c = clp.getRevWalk().parseTree(id);
} catch (MissingObjectException | IncorrectObjectTypeException e) {
- throw new CmdLineException(clp,
+ CmdLineException cle = new CmdLineException(clp,
CLIText.format(CLIText.get().notATree), name);
+ cle.initCause(e);
+ throw cle;
} catch (IOException e) {
throw new CmdLineException(clp,
CLIText.format(CLIText.get().cannotReadBecause), name,
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java
index 024f0f3b00..567880f478 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java
@@ -149,7 +149,9 @@ public class TimeoutOutputStreamTest {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
- throw new InterruptedIOException();
+ InterruptedIOException e1 = new InterruptedIOException();
+ e1.initCause(e);
+ throw e1;
}
}
}
@@ -202,7 +204,9 @@ public class TimeoutOutputStreamTest {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
- throw new InterruptedIOException();
+ InterruptedIOException e1 = new InterruptedIOException();
+ e1.initCause(e);
+ throw e1;
}
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
index 5232223c4c..eef7940012 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
@@ -160,7 +160,7 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
verifyDirectories(u);
} catch (URISyntaxException e) {
throw new InvalidRemoteException(
- MessageFormat.format(JGitText.get().invalidURL, uri));
+ MessageFormat.format(JGitText.get().invalidURL, uri), e);
}
@SuppressWarnings("resource") // Closed by caller
Repository repository = init();
@@ -180,8 +180,9 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
repository.close();
}
cleanup();
- throw new InvalidRemoteException(MessageFormat.format(
- JGitText.get().invalidRemote, remote));
+ throw new InvalidRemoteException(
+ MessageFormat.format(JGitText.get().invalidRemote, remote),
+ e);
} catch (GitAPIException | RuntimeException e) {
if (repository != null) {
repository.close();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
index a4b9bcf00e..033dd60c3b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
@@ -223,7 +223,7 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
e.getMessage(), e);
} catch (URISyntaxException e) {
throw new InvalidRemoteException(MessageFormat.format(
- JGitText.get().invalidRemote, remote));
+ JGitText.get().invalidRemote, remote), e);
} catch (NotSupportedException e) {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfFetchCommand,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
index 12517df516..a4ca309095 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
@@ -180,7 +180,7 @@ public class LsRemoteCommand extends
}
} catch (URISyntaxException e) {
throw new InvalidRemoteException(MessageFormat.format(
- JGitText.get().invalidRemote, remote));
+ JGitText.get().invalidRemote, remote), e);
} catch (NotSupportedException e) {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
index b9b15ebdc6..aa5a63499c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
@@ -152,8 +152,9 @@ public class PushCommand extends
}
} catch (URISyntaxException e) {
- throw new InvalidRemoteException(MessageFormat.format(
- JGitText.get().invalidRemote, remote));
+ throw new InvalidRemoteException(
+ MessageFormat.format(JGitText.get().invalidRemote, remote),
+ e);
} catch (TransportException e) {
throw new org.eclipse.jgit.api.errors.TransportException(
e.getMessage(), e);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
index fcfae65bc6..fb6e5df589 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
@@ -350,6 +350,7 @@ public class SimilarityIndex {
return (1 << idHashBits) * (idHashBits - 3) / idHashBits;
}
+ @SuppressWarnings("UnusedException")
private void grow() throws TableFullException {
if (idHashBits == 30)
throw new TableFullException();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
index 023efd8e17..6a2c3898a6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
@@ -139,7 +139,7 @@ public class ManifestParser extends DefaultHandler {
try {
xr = XMLReaderFactory.createXMLReader();
} catch (SAXException e) {
- throw new IOException(JGitText.get().noXMLParserAvailable);
+ throw new IOException(JGitText.get().noXMLParserAvailable, e);
}
xr.setContentHandler(this);
try {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
index 98f61d1597..c039aaffa9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
@@ -541,7 +541,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
inputStream = new FileInputStream(manifestPath);
} catch (IOException e) {
throw new IllegalArgumentException(
- JGitText.get().pathNotConfigured);
+ JGitText.get().pathNotConfigured, e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java
index ad7aebc27f..3b94984561 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java
@@ -290,9 +290,12 @@ public class FsckPackParser extends PackParser {
ErrorType.MISMATCH_CRC);
}
} catch (MissingObjectException e) {
- throw new CorruptPackIndexException(MessageFormat
- .format(JGitText.get().missingCRC, entry.getName()),
+ CorruptPackIndexException cpe = new CorruptPackIndexException(
+ MessageFormat.format(JGitText.get().missingCRC,
+ entry.getName()),
ErrorType.MISSING_CRC);
+ cpe.initCause(e);
+ throw cpe;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfig.java
index bee2e01a83..6e7ad3e613 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfig.java
@@ -236,7 +236,7 @@ public class DfsBlockCacheConfig {
JGitText.get().enumValueNotSupported3,
CONFIG_CORE_SECTION,
CONFIG_DFS_SECTION,
- CONFIG_KEY_STREAM_RATIO, v));
+ CONFIG_KEY_STREAM_RATIO, v), e);
}
}
return this;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
index 857c1730f4..169587081c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
@@ -769,7 +769,8 @@ public class ObjectDirectory extends FileObjectDatabase {
shallowCommitsIds.add(ObjectId.fromString(line));
} catch (IllegalArgumentException ex) {
throw new IOException(MessageFormat
- .format(JGitText.get().badShallowLine, line));
+ .format(JGitText.get().badShallowLine, line),
+ ex);
}
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
index 0de818a1db..984c163664 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
@@ -1071,7 +1071,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
} catch (DataFormatException e) {
throw new CorruptObjectException(MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
- getPackFile()));
+ getPackFile()), e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
index b636db6f2a..fddd430bf1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
@@ -1035,7 +1035,10 @@ public class RefDirectory extends RefDatabase {
lck.waitForStatChange();
} catch (InterruptedException e) {
lck.unlock();
- throw new ObjectWritingException(MessageFormat.format(JGitText.get().interruptedWriting, name));
+ throw new ObjectWritingException(
+ MessageFormat.format(
+ JGitText.get().interruptedWriting, name),
+ e);
}
if (!lck.commit())
throw new ObjectWritingException(MessageFormat.format(JGitText.get().unableToWrite, name));
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
index 743badbccb..bf47d2c3cd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
@@ -149,8 +149,10 @@ public class UnpackedObject {
}
return new LargeObject(type, size, path, id, wc.db);
} catch (ZipException badStream) {
- throw new CorruptObjectException(id,
+ CorruptObjectException coe = new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream);
+ coe.initCause(badStream);
+ throw coe;
}
}
@@ -192,8 +194,10 @@ public class UnpackedObject {
}
return size;
} catch (ZipException badStream) {
- throw new CorruptObjectException(id,
+ CorruptObjectException coe = new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream);
+ coe.initCause(badStream);
+ throw coe;
}
}
@@ -205,8 +209,10 @@ public class UnpackedObject {
try {
r = inf.inflate(buf);
} catch (DataFormatException e) {
- throw new CorruptObjectException(id,
+ CorruptObjectException coe = new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream);
+ coe.initCause(e);
+ throw coe;
}
if (r != 0)
throw new CorruptObjectException(id,
@@ -277,8 +283,10 @@ public class UnpackedObject {
remaining -= r;
return r;
} catch (ZipException badStream) {
- throw new CorruptObjectException(id,
+ CorruptObjectException coe = new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream);
+ coe.initCause(badStream);
+ throw coe;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index 33ffe07176..9a6ec760b6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -1579,8 +1579,8 @@ public class PackWriter implements AutoCloseable {
if (pool.awaitTermination(60, TimeUnit.SECONDS))
break;
} catch (InterruptedException e) {
- throw new IOException(
- JGitText.get().packingCancelledDuringObjectsWriting);
+ throw new IOException(JGitText
+ .get().packingCancelledDuringObjectsWriting, e);
}
}
}
@@ -1604,7 +1604,8 @@ public class PackWriter implements AutoCloseable {
// Cross our fingers and just break out anyway.
//
throw new IOException(
- JGitText.get().packingCancelledDuringObjectsWriting);
+ JGitText.get().packingCancelledDuringObjectsWriting,
+ ie);
}
}
@@ -1645,7 +1646,7 @@ public class PackWriter implements AutoCloseable {
for (Future<?> f : futures)
f.cancel(true);
throw new IOException(
- JGitText.get().packingCancelledDuringObjectsWriting);
+ JGitText.get().packingCancelledDuringObjectsWriting, ie);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java
index 20066bec78..d0e24413bb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java
@@ -165,9 +165,10 @@ public class SubmoduleValidator {
}
}
} catch (ConfigInvalidException e) {
- throw new SubmoduleValidationException(
- JGitText.get().invalidGitModules,
- GITMODULES_PARSE);
+ SubmoduleValidationException sve = new SubmoduleValidationException(
+ JGitText.get().invalidGitModules, GITMODULES_PARSE);
+ sve.initCause(e);
+ throw sve;
}
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java
index a5e4d787f4..dc5e5cc20f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java
@@ -114,8 +114,11 @@ public final class AbbreviatedObjectId implements Serializable {
final int d = hexUInt32(bs, ptr + 24, end);
final int e = hexUInt32(bs, ptr + 32, end);
return new AbbreviatedObjectId(end - ptr, a, b, c, d, e);
- } catch (ArrayIndexOutOfBoundsException e1) {
- throw new InvalidObjectIdException(bs, ptr, end - ptr);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ InvalidObjectIdException e1 = new InvalidObjectIdException(bs, ptr,
+ end - ptr);
+ e1.initCause(e);
+ throw e1;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
index d502274c43..ffc742d473 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
@@ -601,7 +601,10 @@ public final class Constants {
throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
}
} catch (ArrayIndexOutOfBoundsException bad) {
- throw new CorruptObjectException(id, JGitText.get().corruptObjectInvalidType);
+ CorruptObjectException coe = new CorruptObjectException(id,
+ JGitText.get().corruptObjectInvalidType);
+ coe.initCause(bad);
+ throw coe;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
index abc9b21196..cc0b995f10 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
@@ -46,7 +46,7 @@ public class DefaultTypedConfigGetter implements TypedConfigGetter {
return StringUtils.toBoolean(n);
} catch (IllegalArgumentException err) {
throw new IllegalArgumentException(MessageFormat.format(
- JGitText.get().invalidBooleanValue, section, name, n));
+ JGitText.get().invalidBooleanValue, section, name, n), err);
}
}
@@ -152,7 +152,8 @@ public class DefaultTypedConfigGetter implements TypedConfigGetter {
return mul * Long.parseLong(n);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException(MessageFormat.format(
- JGitText.get().invalidIntegerValue, section, name, str));
+ JGitText.get().invalidIntegerValue, section, name, str),
+ nfe);
}
}
@@ -239,7 +240,10 @@ public class DefaultTypedConfigGetter implements TypedConfigGetter {
return wantUnit.convert(Long.parseLong(digits) * inputMul,
inputUnit);
} catch (NumberFormatException nfe) {
- throw notTimeUnit(section, subsection, unitName, valueString);
+ IllegalArgumentException iae = notTimeUnit(section, subsection,
+ unitName, valueString);
+ iae.initCause(nfe);
+ throw iae;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java
index 86b306d5b5..4a712ba360 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java
@@ -234,9 +234,11 @@ public class MutableObjectId extends AnyObjectId {
w3 = RawParseUtils.parseHexInt32(bs, p + 16);
w4 = RawParseUtils.parseHexInt32(bs, p + 24);
w5 = RawParseUtils.parseHexInt32(bs, p + 32);
- } catch (ArrayIndexOutOfBoundsException e1) {
- throw new InvalidObjectIdException(bs, p,
+ } catch (ArrayIndexOutOfBoundsException e) {
+ InvalidObjectIdException e1 = new InvalidObjectIdException(bs, p,
Constants.OBJECT_ID_STRING_LENGTH);
+ e1.initCause(e);
+ throw e1;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java
index 11c0aefe39..269049f4a2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java
@@ -213,9 +213,11 @@ public class ObjectId extends AnyObjectId implements Serializable {
final int d = RawParseUtils.parseHexInt32(bs, p + 24);
final int e = RawParseUtils.parseHexInt32(bs, p + 32);
return new ObjectId(a, b, c, d, e);
- } catch (ArrayIndexOutOfBoundsException e1) {
- throw new InvalidObjectIdException(bs, p,
+ } catch (ArrayIndexOutOfBoundsException e) {
+ InvalidObjectIdException e1 = new InvalidObjectIdException(bs, p,
Constants.OBJECT_ID_STRING_LENGTH);
+ e1.initCause(e);
+ throw e1;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index 503e218b5a..a7a832c1aa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -550,9 +550,11 @@ public abstract class Repository implements AutoCloseable {
try {
pnum = Integer.parseInt(parentnum);
} catch (NumberFormatException e) {
- throw new RevisionSyntaxException(
+ RevisionSyntaxException rse = new RevisionSyntaxException(
JGitText.get().invalidCommitParentNumber,
revstr);
+ rse.initCause(e);
+ throw rse;
}
if (pnum != 0) {
RevCommit commit = (RevCommit) rev;
@@ -647,8 +649,10 @@ public abstract class Repository implements AutoCloseable {
try {
dist = Integer.parseInt(distnum);
} catch (NumberFormatException e) {
- throw new RevisionSyntaxException(
+ RevisionSyntaxException rse = new RevisionSyntaxException(
JGitText.get().invalidAncestryLength, revstr);
+ rse.initCause(e);
+ throw rse;
}
} else
dist = 1;
@@ -707,7 +711,10 @@ public abstract class Repository implements AutoCloseable {
remoteConfig = new RemoteConfig(getConfig(),
"origin"); //$NON-NLS-1$
} catch (URISyntaxException e) {
- throw new RevisionSyntaxException(revstr);
+ RevisionSyntaxException rse = new RevisionSyntaxException(
+ revstr);
+ rse.initCause(e);
+ throw rse;
}
String remoteBranchName = getConfig()
.getString(
@@ -874,8 +881,11 @@ public abstract class Repository implements AutoCloseable {
try {
number = Integer.parseInt(time);
} catch (NumberFormatException nfe) {
- throw new RevisionSyntaxException(MessageFormat.format(
- JGitText.get().invalidReflogRevision, time));
+ RevisionSyntaxException rse = new RevisionSyntaxException(
+ MessageFormat.format(JGitText.get().invalidReflogRevision,
+ time));
+ rse.initCause(nfe);
+ throw rse;
}
assert number >= 0;
ReflogReader reader = getReflogReader(ref.getName());
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
index a177c290ee..1e7f3b1f00 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
@@ -655,7 +655,8 @@ public class AmazonS3 {
try {
xr = XMLReaderFactory.createXMLReader();
} catch (SAXException e) {
- throw new IOException(JGitText.get().noXMLParserAvailable);
+ throw new IOException(
+ JGitText.get().noXMLParserAvailable, e);
}
xr.setContentHandler(this);
try (InputStream in = c.getInputStream()) {
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 8604244db4..1417faee80 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
@@ -203,7 +203,9 @@ abstract class BasePackConnection extends BaseConnection {
try {
id = ObjectId.fromString(line.substring(0, 40));
} catch (InvalidObjectIdException e) {
- throw invalidRefAdvertisementLine(line);
+ PackProtocolException ppe = invalidRefAdvertisementLine(line);
+ ppe.initCause(e);
+ throw ppe;
}
if (name.equals(".have")) { //$NON-NLS-1$
additionalHaves.add(id);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java
index 93800d5009..c992bb1cb5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java
@@ -286,7 +286,7 @@ public class PacketLineIn {
try {
len = RawParseUtils.parseHexInt16(lineBuffer, 0);
} catch (ArrayIndexOutOfBoundsException err) {
- throw invalidHeader();
+ throw invalidHeader(err);
}
if (len == 0) {
@@ -320,6 +320,12 @@ public class PacketLineIn {
+ (char) lineBuffer[2] + (char) lineBuffer[3]));
}
+ private IOException invalidHeader(Throwable cause) {
+ IOException ioe = invalidHeader();
+ ioe.initCause(cause);
+ return ioe;
+ }
+
/**
* IOException thrown by read when the configured input limit is exceeded.
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
index 24cd8f3df1..e505e1706f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -2110,7 +2110,7 @@ public class ReceivePack {
} catch (InputOverLimitIOException e) {
String msg = JGitText.get().tooManyCommands;
fatalError(msg);
- throw new PackProtocolException(msg);
+ throw new PackProtocolException(msg, e);
} finally {
try {
close();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TestProtocol.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TestProtocol.java
index 13b891fcfc..c6ecb3a79f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TestProtocol.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TestProtocol.java
@@ -140,7 +140,7 @@ public class TestProtocol<C> extends TransportProtocol {
int n = handles.size();
uri = new URIish(SCHEME + "://test/conn" + n); //$NON-NLS-1$
} catch (URISyntaxException e) {
- throw new IllegalStateException();
+ throw new IllegalStateException(e);
}
handles.put(uri, new Handle(req, remote));
return uri;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java
index 155c115f82..04ebddb107 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportBundleFile.java
@@ -113,7 +113,10 @@ class TransportBundleFile extends Transport implements TransportBundle {
try {
src = new FileInputStream(bundle);
} catch (FileNotFoundException err) {
- throw new TransportException(uri, JGitText.get().notFound);
+ TransportException te = new TransportException(uri,
+ JGitText.get().notFound);
+ te.initCause(err);
+ throw te;
}
return new BundleFetchConnection(this, src);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java
index be17b44d79..403f98d869 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java
@@ -143,7 +143,10 @@ class TransportLocal extends Transport implements PackTransport {
.setFS(local != null ? local.getFS() : FS.DETECTED)
.setGitDir(remoteGitDir).build();
} catch (IOException err) {
- throw new TransportException(uri, JGitText.get().notAGitDirectory);
+ TransportException te = new TransportException(uri,
+ JGitText.get().notAGitDirectory);
+ te.initCause(err);
+ throw te;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
index 6ebb668c7a..858d1f7b6a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
@@ -266,7 +266,10 @@ public class URIish implements Serializable {
try {
val = parseHexByte(c1, c2);
} catch (ArrayIndexOutOfBoundsException e) {
- throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
+ URISyntaxException use = new URISyntaxException(s,
+ JGitText.get().cannotParseGitURIish);
+ use.initCause(e);
+ throw use;
}
os[j++] = (byte) val;
i += 2;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java
index 1880c8b733..df9f11ecf8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java
@@ -282,9 +282,12 @@ abstract class WalkEncryption {
String REGEX_TRANS = "(.+)/(.+)/(.+)"; //$NON-NLS-1$
}
- static GeneralSecurityException securityError(String message) {
- return new GeneralSecurityException(
+ static GeneralSecurityException securityError(String message,
+ Throwable cause) {
+ GeneralSecurityException e = new GeneralSecurityException(
MessageFormat.format(JGitText.get().encryptionError, message));
+ e.initCause(cause);
+ return e;
}
/**
@@ -332,21 +335,21 @@ abstract class WalkEncryption {
try {
size = Integer.parseInt(keySize);
} catch (Exception e) {
- throw securityError(X_KEY_SIZE + EMPTY + keySize);
+ throw securityError(X_KEY_SIZE + EMPTY + keySize, e);
}
final int iter;
try {
iter = Integer.parseInt(keyIter);
} catch (Exception e) {
- throw securityError(X_KEY_ITER + EMPTY + keyIter);
+ throw securityError(X_KEY_ITER + EMPTY + keyIter, e);
}
final byte[] salt;
try {
salt = Hex.decode(keySalt.replaceAll(REGEX_WS, EMPTY));
} catch (Exception e) {
- throw securityError(X_KEY_SALT + EMPTY + keySalt);
+ throw securityError(X_KEY_SALT + EMPTY + keySalt, e);
}
KeySpec keySpec = new PBEKeySpec(pass.toCharArray(), salt, iter, size);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index 02ca86b954..2c3f3e2542 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -1159,7 +1159,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
} catch (CharacterCodingException e) {
// This should so never happen.
throw new RuntimeException(MessageFormat.format(
- JGitText.get().unencodeableFile, getName()));
+ JGitText.get().unencodeableFile, getName()), e);
}
encodedNameLen = b.limit();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
index fa99087fe4..4831fbb64e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
@@ -300,7 +300,8 @@ public class FileUtils {
} catch (InterruptedException e) {
throw new IOException(
MessageFormat.format(JGitText.get().renameFileFailed,
- src.getAbsolutePath(), dst.getAbsolutePath()));
+ src.getAbsolutePath(), dst.getAbsolutePath()),
+ e);
}
}
throw new IOException(
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java
index 1356136000..1947b3bf04 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java
@@ -70,7 +70,7 @@ public class TimeoutInputStream extends FilterInputStream {
beginRead();
return super.read();
} catch (InterruptedIOException e) {
- throw readTimedOut();
+ throw readTimedOut(e);
} finally {
endRead();
}
@@ -89,7 +89,7 @@ public class TimeoutInputStream extends FilterInputStream {
beginRead();
return super.read(buf, off, cnt);
} catch (InterruptedIOException e) {
- throw readTimedOut();
+ throw readTimedOut(e);
} finally {
endRead();
}
@@ -102,7 +102,7 @@ public class TimeoutInputStream extends FilterInputStream {
beginRead();
return super.skip(cnt);
} catch (InterruptedIOException e) {
- throw readTimedOut();
+ throw readTimedOut(e);
} finally {
endRead();
}
@@ -116,8 +116,11 @@ public class TimeoutInputStream extends FilterInputStream {
myTimer.end();
}
- private InterruptedIOException readTimedOut() {
- return new InterruptedIOException(MessageFormat.format(
- JGitText.get().readTimedOut, Integer.valueOf(timeout)));
+ private InterruptedIOException readTimedOut(InterruptedIOException e) {
+ InterruptedIOException interrupted = new InterruptedIOException(
+ MessageFormat.format(JGitText.get().readTimedOut,
+ Integer.valueOf(timeout)));
+ interrupted.initCause(e);
+ return interrupted;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java
index 7532c42b97..3fbf6ffdcb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java
@@ -72,7 +72,7 @@ public class TimeoutOutputStream extends OutputStream {
beginWrite();
dst.write(b);
} catch (InterruptedIOException e) {
- throw writeTimedOut();
+ throw writeTimedOut(e);
} finally {
endWrite();
}
@@ -91,7 +91,7 @@ public class TimeoutOutputStream extends OutputStream {
beginWrite();
dst.write(buf, off, len);
} catch (InterruptedIOException e) {
- throw writeTimedOut();
+ throw writeTimedOut(e);
} finally {
endWrite();
}
@@ -104,7 +104,7 @@ public class TimeoutOutputStream extends OutputStream {
beginWrite();
dst.flush();
} catch (InterruptedIOException e) {
- throw writeTimedOut();
+ throw writeTimedOut(e);
} finally {
endWrite();
}
@@ -117,7 +117,7 @@ public class TimeoutOutputStream extends OutputStream {
beginWrite();
dst.close();
} catch (InterruptedIOException e) {
- throw writeTimedOut();
+ throw writeTimedOut(e);
} finally {
endWrite();
}
@@ -131,8 +131,11 @@ public class TimeoutOutputStream extends OutputStream {
myTimer.end();
}
- private InterruptedIOException writeTimedOut() {
- return new InterruptedIOException(MessageFormat.format(
- JGitText.get().writeTimedOut, Integer.valueOf(timeout)));
+ private InterruptedIOException writeTimedOut(InterruptedIOException cause) {
+ InterruptedIOException e = new InterruptedIOException(
+ MessageFormat.format(JGitText.get().writeTimedOut,
+ Integer.valueOf(timeout)));
+ e.initCause(cause);
+ return e;
}
}
diff --git a/tools/BUILD b/tools/BUILD
index d66837700c..2b208744b5 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -78,6 +78,7 @@ java_package_configuration(
"-Xep:TypeParameterShadowing:ERROR",
"-Xep:TypeParameterUnusedInFormals:WARN",
"-Xep:URLEqualsHashCode:ERROR",
+ "-Xep:UnusedException:ERROR",
"-Xep:UnsynchronizedOverridesSynchronized:ERROR",
"-Xep:WaitNotInLoop:ERROR",
],