From fc2d723dd993b4d5e34db2b984189b4b6367c26a Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sat, 4 Apr 2015 00:45:33 +0200 Subject: [PATCH 1/2] Externalize error messages used in ObjectDirectoryInserter Change-Id: I3bc26847071fbc31267a4a4cf5a10b428bcf229d Signed-off-by: Matthias Sohn --- .../org/eclipse/jgit/internal/JGitText.properties | 2 ++ .../src/org/eclipse/jgit/internal/JGitText.java | 2 ++ .../internal/storage/file/ObjectDirectoryInserter.java | 9 ++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties index a003b02cc..33156553b 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -258,6 +258,7 @@ indexWriteException=Modified index could not be written initFailedBareRepoDifferentDirs=When initializing a bare repo with directory {0} and separate git-dir {1} specified both folders must point to the same location initFailedNonBareRepoSameDirs=When initializing a non-bare repo with directory {0} and separate git-dir {1} specified both folders should not point to the same location inMemoryBufferLimitExceeded=In-memory buffer limit exceeded +inputDidntMatchLength=Input did not match supplied length. {0} bytes are missing. inputStreamMustSupportMark=InputStream must support mark() integerValueOutOfRange=Integer value {0}.{1} out of range internalRevisionError=internal revision error @@ -536,6 +537,7 @@ truncatedHunkNewLinesMissing=Truncated hunk, at least {0} new lines is missing truncatedHunkOldLinesMissing=Truncated hunk, at least {0} old lines is missing tSizeMustBeGreaterOrEqual1=tSize must be >= 1 unableToCheckConnectivity=Unable to check connectivity. +unableToCreateNewObject=Unable to create new object: {0} unableToStore=Unable to store {0}. unableToWrite=Unable to write {0} unencodeableFile=Unencodable file: {0} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index 63b788f6b..587af5725 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -317,6 +317,7 @@ public class JGitText extends TranslationBundle { /***/ public String initFailedBareRepoDifferentDirs; /***/ public String initFailedNonBareRepoSameDirs; /***/ public String inMemoryBufferLimitExceeded; + /***/ public String inputDidntMatchLength; /***/ public String inputStreamMustSupportMark; /***/ public String integerValueOutOfRange; /***/ public String internalRevisionError; @@ -595,6 +596,7 @@ public class JGitText extends TranslationBundle { /***/ public String truncatedHunkOldLinesMissing; /***/ public String tSizeMustBeGreaterOrEqual1; /***/ public String unableToCheckConnectivity; + /***/ public String unableToCreateNewObject; /***/ public String unableToStore; /***/ public String unableToWrite; /***/ public String unencodeableFile; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java index 812c899a8..eb87460d8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java @@ -55,10 +55,12 @@ import java.io.OutputStream; import java.nio.channels.Channels; import java.security.DigestOutputStream; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; import org.eclipse.jgit.errors.ObjectWritingException; +import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -123,7 +125,8 @@ class ObjectDirectoryInserter extends ObjectInserter { } final File dst = db.fileFor(id); - throw new ObjectWritingException("Unable to create new object: " + dst); + throw new ObjectWritingException(MessageFormat + .format(JGitText.get().unableToCreateNewObject, dst)); } @Override @@ -242,7 +245,7 @@ class ObjectDirectoryInserter extends ObjectInserter { } private static EOFException shortInput(long missing) { - return new EOFException("Input did not match supplied length. " - + missing + " bytes are missing."); + return new EOFException(MessageFormat.format( + JGitText.get().inputDidntMatchLength, Long.valueOf(missing))); } } From 4dd4d7e12abec2740c14d681d91c1b799f55f686 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sat, 4 Apr 2015 00:49:05 +0200 Subject: [PATCH 2/2] Silence false null pointer access warnings in PackFile Change-Id: Ia39085557b38840dfaa9b4995e6f6c40e19042cb Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/internal/storage/file/PackFile.java | 2 ++ 1 file changed, 2 insertions(+) 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 eb2293874..ad3322e0d 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 @@ -362,6 +362,7 @@ public class PackFile implements Iterable { } } + @SuppressWarnings("null") private void copyAsIs2(PackOutputStream out, LocalObjectToPack src, boolean validate, WindowCursor curs) throws IOException, StoredObjectRepresentationNotAvailableException { @@ -703,6 +704,7 @@ public class PackFile implements Iterable { , getPackFile())); } + @SuppressWarnings("null") ObjectLoader load(final WindowCursor curs, long pos) throws IOException, LargeObjectException { try {