From 365c6cb3874ab8f284f49aba21df2a2900297872 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 19 Dec 2017 11:19:10 +0900 Subject: [PATCH] Use new StoredObjectRepresentationNotAvailableException constructor In 5e7eed4 a new StoredObjectRepresentationNotAvailableException constructor was added, that takes a Throwable to initialize the exception cause. Update more call sites to use this constructor instead of first instantiating it and explicitly calling initCause(). All callers now use the new constructor, so annotate the other one as deprecated. Change-Id: I6d2a7e289a95f0360ddebf904cfd8b6c18fef10c Signed-off-by: David Pursehouse --- ...ctRepresentationNotAvailableException.java | 4 ++++ .../internal/storage/dfs/DfsPackFile.java | 12 ++++-------- .../jgit/internal/storage/file/PackFile.java | 19 ++++++------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java index ab9ea1d7f4..8fa14c7d38 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java @@ -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. } 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 54b0cb554e..4886ed7149 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 @@ -660,16 +660,12 @@ public final class DfsPackFile extends BlockBasedFile { Long.valueOf(src.offset), getFileName())); corruptObject.initCause(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) { 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 febbb9602d..6fbb0df620 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 @@ -518,16 +518,12 @@ public class PackFile implements Iterable { Long.valueOf(src.offset), getPackFile())); corruptObject.initCause(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 @@ public class PackFile implements Iterable { try { doOpen(); } catch (IOException thisPackNotValid) { - StoredObjectRepresentationNotAvailableException gone; - - gone = new StoredObjectRepresentationNotAvailableException(otp); - gone.initCause(thisPackNotValid); - throw gone; + throw new StoredObjectRepresentationNotAvailableException(otp, + thisPackNotValid); } } } -- 2.39.5