summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2016-01-19 11:13:40 -0500
committerDave Borowitz <dborowitz@google.com>2016-01-19 17:59:19 -0500
commit2ccea7f05a0f3e783f6a8fa3f07cc5f1001bc950 (patch)
treef668b9fea889815cbe7deedbfdbaa30a413fa741
parenta693d7b33c9c7d7315974feff6cefe4ab84fb9a6 (diff)
downloadjgit-2ccea7f05a0f3e783f6a8fa3f07cc5f1001bc950.tar.gz
jgit-2ccea7f05a0f3e783f6a8fa3f07cc5f1001bc950.zip
ChangeIdUtil: Don't throw IOException
This could have only happened during the getBytes call. Instead, use Constants.encode, which is a non-throwing implementation. This change is binary compatible with existing code compiled against older versions of JGit, although it might break compilation of previously compiling code due to dead catch blocks. Change-Id: I191fec5cac718657407230de141440e86d0151fb
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java8
1 files changed, 2 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java
index 35fc99e54e..e14096e598 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java
@@ -42,7 +42,6 @@
*/
package org.eclipse.jgit.util;
-import java.io.IOException;
import java.util.regex.Pattern;
import org.eclipse.jgit.lib.Constants;
@@ -90,12 +89,10 @@ public class ChangeIdUtil {
* The commit message
* @return the change id SHA1 string (without the 'I') or null if the
* message is not complete enough
- * @throws IOException
*/
public static ObjectId computeChangeId(final ObjectId treeId,
final ObjectId firstParentId, final PersonIdent author,
- final PersonIdent committer, final String message)
- throws IOException {
+ final PersonIdent committer, final String message) {
String cleanMessage = clean(message);
if (cleanMessage.length() == 0)
return null;
@@ -116,8 +113,7 @@ public class ChangeIdUtil {
b.append("\n\n"); //$NON-NLS-1$
b.append(cleanMessage);
try (ObjectInserter f = new ObjectInserter.Formatter()) {
- return f.idFor(Constants.OBJ_COMMIT, //
- b.toString().getBytes(Constants.CHARACTER_ENCODING));
+ return f.idFor(Constants.OBJ_COMMIT, Constants.encode(b.toString()));
}
}