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 509027daf..1689e770e 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -325,6 +325,7 @@ invalidEncryption=Invalid encryption invalidGitdirRef = Invalid .git reference in file ''{0}'' invalidGitType=invalid git type: {0} invalidId=Invalid id: {0} +invalidId0=Invalid id invalidIdLength=Invalid id length {0}; should be {1} invalidIgnoreParamSubmodule=Found invalid ignore param for submodule {0}. invalidIntegerValue=Invalid integer value: {0}.{1}={2} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java index b545312ae..ca1c26ae3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java @@ -45,7 +45,8 @@ package org.eclipse.jgit.errors; -import java.io.UnsupportedEncodingException; +import static java.nio.charset.StandardCharsets.US_ASCII; + import java.text.MessageFormat; import org.eclipse.jgit.internal.JGitText; @@ -64,16 +65,16 @@ public class InvalidObjectIdException extends IllegalArgumentException { * @param length of the sequence of invalid bytes. */ public InvalidObjectIdException(byte[] bytes, int offset, int length) { - super(MessageFormat.format(JGitText.get().invalidId, asAscii(bytes, offset, length))); + super(msg(bytes, offset, length)); } - private static String asAscii(byte[] bytes, int offset, int length) { + private static String msg(byte[] bytes, int offset, int length) { try { - return ": " + new String(bytes, offset, length, "US-ASCII"); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (UnsupportedEncodingException e2) { - return ""; //$NON-NLS-1$ - } catch (StringIndexOutOfBoundsException e2) { - return ""; //$NON-NLS-1$ + return MessageFormat.format( + JGitText.get().invalidId, + new String(bytes, offset, length, US_ASCII)); + } catch (StringIndexOutOfBoundsException e) { + return JGitText.get().invalidId0; } } } 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 f903f2337..86f277ac3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -384,6 +384,7 @@ public class JGitText extends TranslationBundle { /***/ public String invalidGitdirRef; /***/ public String invalidGitType; /***/ public String invalidId; + /***/ public String invalidId0; /***/ public String invalidIdLength; /***/ public String invalidIgnoreParamSubmodule; /***/ public String invalidIntegerValue;