From 5e7eed41f6273466c7dc60cee764fabc79bcd5ad Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 18 Dec 2017 14:34:13 +0900 Subject: [PATCH] StoredObjectRepresentationNotAvailableException: Add constructor that takes cause If the cause can be passed into the constructor, callers don't need to instantiate it and then explicitly call initCause. Note that the constructors in this class cause "non-API parameter type" warnings because ObjectToPack is internal, however it's probably OK since the only non-internal reference to it is in the pgm.debug package. Change-Id: Ia4eab24e79f9afe6214ea8160137d941d4048319 Signed-off-by: David Pursehouse --- ...ObjectRepresentationNotAvailableException.java | 15 +++++++++++++++ .../jgit/internal/storage/dfs/DfsPackFile.java | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java index bb11c9623a..cb2ee878cc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java @@ -61,4 +61,19 @@ public class StoredObjectRepresentationNotAvailableException extends Exception { public StoredObjectRepresentationNotAvailableException(ObjectToPack otp) { // Do nothing. } + + /** + * Construct an error for an object. + * + * @param otp + * the object whose current representation is no longer present. + * @param cause + * cause + * @since 4.10 + */ + public StoredObjectRepresentationNotAvailableException(ObjectToPack otp, + Throwable cause) { + super(cause); + // Do nothing. + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java index dfb41e204f..64b51b11bd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java @@ -533,10 +533,8 @@ public final class DfsPackFile extends BlockBasedFile { try { readFully(src.offset, buf, 0, 20, ctx); } catch (IOException ioError) { - StoredObjectRepresentationNotAvailableException gone; - gone = new StoredObjectRepresentationNotAvailableException(src); - gone.initCause(ioError); - throw gone; + throw new StoredObjectRepresentationNotAvailableException(src, + ioError); } int c = buf[0] & 0xff; final int typeCode = (c >> 4) & 7; -- 2.39.5