aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2015-06-30 14:34:02 -0700
committerJonathan Nieder <jrn@google.com>2015-07-06 12:34:31 -0700
commit0c7ad12c767d34ab90505c405ad6f0b70ee670ec (patch)
tree40e662fd48da54ea44f68e2ee8791912e2bbef97 /org.eclipse.jgit/src/org
parent3c33d094a1be5e773c64fcdf5b47da54126fabf2 (diff)
downloadjgit-0c7ad12c767d34ab90505c405ad6f0b70ee670ec.tar.gz
jgit-0c7ad12c767d34ab90505c405ad6f0b70ee670ec.zip
Avoid double-colon in InvalidObjectIdException description
The invalidId message in JGitText and the asAscii bad id both contain a colon, so the resulting message would say Invalid id: : a78987c98798ufa Fix it by keeping the colon in the translated message and not adding another colon programmatically. Noticed by code inspection. Change-Id: I13972eebde27a4128828e6c64517666f0ba6288b Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java17
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java1
2 files changed, 10 insertions, 8 deletions
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 b545312ae7..ca1c26ae37 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 f903f23377..86f277ac39 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;