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>
stable-4.10
David Pursehouse 7 years ago
parent
commit
5e7eed41f6
  1. 15
      org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java
  2. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java

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

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

Loading…
Cancel
Save