diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-19 11:37:08 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-19 23:27:53 +0900 |
commit | 0f1c160aa7302266136389c4e7b2ece30fc38675 (patch) | |
tree | dceef5f025a225d7c4be3b51293a04c45a5fbf53 | |
parent | 365c6cb3874ab8f284f49aba21df2a2900297872 (diff) | |
download | jgit-0f1c160aa7302266136389c4e7b2ece30fc38675.tar.gz jgit-0f1c160aa7302266136389c4e7b2ece30fc38675.zip |
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>
4 files changed, 19 insertions, 24 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java index 6d6c534734..eb0a527c5f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java @@ -616,13 +616,12 @@ public class DfsInserter extends ObjectInserter { 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); } } 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 4886ed7149..7e360421ac 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 @@ -657,8 +657,8 @@ public final class DfsPackFile extends BlockBasedFile { CorruptObjectException corruptObject = new CorruptObjectException( MessageFormat.format( JGitText.get().objectAtHasBadZlibStream, - Long.valueOf(src.offset), getFileName())); - corruptObject.initCause(dataFormat); + Long.valueOf(src.offset), getFileName()), + dataFormat); throw new StoredObjectRepresentationNotAvailableException(src, corruptObject); @@ -866,12 +866,11 @@ public final class DfsPackFile extends BlockBasedFile { 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); } } @@ -1014,12 +1013,11 @@ public final class DfsPackFile extends BlockBasedFile { 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); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java index 6fbb0df620..d5219c7a05 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java +++ b/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( MessageFormat.format( JGitText.get().objectAtHasBadZlibStream, - Long.valueOf(src.offset), getPackFile())); - corruptObject.initCause(dataFormat); + Long.valueOf(src.offset), getPackFile()), + dataFormat); throw new StoredObjectRepresentationNotAvailableException(src, corruptObject); @@ -895,12 +895,11 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { 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); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java index 4643158c7a..e60e297872 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java @@ -582,13 +582,12 @@ class PackInserter extends ObjectInserter { 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); } } |