Browse Source

Don't unnecessarily explicitly call CorruptObjectException#initCause

CorruptObjectException has a constructor that takes Throwable and
calls initCause with it.  Use that instead of instantiating the
exception and explicitly calling initCause.

Change-Id: I1f2747d6c4cc5249e93401b9787eb4ceb50cb995
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.10
David Pursehouse 7 years ago
parent
commit
0f1c160aa7
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
  2. 18
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
  3. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
  4. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java

@ -616,13 +616,12 @@ public class DfsInserter extends ObjectInserter {
try { try {
return packOut.inflate(ctx, zpos, sz); return packOut.inflate(ctx, zpos, sz);
} catch (DataFormatException dfe) { } catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException( throw new CorruptObjectException(
MessageFormat.format( MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(obj.getOffset()), Long.valueOf(obj.getOffset()),
packDsc.getFileName(PackExt.PACK))); packDsc.getFileName(PackExt.PACK)),
coe.initCause(dfe); dfe);
throw coe;
} }
} }

18
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java

@ -657,8 +657,8 @@ public final class DfsPackFile extends BlockBasedFile {
CorruptObjectException corruptObject = new CorruptObjectException( CorruptObjectException corruptObject = new CorruptObjectException(
MessageFormat.format( MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(src.offset), getFileName())); Long.valueOf(src.offset), getFileName()),
corruptObject.initCause(dataFormat); dataFormat);
throw new StoredObjectRepresentationNotAvailableException(src, throw new StoredObjectRepresentationNotAvailableException(src,
corruptObject); corruptObject);
@ -866,12 +866,11 @@ public final class DfsPackFile extends BlockBasedFile {
return new ObjectLoader.SmallObject(type, data); return new ObjectLoader.SmallObject(type, data);
} catch (DataFormatException dfe) { } catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException( throw new CorruptObjectException(
MessageFormat.format( MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos), JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
getFileName())); getFileName()),
coe.initCause(dfe); dfe);
throw coe;
} }
} }
@ -1014,12 +1013,11 @@ public final class DfsPackFile extends BlockBasedFile {
try { try {
return BinaryDelta.getResultSize(getDeltaHeader(ctx, deltaAt)); return BinaryDelta.getResultSize(getDeltaHeader(ctx, deltaAt));
} catch (DataFormatException dfe) { } catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException( throw new CorruptObjectException(
MessageFormat.format( MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos), JGitText.get().objectAtHasBadZlibStream, Long.valueOf(pos),
getFileName())); getFileName()),
coe.initCause(dfe); dfe);
throw coe;
} }
} }

11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

@ -515,8 +515,8 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
CorruptObjectException corruptObject = new CorruptObjectException( CorruptObjectException corruptObject = new CorruptObjectException(
MessageFormat.format( MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(src.offset), getPackFile())); Long.valueOf(src.offset), getPackFile()),
corruptObject.initCause(dataFormat); dataFormat);
throw new StoredObjectRepresentationNotAvailableException(src, throw new StoredObjectRepresentationNotAvailableException(src,
corruptObject); corruptObject);
@ -895,12 +895,11 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
return new ObjectLoader.SmallObject(type, data); return new ObjectLoader.SmallObject(type, data);
} catch (DataFormatException dfe) { } catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException( throw new CorruptObjectException(
MessageFormat.format( MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(pos), getPackFile())); Long.valueOf(pos), getPackFile()),
coe.initCause(dfe); dfe);
throw coe;
} }
} }

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java

@ -582,13 +582,12 @@ class PackInserter extends ObjectInserter {
try { try {
return packOut.inflate(zpos, sz); return packOut.inflate(zpos, sz);
} catch (DataFormatException dfe) { } catch (DataFormatException dfe) {
CorruptObjectException coe = new CorruptObjectException( throw new CorruptObjectException(
MessageFormat.format( MessageFormat.format(
JGitText.get().objectAtHasBadZlibStream, JGitText.get().objectAtHasBadZlibStream,
Long.valueOf(obj.getOffset()), Long.valueOf(obj.getOffset()),
tmpPack.getAbsolutePath())); tmpPack.getAbsolutePath()),
coe.initCause(dfe); dfe);
throw coe;
} }
} }

Loading…
Cancel
Save