Merge changes I50095928,Idadec0ab,I1f2747d6,I6d2a7e28

* changes:
  LargeObjectException: Add constructor that takes Throwable
  InvalidPatternException: Add constructor that takes Throwable
  Don't unnecessarily explicitly call CorruptObjectException#initCause
  Use new StoredObjectRepresentationNotAvailableException constructor
This commit is contained in:
David Pursehouse 2017-12-19 18:02:11 -05:00 committed by Gerrit Code Review @ Eclipse.org
commit 19864c6c02
9 changed files with 64 additions and 52 deletions

View File

@ -66,6 +66,23 @@ public InvalidPatternException(String message, String pattern) {
this.pattern = pattern;
}
/**
* Constructor for InvalidPatternException
*
* @param message
* explains what was wrong with the pattern.
* @param pattern
* the invalid pattern.
* @param cause
* the cause.
* @since 4.10
*/
public InvalidPatternException(String message, String pattern,
Throwable cause) {
this(message, pattern);
initCause(cause);
}
/**
* Get the invalid pattern
*

View File

@ -64,6 +64,17 @@ public LargeObjectException() {
// Do nothing.
}
/**
* Create a large object exception, where the object isn't known.
*
* @param cause
* the cause
* @since 4.10
*/
public LargeObjectException(Throwable cause) {
initCause(cause);
}
/**
* Create a large object exception, naming the object that is too big.
*

View File

@ -56,8 +56,12 @@ public class StoredObjectRepresentationNotAvailableException extends Exception {
*
* @param otp
* the object whose current representation is no longer present.
* @deprecated use
* {@link #StoredObjectRepresentationNotAvailableException(ObjectToPack, Throwable)}
* instead.
* @since 3.0
*/
@Deprecated
public StoredObjectRepresentationNotAvailableException(ObjectToPack otp) {
// Do nothing.
}

View File

@ -442,12 +442,10 @@ && isLetter(lookAhead(pattern, i)))
try {
return Pattern.compile(sb.toString());
} catch (PatternSyntaxException e) {
InvalidPatternException patternException = new InvalidPatternException(
throw new InvalidPatternException(
MessageFormat.format(JGitText.get().invalidIgnoreRule,
pattern),
pattern);
patternException.initCause(e);
throw patternException;
pattern, e);
}
}

View File

@ -616,13 +616,12 @@ private byte[] inflate(PackedObjectInfo obj, long zpos, int sz)
try {
return packOut.inflate(ctx, zpos, sz);
} catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException(
throw new CorruptObjectException(
MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(obj.getOffset()),
packDsc.getFileName(PackExt.PACK)));
coe.initCause(dfe);
throw coe;
packDsc.getFileName(PackExt.PACK)),
dfe);
}
}

View File

@ -657,19 +657,15 @@ void copyAsIs(PackOutputStream out, DfsObjectToPack src,
CorruptObjectException corruptObject = new CorruptObjectException(
MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(src.offset), getFileName()));
corruptObject.initCause(dataFormat);
Long.valueOf(src.offset), getFileName()),
dataFormat);
StoredObjectRepresentationNotAvailableException gone;
gone = new StoredObjectRepresentationNotAvailableException(src);
gone.initCause(corruptObject);
throw gone;
throw new StoredObjectRepresentationNotAvailableException(src,
corruptObject);
} catch (IOException ioError) {
StoredObjectRepresentationNotAvailableException gone;
gone = new StoredObjectRepresentationNotAvailableException(src);
gone.initCause(ioError);
throw gone;
throw new StoredObjectRepresentationNotAvailableException(src,
ioError);
}
if (quickCopy != null) {
@ -870,12 +866,11 @@ else if (delta.next == null)
return new ObjectLoader.SmallObject(type, data);
} catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException(
throw new CorruptObjectException(
MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
getFileName()));
coe.initCause(dfe);
throw coe;
getFileName()),
dfe);
}
}
@ -1018,12 +1013,11 @@ long getObjectSize(DfsReader ctx, long pos)
try {
return BinaryDelta.getResultSize(getDeltaHeader(ctx, deltaAt));
} catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException(
throw new CorruptObjectException(
MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
getFileName()));
coe.initCause(dfe);
throw coe;
getFileName()),
dfe);
}
}

View File

@ -101,9 +101,7 @@ public byte[] getCachedBytes() throws LargeObjectException {
try {
throw new LargeObjectException(getObjectId());
} catch (IOException cannotObtainId) {
LargeObjectException err = new LargeObjectException();
err.initCause(cannotObtainId);
throw err;
throw new LargeObjectException(cannotObtainId);
}
}

View File

@ -515,19 +515,15 @@ private void copyAsIs2(PackOutputStream out, LocalObjectToPack src,
CorruptObjectException corruptObject = new CorruptObjectException(
MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(src.offset), getPackFile()));
corruptObject.initCause(dataFormat);
Long.valueOf(src.offset), getPackFile()),
dataFormat);
StoredObjectRepresentationNotAvailableException gone;
gone = new StoredObjectRepresentationNotAvailableException(src);
gone.initCause(corruptObject);
throw gone;
throw new StoredObjectRepresentationNotAvailableException(src,
corruptObject);
} catch (IOException ioError) {
StoredObjectRepresentationNotAvailableException gone;
gone = new StoredObjectRepresentationNotAvailableException(src);
gone.initCause(ioError);
throw gone;
throw new StoredObjectRepresentationNotAvailableException(src,
ioError);
}
if (quickCopy != null) {
@ -612,11 +608,8 @@ private synchronized void beginCopyAsIs(ObjectToPack otp)
try {
doOpen();
} catch (IOException thisPackNotValid) {
StoredObjectRepresentationNotAvailableException gone;
gone = new StoredObjectRepresentationNotAvailableException(otp);
gone.initCause(thisPackNotValid);
throw gone;
throw new StoredObjectRepresentationNotAvailableException(otp,
thisPackNotValid);
}
}
}
@ -902,12 +895,11 @@ else if (delta.next == null)
return new ObjectLoader.SmallObject(type, data);
} catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException(
throw new CorruptObjectException(
MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(pos), getPackFile()));
coe.initCause(dfe);
throw coe;
Long.valueOf(pos), getPackFile()),
dfe);
}
}

View File

@ -582,13 +582,12 @@ private byte[] inflate(PackedObjectInfo obj, long zpos, int sz)
try {
return packOut.inflate(zpos, sz);
} catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException(
throw new CorruptObjectException(
MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(obj.getOffset()),
tmpPack.getAbsolutePath()));
coe.initCause(dfe);
throw coe;
tmpPack.getAbsolutePath()),
dfe);
}
}