diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2020-01-27 09:47:05 +0900 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-01-27 14:40:08 +0100 |
commit | 4cc13297ccf1fa3e982bbb5638162b3bad63f93c (patch) | |
tree | 3f0b0c0aead716773d569e0b2eb1efb3b6f02081 /org.eclipse.jgit.lfs/src/org/eclipse/jgit | |
parent | 0e4a717870f64e667e657650f12e93d477d369c3 (diff) | |
download | jgit-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>
Diffstat (limited to 'org.eclipse.jgit.lfs/src/org/eclipse/jgit')
4 files changed, 15 insertions, 10 deletions
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; } } |