Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2018-09-29 05:39:56 +0000
committerMatthias Sohn2019-06-19 08:43:01 +0000
commitf18b5010fcf750e6949e53dca292db9f2b4dc57d (patch)
treed3c7db6a7e4f5d6bbb48fae9e483545f52a7d761
parent9387288a8612eb9e9478c5ecfe4b1351a0ed4717 (diff)
downloadjgit-f18b5010fcf750e6949e53dca292db9f2b4dc57d.tar.gz
jgit-f18b5010fcf750e6949e53dca292db9f2b4dc57d.tar.xz
jgit-f18b5010fcf750e6949e53dca292db9f2b4dc57d.zip
Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8
Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java7
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java5
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java2
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java4
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java9
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java6
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java17
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java4
20 files changed, 61 insertions, 53 deletions
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
index 9ed60d941a..aee80d8307 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
@@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.archive;
-import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
+import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.IOException;
import java.io.OutputStream;
@@ -85,7 +85,7 @@ public final class TarFormat extends BaseFormat implements
public ArchiveOutputStream createArchiveOutputStream(OutputStream s,
Map<String, Object> o) throws IOException {
TarArchiveOutputStream out = new TarArchiveOutputStream(s,
- CHARACTER_ENCODING);
+ UTF_8.name());
out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
return applyFormatOptions(out, o);
@@ -99,8 +99,7 @@ public final class TarFormat extends BaseFormat implements
if (mode == FileMode.SYMLINK) {
final TarArchiveEntry entry = new TarArchiveEntry(
path, TarConstants.LF_SYMLINK);
- entry.setLinkName(new String(
- loader.getCachedBytes(100), CHARACTER_ENCODING));
+ entry.setLinkName(new String(loader.getCachedBytes(100), UTF_8));
out.putArchiveEntry(entry);
out.closeArchiveEntry();
return;
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java
index 1a9d192450..b084b0db54 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java
@@ -69,7 +69,7 @@ class InfoRefsServlet extends HttpServlet {
// Assume a dumb client and send back the dumb client
// version of the info/refs file.
rsp.setContentType(HttpSupport.TEXT_PLAIN);
- rsp.setCharacterEncoding(Constants.CHARACTER_ENCODING);
+ rsp.setCharacterEncoding(UTF_8.name());
final Repository db = getRepository(req);
try (OutputStreamWriter out = new OutputStreamWriter(
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
index 9601c8cafa..b6d73b5591 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.http.server;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP;
import static org.eclipse.jgit.util.HttpSupport.ENCODING_X_GZIP;
import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT_ENCODING;
@@ -191,9 +192,9 @@ public final class ServletUtils {
public static void sendPlainText(final String content,
final HttpServletRequest req, final HttpServletResponse rsp)
throws IOException {
- final byte[] raw = content.getBytes(Constants.CHARACTER_ENCODING);
+ final byte[] raw = content.getBytes(UTF_8);
rsp.setContentType(TEXT_PLAIN);
- rsp.setCharacterEncoding(Constants.CHARACTER_ENCODING);
+ rsp.setCharacterEncoding(UTF_8.name());
send(raw, req, rsp);
}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
index 2b4a2511ed..b26324d4f2 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
@@ -298,7 +298,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
throws IOException, ServletException {
final HttpServletResponse r = (HttpServletResponse) response;
r.setContentType("text/plain");
- r.setCharacterEncoding(Constants.CHARACTER_ENCODING);
+ r.setCharacterEncoding(UTF_8.name());
try (PrintWriter w = r.getWriter()) {
w.print("OK");
}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java
index a1283ddf41..146a25ed3d 100644
--- a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.lfs.lib;
-import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
@@ -66,7 +66,7 @@ public class LFSPointerTest {
assertEquals(
"version https://git-lfs.github.com/spec/v1\noid sha256:"
+ s + "\nsize 4\n",
- baos.toString(CHARACTER_ENCODING));
+ baos.toString(UTF_8.name()));
}
}
}
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java
index 40a223d92f..42530f3a34 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java
@@ -37,6 +37,7 @@
*/
package org.eclipse.jgit.pgm;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
@@ -47,7 +48,6 @@ import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
-import org.eclipse.jgit.lib.Constants;
import org.junit.Before;
import org.junit.Test;
@@ -204,7 +204,7 @@ public class ProxyConfigTest {
while ((length = inputStream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
- return result.toString(Constants.CHARACTER_ENCODING);
+ return result.toString(UTF_8.name());
}
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java
index 347883f842..abf7d56819 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.lib;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -72,7 +73,9 @@ public class MergeHeadMsgTest extends RepositoryTestCase {
// same test again, this time with lower-level io
try (FileOutputStream fos = new FileOutputStream(
new File(db.getDirectory(), "MERGE_HEAD"));) {
- fos.write("0000000000000000000000000000000000000000\n1c6db447abdbb291b25f07be38ea0b1bf94947c5\n".getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(
+ "0000000000000000000000000000000000000000\n1c6db447abdbb291b25f07be38ea0b1bf94947c5\n"
+ .getBytes(UTF_8));
}
assertEquals(db.readMergeHeads().size(), 2);
assertEquals(db.readMergeHeads().get(0), ObjectId.zeroId());
@@ -82,7 +85,7 @@ public class MergeHeadMsgTest extends RepositoryTestCase {
assertEquals(db.readMergeHeads(), null);
try (FileOutputStream fos = new FileOutputStream(
new File(db.getDirectory(), "MERGE_HEAD"))) {
- fos.write(sampleId.getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(sampleId.getBytes(UTF_8));
}
assertEquals(db.readMergeHeads().size(), 1);
assertEquals(db.readMergeHeads().get(0), ObjectId.fromString(sampleId));
@@ -100,7 +103,7 @@ public class MergeHeadMsgTest extends RepositoryTestCase {
assertFalse(new File(db.getDirectory(), "MERGE_MSG").exists());
try (FileOutputStream fos = new FileOutputStream(
new File(db.getDirectory(), Constants.MERGE_MSG))) {
- fos.write(mergeMsg.getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(mergeMsg.getBytes(UTF_8));
}
assertEquals(db.readMergeCommitMsg(), mergeMsg);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
index 3542dfad2d..bb24994ee8 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.lib;
import static java.lang.Long.valueOf;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
@@ -181,7 +182,7 @@ public class RacyGitTests extends RepositoryTestCase {
private File addToWorkDir(String path, String content) throws IOException {
File f = new File(db.getWorkTree(), path);
try (FileOutputStream fos = new FileOutputStream(f)) {
- fos.write(content.getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(content.getBytes(UTF_8));
return f;
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java
index 203c00e28a..f58ab06074 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.lib;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -68,7 +69,7 @@ public class SquashCommitMsgTest extends RepositoryTestCase {
assertFalse(new File(db.getDirectory(), Constants.SQUASH_MSG).exists());
try (FileOutputStream fos = new FileOutputStream(
new File(db.getDirectory(), Constants.SQUASH_MSG))) {
- fos.write(squashMsg.getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(squashMsg.getBytes(UTF_8));
}
assertEquals(db.readSquashCommitMsg(), squashMsg);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java
index 5af62b6704..b131808318 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.merge;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
@@ -302,7 +303,7 @@ public class MergeAlgorithmTest {
T(commonBase), T(ours), T(theirs));
ByteArrayOutputStream bo=new ByteArrayOutputStream(50);
fmt.formatMerge(bo, r, "B", "O", "T", Constants.CHARACTER_ENCODING);
- return new String(bo.toByteArray(), Constants.CHARACTER_ENCODING);
+ return new String(bo.toByteArray(), UTF_8);
}
public String t(String text) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java
index 391a701b8e..ad8ae42536 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.transport;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -50,7 +51,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import org.eclipse.jgit.lib.Constants;
import org.junit.Before;
import org.junit.Test;
@@ -173,8 +173,8 @@ public class PacketLineOutTest {
assertEquals(1, flushCnt[0]);
}
- private void assertBuffer(String exp) throws IOException {
+ private void assertBuffer(String exp) {
assertEquals(exp, new String(rawOut.toByteArray(),
- Constants.CHARACTER_ENCODING));
+ UTF_8));
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java
index 4d3e162240..b6cf3564c1 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.transport;
import static java.lang.Integer.valueOf;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.transport.SideBandOutputStream.CH_DATA;
import static org.eclipse.jgit.transport.SideBandOutputStream.CH_ERROR;
import static org.eclipse.jgit.transport.SideBandOutputStream.CH_PROGRESS;
@@ -59,7 +60,6 @@ import java.io.OutputStream;
import java.text.MessageFormat;
import org.eclipse.jgit.internal.JGitText;
-import org.eclipse.jgit.lib.Constants;
import org.junit.Before;
import org.junit.Test;
@@ -259,8 +259,7 @@ public class SideBandOutputStreamTest {
}
}
- private void assertBuffer(String exp) throws IOException {
- assertEquals(exp, new String(rawOut.toByteArray(),
- Constants.CHARACTER_ENCODING));
+ private void assertBuffer(String exp) {
+ assertEquals(exp, new String(rawOut.toByteArray(), UTF_8));
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
index 1783c4193e..9653c365b2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -43,6 +43,8 @@
*/
package org.eclipse.jgit.api;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
@@ -1015,8 +1017,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
df.setRepository(repo);
df.format(commitToPick.getParent(0), commitToPick);
}
- rebaseState.createFile(PATCH, new String(bos.toByteArray(),
- Constants.CHARACTER_ENCODING));
+ rebaseState.createFile(PATCH, new String(bos.toByteArray(), UTF_8));
rebaseState.createFile(STOPPED_SHA,
repo.newObjectReader()
.abbreviate(
@@ -1733,7 +1734,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
throws IOException {
File file = new File(parentDir, name);
try (FileOutputStream fos = new FileOutputStream(file)) {
- fos.write(content.getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(content.getBytes(UTF_8));
fos.write('\n');
}
}
@@ -1741,7 +1742,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
private static void appendToFile(File file, String content)
throws IOException {
try (FileOutputStream fos = new FileOutputStream(file, true)) {
- fos.write(content.getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(content.getBytes(UTF_8));
fos.write('\n');
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
index 45a239da0e..5a73cdc067 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.gitrepo;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME;
import static org.eclipse.jgit.lib.Constants.R_REMOTES;
@@ -606,8 +607,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
}
objectId = inserter.insert(Constants.OBJ_BLOB,
- link.getBytes(
- Constants.CHARACTER_ENCODING));
+ link.getBytes(UTF_8));
dcEntry = new DirCacheEntry(linkfile.dest);
dcEntry.setObjectId(objectId);
dcEntry.setFileMode(FileMode.SYMLINK);
@@ -620,7 +620,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
// create a new DirCacheEntry for .gitmodules file.
final DirCacheEntry dcEntry = new DirCacheEntry(Constants.DOT_GIT_MODULES);
ObjectId objectId = inserter.insert(Constants.OBJ_BLOB,
- content.getBytes(Constants.CHARACTER_ENCODING));
+ content.getBytes(UTF_8));
dcEntry.setObjectId(objectId);
dcEntry.setFileMode(FileMode.REGULAR_FILE);
builder.add(dcEntry);
@@ -629,7 +629,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
// create a new DirCacheEntry for .gitattributes file.
final DirCacheEntry dcEntryAttr = new DirCacheEntry(Constants.DOT_GIT_ATTRIBUTES);
ObjectId attrId = inserter.insert(Constants.OBJ_BLOB,
- attributes.toString().getBytes(Constants.CHARACTER_ENCODING));
+ attributes.toString().getBytes(UTF_8));
dcEntryAttr.setObjectId(attrId);
dcEntryAttr.setFileMode(FileMode.REGULAR_FILE);
builder.add(dcEntryAttr);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
index ed0055416b..4c55196961 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
@@ -232,11 +232,17 @@ public final class Constants {
*
* @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
* instead.
- **/
+ */
@Deprecated
public static final Charset CHARSET;
- /** Native character encoding for commit messages, file names... */
+ /**
+ * Native character encoding for commit messages, file names...
+ *
+ * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
+ * instead.
+ */
+ @Deprecated
public static final String CHARACTER_ENCODING;
/** Default main branch name */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index d73c05e243..2a2699f906 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -49,6 +49,7 @@
package org.eclipse.jgit.lib;
import static org.eclipse.jgit.lib.Constants.LOCK_SUFFIX;
+import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -1965,7 +1966,7 @@ public abstract class Repository implements AutoCloseable {
private void writeCommitMsg(File msgFile, String msg) throws IOException {
if (msg != null) {
try (FileOutputStream fos = new FileOutputStream(msgFile)) {
- fos.write(msg.getBytes(Constants.CHARACTER_ENCODING));
+ fos.write(msg.getBytes(UTF_8));
}
} else {
FileUtils.delete(msgFile, FileUtils.SKIP_MISSING);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
index 026fd819c4..70fb1f0e56 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
@@ -48,10 +48,11 @@
package org.eclipse.jgit.transport;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.BitSet;
@@ -282,12 +283,7 @@ public class URIish implements Serializable {
if (s.indexOf('%') < 0)
return s;
- byte[] bytes;
- try {
- bytes = s.getBytes(Constants.CHARACTER_ENCODING);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e); // can't happen
- }
+ byte[] bytes = s.getBytes(UTF_8);
byte[] os = new byte[bytes.length];
int j = 0;
@@ -335,12 +331,7 @@ public class URIish implements Serializable {
if (s == null)
return null;
ByteArrayOutputStream os = new ByteArrayOutputStream(s.length());
- byte[] bytes;
- try {
- bytes = s.getBytes(Constants.CHARACTER_ENCODING);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e); // cannot happen
- }
+ byte[] bytes = s.getBytes(UTF_8);
for (int i = 0; i < bytes.length; ++i) {
int b = bytes[i] & 0xFF;
if (b <= 32 || (encodeNonAscii && b > 127) || b == '%'
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
index 24b9ac086e..3d25c2314e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
@@ -46,6 +46,8 @@
package org.eclipse.jgit.treewalk;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -412,7 +414,7 @@ public class FileTreeIterator extends WorkingTreeIterator {
public InputStream openInputStream() throws IOException {
if (attributes.isSymbolicLink()) {
return new ByteArrayInputStream(fs.readSymLink(getFile())
- .getBytes(Constants.CHARACTER_ENCODING));
+ .getBytes(UTF_8));
} else {
return new FileInputStream(getFile());
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index 180123e091..e559d2167c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -43,6 +43,8 @@
package org.eclipse.jgit.util;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
@@ -1286,7 +1288,7 @@ public abstract class FS {
OutputStream outRedirect, OutputStream errRedirect, String stdinArgs)
throws IOException, InterruptedException {
InputStream in = (stdinArgs == null) ? null : new ByteArrayInputStream(
- stdinArgs.getBytes(Constants.CHARACTER_ENCODING));
+ stdinArgs.getBytes(UTF_8));
return runProcess(processBuilder, outRedirect, errRedirect, in);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
index 6f92b37853..9190a5915a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
@@ -44,7 +44,7 @@
package org.eclipse.jgit.util;
-import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
+import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -181,7 +181,7 @@ public class HttpSupport {
if (key == null || key.length() == 0)
return;
try {
- urlstr.append(URLEncoder.encode(key, CHARACTER_ENCODING));
+ urlstr.append(URLEncoder.encode(key, UTF_8.name()));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e);
}

Back to the top