]> source.dussan.org Git - jgit.git/commitdiff
Don't unnecessarily explicitly call CorruptObjectException#initCause 57/114357/2
authorDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 19 Dec 2017 02:37:08 +0000 (11:37 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 19 Dec 2017 14:27:53 +0000 (23:27 +0900)
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>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackInserter.java

index 6d6c534734a71e45df974b24c2d24d0a7e99d84a..eb0a527c5f0d4397a178db76950571c735af9f86 100644 (file)
@@ -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);
                        }
                }
 
index 4886ed71492ea0cdedd6c8d5c3f47580638f6324..7e360421ac64329bf427948bd2b3f54613177f46 100644 (file)
@@ -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);
                }
        }
 
index 6fbb0df620d644bc3c3e52b68184947b3d9335a0..d5219c7a057fb0b158427b1acc6f8edd93fc12cc 100644 (file)
@@ -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);
                }
        }
 
index 4643158c7a70a1058b4f219328461e9cd69a002e..e60e29787295e8f3d81d300210369049d9dd90d9 100644 (file)
@@ -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);
                        }
                }