Browse Source

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 <david.pursehouse@gmail.com>
tags/v4.10.0.201712302008-r
David Pursehouse 6 years ago
parent
commit
5e7eed41f6

+ 15
- 0
org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java View File

@@ -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.
}
}

+ 2
- 4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java View File

@@ -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;

Loading…
Cancel
Save