]> source.dussan.org Git - jgit.git/commitdiff
Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8 47/118947/4
authorDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 8 Mar 2018 00:44:01 +0000 (09:44 +0900)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 11 Mar 2018 21:46:52 +0000 (22:46 +0100)
Change-Id: I6714fc3666e1bced22abba94ceb700477349586e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
75 files changed:
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/LfsServerTest.java
org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java
org.eclipse.jgit.lfs.test/src/org/eclipse/jgit/lfs/test/LongObjectIdTestUtils.java
org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteReftable.java
org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolStreamTypeUtilTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/GetTextTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawSubStringPatternTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoLFInputStreamTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/sha1/SHA1Test.java
org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java

index 9379f022e04bad4d701f57b87c498404a76f003c..9ed60d941a52f20748c0e2045996a544030e36a9 100644 (file)
@@ -42,6 +42,8 @@
  */
 package org.eclipse.jgit.archive;
 
+import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.text.MessageFormat;
@@ -82,7 +84,8 @@ public final class TarFormat extends BaseFormat implements
        @Override
        public ArchiveOutputStream createArchiveOutputStream(OutputStream s,
                        Map<String, Object> o) throws IOException {
-               TarArchiveOutputStream out = new TarArchiveOutputStream(s, "UTF-8"); //$NON-NLS-1$
+               TarArchiveOutputStream out = new TarArchiveOutputStream(s,
+                               CHARACTER_ENCODING);
                out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
                out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
                return applyFormatOptions(out, o);
@@ -97,7 +100,7 @@ public final class TarFormat extends BaseFormat implements
                        final TarArchiveEntry entry = new TarArchiveEntry(
                                        path, TarConstants.LF_SYMLINK);
                        entry.setLinkName(new String(
-                                       loader.getCachedBytes(100), "UTF-8")); //$NON-NLS-1$
+                                       loader.getCachedBytes(100), CHARACTER_ENCODING));
                        out.putArchiveEntry(entry);
                        out.closeArchiveEntry();
                        return;
index 5f40be4e05cbf864d5e1e9da162b10c1a08df72c..6ded21f8cc0a2a736c16f19f8f397ef3e97988fb 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.http.test;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_ENCODING;
 import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_LENGTH;
 import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE;
@@ -1084,7 +1084,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
        public void testInvalidWant() throws Exception {
                @SuppressWarnings("resource")
                ObjectId id = new ObjectInserter.Formatter().idFor(Constants.OBJ_BLOB,
-                               "testInvalidWant".getBytes(UTF_8));
+                               "testInvalidWant".getBytes(CHARSET));
 
                Repository dst = createBareRepository();
                try (Transport t = Transport.open(dst, remoteURI);
index cef81a062d4e6b952d5f7a773fd0c07a148fc97c..27f745e4e91935f7dcaef65edc5380430c8b0955 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -246,7 +246,7 @@ public abstract class JGitTestUtil {
                        throws IOException {
                FileUtils.mkdirs(f.getParentFile(), true);
                try (Writer w = new OutputStreamWriter(new FileOutputStream(f),
-                               UTF_8)) {
+                               CHARSET)) {
                        w.write(body);
                }
        }
@@ -263,7 +263,7 @@ public abstract class JGitTestUtil {
         */
        public static String read(final File file) throws IOException {
                final byte[] body = IO.readFully(file);
-               return new String(body, 0, body.length, UTF_8);
+               return new String(body, 0, body.length, CHARSET);
        }
 
        /**
index 568bc3b0e16eb62fe83365d27f76d1a71bd6455d..3c00bd3df1b60055bfaa102410fb92af27e40de1 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
@@ -352,7 +352,7 @@ public abstract class LocalDiskRepositoryTestCase {
                        if (0 != (includedOptions & CONTENT)) {
                                sb.append(", content:"
                                                + new String(repo.open(entry.getObjectId(),
-                                               Constants.OBJ_BLOB).getCachedBytes(), UTF_8));
+                                               Constants.OBJ_BLOB).getCachedBytes(), CHARSET));
                        }
                        if (0 != (includedOptions & ASSUME_UNCHANGED))
                                sb.append(", assume-unchanged:"
index afc2c445cfa745bac279cfa66f4f32806770ef7f..5a83a1f4929a1845df2c55ca7665cbd98a6d4b56 100644 (file)
@@ -46,7 +46,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 
 import java.io.File;
@@ -199,7 +199,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
        protected static void checkFile(File f, final String checkData)
                        throws IOException {
                try (Reader r = new InputStreamReader(new FileInputStream(f),
-                               UTF_8)) {
+                               CHARSET)) {
                        if (checkData.length() > 0) {
                                char[] data = new char[checkData.length()];
                                assertEquals(data.length, r.read(data));
index 41634e7cda13328eacb44b0fa7dab942612a9672..89a86d8eeaf5959e0b753caf9015c052836af6e9 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -268,7 +268,7 @@ public class TestRepository<R extends Repository> {
         * @throws Exception
         */
        public RevBlob blob(final String content) throws Exception {
-               return blob(content.getBytes(UTF_8));
+               return blob(content.getBytes(CHARSET));
        }
 
        /**
index 10823b878845359a0467cd8ea54ef2bd2efcd8b8..50a06f94d68199d8ebad1ee782860122f3359364 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs.server.fs;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 
 import java.io.BufferedInputStream;
@@ -211,11 +211,11 @@ public abstract class LfsServerTest {
                                if (buf.hasArray()) {
                                        error = new String(buf.array(),
                                                        buf.arrayOffset() + buf.position(), buf.remaining(),
-                                                       UTF_8);
+                                                       CHARSET);
                                } else {
                                        final byte[] b = new byte[buf.remaining()];
                                        buf.duplicate().get(b);
-                                       error = new String(b, UTF_8);
+                                       error = new String(b, CHARSET);
                                }
                        } catch (IOException e) {
                                error = statusLine.getReasonPhrase();
index 690abb27e797f9e9f2accb456f75c39c2fe66bfb..28b123165e09d6c6ff63c19f498a605b3b5da4fb 100644 (file)
@@ -31,6 +31,7 @@ Import-Package: com.google.gson;version="[2.8.0,3.0.0)",
  org.eclipse.jgit.lfs.errors;version="[5.0.0,5.1.0)",
  org.eclipse.jgit.lfs.internal;version="[5.0.0,5.1.0)",
  org.eclipse.jgit.lfs.lib;version="[5.0.0,5.1.0)",
+ org.eclipse.jgit.lib;version="[5.0.0,5.1.0)",
  org.eclipse.jgit.nls;version="[5.0.0,5.1.0)",
  org.eclipse.jgit.transport.http;version="[5.0.0,5.1.0)",
  org.eclipse.jgit.transport.http.apache;version="[5.0.0,5.1.0)",
index c7f55dd3c1daa49da2ac19efae22f0b5207d1d72..d22d45967edfb5a60d002c109b7de6d1862f29cd 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs.server;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.apache.http.HttpStatus.SC_FORBIDDEN;
 import static org.apache.http.HttpStatus.SC_INSUFFICIENT_STORAGE;
 import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
@@ -202,10 +202,10 @@ public abstract class LfsProtocolServlet extends HttpServlet {
        protected void doPost(HttpServletRequest req, HttpServletResponse res)
                        throws ServletException, IOException {
                Writer w = new BufferedWriter(
-                               new OutputStreamWriter(res.getOutputStream(), UTF_8));
+                               new OutputStreamWriter(res.getOutputStream(), CHARSET));
 
                Reader r = new BufferedReader(
-                               new InputStreamReader(req.getInputStream(), UTF_8));
+                               new InputStreamReader(req.getInputStream(), CHARSET));
                LfsRequest request = LfsGson.fromJson(r, LfsRequest.class);
                String path = req.getPathInfo();
 
index b21c94e4e6488640fba293ca952f216962a653fc..374a560581a4557cedced0b8d1369ceec423fede 100644 (file)
@@ -43,7 +43,7 @@
  */
 package org.eclipse.jgit.lfs.server.s3;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION;
 
 import java.io.UnsupportedEncodingException;
@@ -359,13 +359,13 @@ class SignerV4 {
 
        private static byte[] hash(String s) {
                MessageDigest md = Constants.newMessageDigest();
-               md.update(s.getBytes(UTF_8));
+               md.update(s.getBytes(CHARSET));
                return md.digest();
        }
 
        private static byte[] sign(String stringData, byte[] key) {
                try {
-                       byte[] data = stringData.getBytes(UTF_8);
+                       byte[] data = stringData.getBytes(CHARSET);
                        Mac mac = Mac.getInstance(HMACSHA256);
                        mac.init(new SecretKeySpec(key, HMACSHA256));
                        return mac.doFinal(data);
@@ -395,7 +395,7 @@ class SignerV4 {
        private static String urlEncode(String url, boolean keepPathSlash) {
                String encoded;
                try {
-                       encoded = URLEncoder.encode(url, UTF_8.name());
+                       encoded = URLEncoder.encode(url, CHARSET.name());
                } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(LfsServerText.get().unsupportedUtf8, e);
                }
index c3c38594675bf10c9d79531e68393047483b6230..e3c6ef80bc43386ccd3a40e1e0d186f895074d2d 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs.test;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.BufferedInputStream;
 import java.io.FileNotFoundException;
@@ -66,7 +66,7 @@ public class LongObjectIdTestUtils {
         */
        public static LongObjectId hash(String s) {
                MessageDigest md = Constants.newMessageDigest();
-               md.update(s.getBytes(UTF_8));
+               md.update(s.getBytes(CHARSET));
                return LongObjectId.fromRaw(md.digest());
        }
 
index 146a25ed3d90d548ba72c04940596eb1a0db4f58..a1283ddf419c8901a50d4856637f53f79b5170cb 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.lfs.lib;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
 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(UTF_8.name()));
+                                       baos.toString(CHARACTER_ENCODING));
                }
        }
 }
index 0e3830c098f0b525952b8a92db77a6239eaf0fb8..4f959409fca50da199a87f7206aa568bba226085 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -134,7 +134,7 @@ public class LfsPointer implements Comparable<LfsPointer> {
         */
        public void encode(OutputStream out) {
                try (PrintStream ps = new PrintStream(out, false,
-                               UTF_8.name())) {
+                               CHARSET.name())) {
                        ps.print("version "); //$NON-NLS-1$
                        ps.print(VERSION + "\n"); //$NON-NLS-1$
                        ps.print("oid " + HASH_FUNCTION_NAME + ":"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -143,7 +143,7 @@ public class LfsPointer implements Comparable<LfsPointer> {
                        ps.print(size + "\n"); //$NON-NLS-1$
                } catch (UnsupportedEncodingException e) {
                        // should not happen, we are using a standard charset
-                       throw new UnsupportedCharsetException(UTF_8.name());
+                       throw new UnsupportedCharsetException(CHARSET.name());
                }
        }
 
@@ -165,7 +165,7 @@ public class LfsPointer implements Comparable<LfsPointer> {
                long sz = -1;
 
                try (BufferedReader br = new BufferedReader(
-                               new InputStreamReader(in, UTF_8))) {
+                               new InputStreamReader(in, CHARSET))) {
                        for (String s = br.readLine(); s != null; s = br.readLine()) {
                                if (s.startsWith("#") || s.length() == 0) { //$NON-NLS-1$
                                        continue;
index c522572ee37c45fa179130effb2af39780e743dd..7fd7c216acf6b728dfee855c48fe2d08a420bdab 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lfs.Protocol.OPERATION_UPLOAD;
 import static org.eclipse.jgit.lfs.internal.LfsConnectionFactory.toRequest;
 import static org.eclipse.jgit.transport.http.HttpConnection.HTTP_OK;
@@ -204,7 +204,7 @@ public class LfsPrePushHook extends PrePushHook {
                }
                Gson gson = Protocol.gson();
                api.getOutputStream().write(
-                               gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(UTF_8));
+                               gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(CHARSET));
                int responseCode = api.getResponseCode();
                if (responseCode != HTTP_OK) {
                        throw new IOException(
index e2ab3092300d07a82b671587b519f3ee9417d472..6bff12f9cc2092a563e5b218fb7f9aa5864abf1d 100644 (file)
  */
 package org.eclipse.jgit.lfs;
 
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.text.MessageFormat;
@@ -169,7 +170,7 @@ public class SmudgeFilter extends FilterCommand {
                                .write(gson
                                                .toJson(LfsConnectionFactory
                                                                .toRequest(Protocol.OPERATION_DOWNLOAD, res))
-                                               .getBytes(StandardCharsets.UTF_8));
+                                               .getBytes(CHARSET));
                int responseCode = lfsServerConn.getResponseCode();
                if (responseCode != HttpConnection.HTTP_OK) {
                        throw new IOException(
index e5c85ebfc733d33816b4a3ad52cedf6e8536d38a..e992ddfb5b0d901221591ed7db8ed422a5d8d303 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.pgm;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
@@ -612,7 +612,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
 
        private BufferedReader readFromProcess(Process proc) throws Exception {
                return new BufferedReader(
-                               new InputStreamReader(proc.getInputStream(), UTF_8));
+                               new InputStreamReader(proc.getInputStream(), CHARSET));
        }
 
        private void grepForEntry(String name, String mode, String... cmdline)
@@ -750,7 +750,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
                        // found!
                        List<String> l = new ArrayList<>();
                        BufferedReader reader = new BufferedReader(
-                                       new InputStreamReader(in, UTF_8));
+                                       new InputStreamReader(in, CHARSET));
                        String line;
                        while ((line = reader.readLine()) != null)
                                l.add(line);
index 81aeef8cddf69afffe462508ff95b7cdb0568c11..0bc80f7d310a2a5b97e76683ae71e65a6056ae18 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.pgm;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -151,7 +151,7 @@ public class CommandCatalog {
                final BufferedReader cIn;
                try {
                        final InputStream in = cUrl.openStream();
-                       cIn = new BufferedReader(new InputStreamReader(in, UTF_8));
+                       cIn = new BufferedReader(new InputStreamReader(in, CHARSET));
                } catch (IOException err) {
                        // If we cannot read from the service list, go to the next.
                        //
index a376bc098d3f717c8999e06dfeb32063667c40a2..75612be7534197f24de0e62e63a5d3b47b0433d6 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.pgm;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.File;
 import java.io.IOException;
@@ -217,7 +217,7 @@ public class Main {
        }
 
        PrintWriter createErrorWriter() {
-               return new PrintWriter(new OutputStreamWriter(System.err, UTF_8));
+               return new PrintWriter(new OutputStreamWriter(System.err, CHARSET));
        }
 
        private void execute(final String[] argv) throws Exception {
index 248eaac8ad22039a52d79f362b65bfcb5ed5859d..575a12215870bd1df8bf6707707c53e0420db93f 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.pgm.debug;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.Constants.HEAD;
 import static org.eclipse.jgit.lib.Constants.MASTER;
 import static org.eclipse.jgit.lib.Constants.R_HEADS;
@@ -154,7 +154,7 @@ class BenchmarkReftable extends TextBuiltin {
                        throws IOException, FileNotFoundException {
                RefList.Builder<Ref> list = new RefList.Builder<>();
                try (BufferedReader br = new BufferedReader(new InputStreamReader(
-                               new FileInputStream(lsRemotePath), UTF_8))) {
+                               new FileInputStream(lsRemotePath), CHARSET))) {
                        Ref last = null;
                        String line;
                        while ((line = br.readLine()) != null) {
index 6cbc1b082bb7868ffb598ee06332755f8026bdb2..c5ea028be8160ece13f390410f945843628f74c5 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.pgm.debug;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.Constants.HEAD;
 import static org.eclipse.jgit.lib.Constants.MASTER;
 import static org.eclipse.jgit.lib.Constants.R_HEADS;
@@ -192,7 +192,7 @@ class WriteReftable extends TextBuiltin {
        static List<Ref> readRefs(String inputFile) throws IOException {
                List<Ref> refs = new ArrayList<>();
                try (BufferedReader br = new BufferedReader(
-                               new InputStreamReader(new FileInputStream(inputFile), UTF_8))) {
+                               new InputStreamReader(new FileInputStream(inputFile), CHARSET))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                ObjectId id = ObjectId.fromString(line.substring(0, 40));
@@ -227,7 +227,7 @@ class WriteReftable extends TextBuiltin {
 
                List<LogEntry> log = new ArrayList<>();
                try (BufferedReader br = new BufferedReader(
-                               new InputStreamReader(new FileInputStream(logPath), UTF_8))) {
+                               new InputStreamReader(new FileInputStream(logPath), CHARSET))) {
                        @SuppressWarnings("nls")
                        Pattern pattern = Pattern.compile("([^,]+)" // 1: ref
                                        + ",([0-9]+(?:[.][0-9]+)?)" // 2: time
index 438d2d625b2aadb4d4a3637815504f7d6a4725fb..4d9e864227e26761042c489db16ead5c4aa6a341 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.ignore;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -158,7 +158,7 @@ public class CGitVsJGitRandomIgnorePatternTest {
                        this.gitDir = gitDir;
                        this.pattern = pattern;
                        Files.write(FileUtils.toPath(new File(gitDir, ".gitignore")),
-                                       (pattern + "\n").getBytes(UTF_8), StandardOpenOption.CREATE,
+                                       (pattern + "\n").getBytes(CHARSET), StandardOpenOption.CREATE,
                                        StandardOpenOption.TRUNCATE_EXISTING,
                                        StandardOpenOption.WRITE);
                }
@@ -188,7 +188,7 @@ public class CGitVsJGitRandomIgnorePatternTest {
                        Process proc = Runtime.getRuntime().exec(command, new String[0],
                                        gitDir);
                        try (OutputStream out = proc.getOutputStream()) {
-                               out.write((path + "\n").getBytes(UTF_8));
+                               out.write((path + "\n").getBytes(CHARSET));
                                out.flush();
                        }
                        return proc;
index 1e3a39aad82b301a12d2e7069a777322443557ea..bb303cc4115246467fdbd7d64c5c5ccbc0a305be 100644 (file)
@@ -42,7 +42,7 @@
 
 package org.eclipse.jgit.api;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_CRLF;
 import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_LF;
 import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.DIRECT;
@@ -150,8 +150,8 @@ public class EolStreamTypeUtilTest {
                        EolStreamType streamTypeWithBinaryCheck, String output,
                        String expectedConversion) throws Exception {
                ByteArrayOutputStream b;
-               byte[] outputBytes = output.getBytes(UTF_8);
-               byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
+               byte[] outputBytes = output.getBytes(CHARSET);
+               byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
 
                // test using output text and assuming it was declared TEXT
                b = new ByteArrayOutputStream();
@@ -277,8 +277,8 @@ public class EolStreamTypeUtilTest {
        private void testCheckin(EolStreamType streamTypeText,
                        EolStreamType streamTypeWithBinaryCheck, String input,
                        String expectedConversion) throws Exception {
-               byte[] inputBytes = input.getBytes(UTF_8);
-               byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
+               byte[] inputBytes = input.getBytes(CHARSET);
+               byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
 
                // test using input text and assuming it was declared TEXT
                try (InputStream in = EolStreamTypeUtil.wrapInputStream(
index 6e06e9545a9c2be264dedc908bdb1665b90bec2f..e234aa339c2be2c943a0d921b1393d770daac5e4 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 
 import java.util.List;
@@ -88,7 +88,7 @@ public class NotesCommandTest extends RepositoryTestCase {
                git.notesAdd().setObjectId(commit2).setMessage("data").call();
                Note note = git.notesShow().setObjectId(commit2).call();
                String content = new String(db.open(note.getData()).getCachedBytes(),
-                               UTF_8);
+                               CHARSET);
                assertEquals(content, "data");
 
                git.notesRemove().setObjectId(commit2).call();
index 9461c42500431683fc7d0e86c60fd8f07ed2b393..0b0e3bf3ea6536105bda282388acbc2f613b2084 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -592,7 +592,7 @@ public class PullCommandTest extends RepositoryTestCase {
        private static void writeToFile(File actFile, String string)
                        throws IOException {
                try (FileOutputStream fos = new FileOutputStream(actFile)) {
-                       fos.write(string.getBytes(UTF_8));
+                       fos.write(string.getBytes(CHARSET));
                }
        }
 
@@ -606,7 +606,7 @@ public class PullCommandTest extends RepositoryTestCase {
                                bos.write(buffer, 0, read);
                                read = fis.read(buffer);
                        }
-                       String content = new String(bos.toByteArray(), UTF_8);
+                       String content = new String(bos.toByteArray(), CHARSET);
                        assertEquals(string, content);
                }
        }
index 913b4ac434a99095cf7e71bbbebff32da1728fca..b349c66cabbbb75ccca374c6d025aebed860b99e 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -396,7 +396,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
        private static void writeToFile(File actFile, String string)
                        throws IOException {
                try (FileOutputStream fos = new FileOutputStream(actFile)) {
-                       fos.write(string.getBytes(UTF_8));
+                       fos.write(string.getBytes(CHARSET));
                }
        }
 
@@ -410,7 +410,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
                                bos.write(buffer, 0, read);
                                read = fis.read(buffer);
                        }
-                       String content = new String(bos.toByteArray(), UTF_8);
+                       String content = new String(bos.toByteArray(), CHARSET);
                        assertEquals(string, content);
                }
        }
index 2bf91aeed86f0142eaffb0b0393a68f23e46806c..96e7091ae15959252219295d6009a60d302a1315 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -1464,7 +1464,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
                assertEquals("GIT_AUTHOR_DATE='@123456789 -0100'", lines[2]);
 
                PersonIdent parsedIdent = git.rebase().parseAuthor(
-                               convertedAuthor.getBytes(UTF_8));
+                               convertedAuthor.getBytes(CHARSET));
                assertEquals(ident.getName(), parsedIdent.getName());
                assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
                // this is rounded to the last second
@@ -1481,7 +1481,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
                assertEquals("GIT_AUTHOR_DATE='@123456789 +0930'", lines[2]);
 
                parsedIdent = git.rebase().parseAuthor(
-                               convertedAuthor.getBytes(UTF_8));
+                               convertedAuthor.getBytes(CHARSET));
                assertEquals(ident.getName(), parsedIdent.getName());
                assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
                assertEquals(123456789000L, parsedIdent.getWhen().getTime());
@@ -2104,7 +2104,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
                int count = 0;
                File todoFile = getTodoFile();
                try (BufferedReader br = new BufferedReader(new InputStreamReader(
-                               new FileInputStream(todoFile), UTF_8))) {
+                               new FileInputStream(todoFile), CHARSET))) {
                        String line = br.readLine();
                        while (line != null) {
                                int firstBlank = line.indexOf(' ');
index 0f13a68b256c870a6063921cc8686feec66e4bac..32f34213ecdb0afbef91add01be412ece8039941 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.diff;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -240,6 +240,6 @@ public abstract class AbstractDiffTestCase {
                        r.append(text.charAt(i));
                        r.append('\n');
                }
-               return new RawText(r.toString().getBytes(UTF_8));
+               return new RawText(r.toString().getBytes(CHARSET));
        }
 }
index 6ad59b9e56498b527c3da29ad9e1c0957ac49971..69e40777cc4c19c29733eda98f617dbb78321eca 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.diff;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -136,8 +136,8 @@ public class RawTextTest {
                e = c.reduceCommonStartEnd(t("abQxy"), t("abRxy"), e);
                assertEquals(new Edit(2, 3, 2, 3), e);
 
-               RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(UTF_8));
-               RawText b = new RawText("p\na  b \nR\n c  d \n".getBytes(UTF_8));
+               RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(CHARSET));
+               RawText b = new RawText("p\na  b \nR\n c  d \n".getBytes(CHARSET));
                e = new Edit(0, 4, 0, 4);
                e = RawTextComparator.WS_IGNORE_ALL.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(2, 3, 2, 3), e);
@@ -149,14 +149,14 @@ public class RawTextTest {
                RawText b;
                Edit e;
 
-               a = new RawText("R\n y\n".getBytes(UTF_8));
-               b = new RawText("S\n\n y\n".getBytes(UTF_8));
+               a = new RawText("R\n y\n".getBytes(CHARSET));
+               b = new RawText("S\n\n y\n".getBytes(CHARSET));
                e = new Edit(0, 2, 0, 3);
                e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(0, 1, 0, 2), e);
 
-               a = new RawText("S\n\n y\n".getBytes(UTF_8));
-               b = new RawText("R\n y\n".getBytes(UTF_8));
+               a = new RawText("S\n\n y\n".getBytes(CHARSET));
+               b = new RawText("R\n y\n".getBytes(CHARSET));
                e = new Edit(0, 3, 0, 2);
                e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(0, 2, 0, 1), e);
@@ -167,8 +167,8 @@ public class RawTextTest {
                RawText a;
                RawText b;
                Edit e;
-               a = new RawText("start".getBytes(UTF_8));
-               b = new RawText("start of line".getBytes(UTF_8));
+               a = new RawText("start".getBytes(CHARSET));
+               b = new RawText("start of line".getBytes(CHARSET));
                e = new Edit(0, 1, 0, 1);
                e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(0, 1, 0, 1), e);
@@ -179,8 +179,8 @@ public class RawTextTest {
                RawText a;
                RawText b;
                Edit e;
-               a = new RawText("start".getBytes(UTF_8));
-               b = new RawText("start of\nlastline".getBytes(UTF_8));
+               a = new RawText("start".getBytes(CHARSET));
+               b = new RawText("start of\nlastline".getBytes(CHARSET));
                e = new Edit(0, 1, 0, 2);
                e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(0, 1, 0, 2), e);
@@ -239,6 +239,6 @@ public class RawTextTest {
                        r.append(text.charAt(i));
                        r.append('\n');
                }
-               return new RawText(r.toString().getBytes(UTF_8));
+               return new RawText(r.toString().getBytes(CHARSET));
        }
 }
index f168e832846e7c02b87309ac1d21ea8042ebd212..51a6f8121c2650d420ec558ed9f1e11c6e177a4b 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.diff;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -82,7 +82,7 @@ public class SimilarityIndexTest {
                                + "A\n" //
                                + "B\n" //
                                + "B\n" //
-                               + "B\n").getBytes(UTF_8);
+                               + "B\n").getBytes(CHARSET);
                SimilarityIndex si = new SimilarityIndex();
                si.hash(new ByteArrayInputStream(in), in.length, false);
                assertEquals(2, si.size());
@@ -130,12 +130,12 @@ public class SimilarityIndexTest {
                                + "D\r\n" //
                                + "B\r\n";
                SimilarityIndex src = new SimilarityIndex();
-               byte[] bytes1 = text.getBytes(UTF_8);
+               byte[] bytes1 = text.getBytes(CHARSET);
                src.hash(new ByteArrayInputStream(bytes1), bytes1.length, true);
                src.sort();
 
                SimilarityIndex dst = new SimilarityIndex();
-               byte[] bytes2 = text.replace("\r", "").getBytes(UTF_8);
+               byte[] bytes2 = text.replace("\r", "").getBytes(CHARSET);
                dst.hash(new ByteArrayInputStream(bytes2), bytes2.length, true);
                dst.sort();
 
index dec17623fc99d75ef264c6bb9255bdb5555397e6..80d4329858c1bbde683945f32d2c0a88c4450f06 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.dircache;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.junit.Assert.assertEquals;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -236,7 +236,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
        private static Map<String, CGitIndexRecord> readLsFiles() throws Exception {
                final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<>();
                try (BufferedReader br = new BufferedReader(new InputStreamReader(
-                               new FileInputStream(pathOf("gitgit.lsfiles")), UTF_8))) {
+                               new FileInputStream(pathOf("gitgit.lsfiles")), CHARSET))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                final CGitIndexRecord cr = new CGitIndexRecord(line);
@@ -249,7 +249,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
        private static Map<String, CGitLsTreeRecord> readLsTree() throws Exception {
                final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<>();
                try (BufferedReader br = new BufferedReader(new InputStreamReader(
-                               new FileInputStream(pathOf("gitgit.lstree")), UTF_8))) {
+                               new FileInputStream(pathOf("gitgit.lstree")), CHARSET))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                final CGitLsTreeRecord cr = new CGitLsTreeRecord(line);
index c9673a68827ccad4b4347d4ab45ad201f386251a..69a48cc4b5fd0058e4ad75c8e5207924754c264a 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.gitrepo;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -82,7 +82,7 @@ public class ManifestParserTest {
 
                ManifestParser parser = new ManifestParser(
                                null, null, "master", baseUrl, null, null);
-               parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)));
+               parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)));
                // Unfiltered projects should have them all.
                results.clear();
                results.add("foo");
@@ -136,7 +136,7 @@ public class ManifestParserTest {
                                baseUrl, null, null);
                try {
                        parser.read(new ByteArrayInputStream(
-                                       xmlContent.toString().getBytes(UTF_8)));
+                                       xmlContent.toString().getBytes(CHARSET)));
                        fail("ManifestParser did not throw exception for missing fetch");
                } catch (IOException e) {
                        assertTrue(e.getCause() instanceof SAXException);
index 2253a0421fbd11dddefc13a69f6501ad7a53d0a8..6f6dd5f46faa8f4ef9b6e916f93527d5947d87b1 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.gitrepo;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -214,7 +214,7 @@ public class RepoCommandTest extends RepositoryTestCase {
 
                RevCommit commit = cmd
                        .setInputStream(new ByteArrayInputStream(
-                               xmlContent.toString().getBytes(UTF_8)))
+                               xmlContent.toString().getBytes(CHARSET)))
                        .setRemoteReader(repos)
                        .setURI("platform/")
                        .setTargetURI("platform/superproject")
@@ -225,7 +225,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                String firstIdStr = commit.getId().name() + ":" + ".gitmodules";
                commit = new RepoCommand(dest)
                        .setInputStream(new ByteArrayInputStream(
-                               xmlContent.toString().getBytes(UTF_8)))
+                               xmlContent.toString().getBytes(CHARSET)))
                        .setRemoteReader(repos)
                        .setURI("platform/")
                        .setTargetURI("platform/superproject")
@@ -266,7 +266,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                repos.put("platform/base", child);
 
                RevCommit commit = cmd
-                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
+                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
                        .setRemoteReader(repos)
                        .setURI("platform/")
                        .setTargetURI("platform/superproject")
@@ -308,7 +308,7 @@ public class RepoCommandTest extends RepositoryTestCase {
 
                RevCommit commit = new RepoCommand(dest)
                        .setInputStream(new ByteArrayInputStream(
-                               xmlContent.toString().getBytes(UTF_8)))
+                               xmlContent.toString().getBytes(CHARSET)))
                        .setRemoteReader(new IndexedRepos())
                        .setURI("platform/")
                        .setTargetURI("platform/superproject")
@@ -358,7 +358,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                repos.put("plugins/cookbook", child);
 
                RevCommit commit = cmd
-                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
+                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
                        .setRemoteReader(repos)
                        .setURI("")
                        .setTargetURI("gerrit")
@@ -412,7 +412,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                                repos.put(repoUrl, child);
 
                                RevCommit commit = cmd
-                                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
+                                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
                                        .setRemoteReader(repos)
                                        .setURI(baseUrl)
                                        .setTargetURI("gerrit")
@@ -469,7 +469,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                                repos.put(repoUrl, child);
 
                                RevCommit commit = cmd
-                                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
+                                       .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
                                        .setRemoteReader(repos)
                                        .setURI(baseUrl)
                                        .setTargetURI(abs + "/superproject")
index 17c7ef1392f722083d6f8c2ca8a27a7a47f1e244..80595feff5da10ad44bacc52d8f4d38a59064afc 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.ignore;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.junit.Assert.assertEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -765,6 +765,6 @@ public class IgnoreNodeTest extends RepositoryTestCase {
                for (String line : rules) {
                        data.append(line + "\n");
                }
-               return new ByteArrayInputStream(data.toString().getBytes(UTF_8));
+               return new ByteArrayInputStream(data.toString().getBytes(CHARSET));
        }
 }
index d5d3857ca4cc4de7ad2860f5cd0f4753bee23a28..26c11c7eb7d01d0efa43f1f7aa5ffc55ba95559a 100644 (file)
@@ -41,7 +41,7 @@
  */
 package org.eclipse.jgit.indexdiff;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -128,7 +128,7 @@ public class IndexDiffWithSymlinkTest extends LocalDiskRepositoryTestCase {
                File restoreScript = new File(testDir, name + ".sh");
                try (OutputStream out = new BufferedOutputStream(
                                new FileOutputStream(restoreScript));
-                               Writer writer = new OutputStreamWriter(out, UTF_8)) {
+                               Writer writer = new OutputStreamWriter(out, CHARSET)) {
                        writer.write("echo `which git` 1>&2\n");
                        writer.write("echo `git --version` 1>&2\n");
                        writer.write("git init " + name + " && \\\n");
index 52861ecd5371768c37fbcf7db9d490d6a1b74cb8..592d0c8671cd439c59c195dac0535fe754d4ff8c 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.internal.storage.file;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.junit.Assert.assertEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -252,7 +252,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
 
                ObjectId blobId;
                try (ObjectInserter ins = bareRepo.newObjectInserter()) {
-                       blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(UTF_8));
+                       blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(CHARSET));
                        ins.flush();
                }
 
index d7505af4cf899403c89abba3cc7d3c66a409df1c..b5d6485604e1df4145b47d5c172cd70b07fa6f60 100644 (file)
@@ -47,7 +47,7 @@
 package org.eclipse.jgit.internal.storage.file;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -522,7 +522,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                                4294967295000L, 60));
                commit.setCommitter(new PersonIdent("Joe Hacker", "joe2@example.com",
                                4294967295000L, 60));
-               commit.setEncoding(UTF_8);
+               commit.setEncoding(CHARSET);
                commit.setMessage("\u00dcbergeeks");
                ObjectId cid = insertCommit(commit);
                assertEquals("4680908112778718f37e686cbebcc912730b3154", cid.name());
index b7027f3272954e933719fdc2cccff35574b1f7de..965899e7a088402a928b109f12a12a58d6527864 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
@@ -418,6 +418,6 @@ public class TestRepositoryTest {
                RevObject obj = tr.get(rw.parseTree(treeish), path);
                assertSame(RevBlob.class, obj.getClass());
                ObjectLoader loader = rw.getObjectReader().open(obj);
-               return new String(loader.getCachedBytes(), UTF_8);
+               return new String(loader.getCachedBytes(), CHARSET);
        }
 }
index f1c62d4be25d03d6ded1b2822b1f2606facb9f1d..22c66cec162fe46a5ac9b8492c63af6de95986a3 100644 (file)
@@ -45,7 +45,7 @@
 package org.eclipse.jgit.lib;
 
 import static java.lang.Integer.valueOf;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.junit.JGitTestUtil.concat;
 import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH;
 import static org.eclipse.jgit.lib.Constants.OBJ_BAD;
@@ -1454,7 +1454,7 @@ public class ObjectCheckerTest {
                StringBuilder b = new StringBuilder();
                entry(b, "100644 A");
                entry(b, "100644 a");
-               byte[] data = b.toString().getBytes(UTF_8);
+               byte[] data = b.toString().getBytes(CHARSET);
                checker.setSafeForWindows(true);
                assertCorrupt("duplicate entry names", OBJ_TREE, data);
                assertSkipListAccepts(OBJ_TREE, data);
@@ -1468,7 +1468,7 @@ public class ObjectCheckerTest {
                StringBuilder b = new StringBuilder();
                entry(b, "100644 A");
                entry(b, "100644 a");
-               byte[] data = b.toString().getBytes(UTF_8);
+               byte[] data = b.toString().getBytes(CHARSET);
                checker.setSafeForMacOS(true);
                assertCorrupt("duplicate entry names", OBJ_TREE, data);
                assertSkipListAccepts(OBJ_TREE, data);
@@ -1482,7 +1482,7 @@ public class ObjectCheckerTest {
                StringBuilder b = new StringBuilder();
                entry(b, "100644 \u0065\u0301");
                entry(b, "100644 \u00e9");
-               byte[] data = b.toString().getBytes(UTF_8);
+               byte[] data = b.toString().getBytes(CHARSET);
                checker.setSafeForMacOS(true);
                assertCorrupt("duplicate entry names", OBJ_TREE, data);
                assertSkipListAccepts(OBJ_TREE, data);
@@ -1496,7 +1496,7 @@ public class ObjectCheckerTest {
                StringBuilder b = new StringBuilder();
                entry(b, "100644 A");
                checker.setSafeForMacOS(true);
-               checker.checkTree(b.toString().getBytes(UTF_8));
+               checker.checkTree(b.toString().getBytes(CHARSET));
        }
 
        @Test
index 9322a4734e1b00367e39b8c3ebf43fa47e0a5850..9734ac851c7a839b6da1ffa790c41531036c6f7b 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.merge;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -756,7 +756,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                }
                binary[50] = '\0';
 
-               writeTrashFile("file", new String(binary, UTF_8));
+               writeTrashFile("file", new String(binary, CHARSET));
                git.add().addFilepattern("file").call();
                RevCommit first = git.commit().setMessage("added file").call();
 
@@ -764,7 +764,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                int idx = LINELEN * 1200 + 1;
                byte save = binary[idx];
                binary[idx] = '@';
-               writeTrashFile("file", new String(binary, UTF_8));
+               writeTrashFile("file", new String(binary, CHARSET));
 
                binary[idx] = save;
                git.add().addFilepattern("file").call();
@@ -773,7 +773,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
 
                git.checkout().setCreateBranch(true).setStartPoint(first).setName("side").call();
                binary[LINELEN * 1500 + 1] = '!';
-               writeTrashFile("file", new String(binary, UTF_8));
+               writeTrashFile("file", new String(binary, CHARSET));
                git.add().addFilepattern("file").call();
                RevCommit sideCommit = git.commit().setAll(true)
                        .setMessage("modified file l 1500").call();
@@ -935,7 +935,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                        merger.getMergeResults().get("file");
                        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
                                fmt.formatMerge(out, merger.getMergeResults().get("file"),
-                                               "BASE", "OURS", "THEIRS", UTF_8.name());
+                                               "BASE", "OURS", "THEIRS", CHARSET.name());
                                String expected = "<<<<<<< OURS\n"
                                                + "1master\n"
                                                + "=======\n"
@@ -943,7 +943,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
                                                + ">>>>>>> THEIRS\n"
                                                + "2\n"
                                                + "3";
-                               assertEquals(expected, new String(out.toByteArray(), UTF_8));
+                               assertEquals(expected, new String(out.toByteArray(), CHARSET));
                        }
                }
        }
@@ -1328,6 +1328,6 @@ public class ResolveMergerTest extends RepositoryTestCase {
                if (obj == null) {
                        return null;
                }
-               return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), UTF_8);
+               return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), CHARSET);
        }
 }
index 65375c7ae0b2bc70c9409f82b0b331caba0a036a..8da199f7c6256abcd495e4b42837bb13e3c96a0e 100644 (file)
@@ -44,7 +44,7 @@
 package org.eclipse.jgit.patch;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -83,7 +83,7 @@ public class GetTextTest {
        @Test
        public void testGetText_Convert() throws IOException {
                final Charset csOld = ISO_8859_1;
-               final Charset csNew = UTF_8;
+               final Charset csNew = CHARSET;
                final Patch p = parseTestPatchFile();
                assertTrue(p.getErrors().isEmpty());
                assertEquals(1, p.getFiles().size());
@@ -103,7 +103,7 @@ public class GetTextTest {
        @Test
        public void testGetText_DiffCc() throws IOException {
                final Charset csOld = ISO_8859_1;
-               final Charset csNew = UTF_8;
+               final Charset csNew = CHARSET;
                final Patch p = parseTestPatchFile();
                assertTrue(p.getErrors().isEmpty());
                assertEquals(1, p.getFiles().size());
index 88f240bb1f39557548b86ec5ab253ff28d72398f..9fc96212c712e090bfa6815e578da494292f894d 100644 (file)
@@ -44,7 +44,7 @@
 package org.eclipse.jgit.revwalk;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -114,7 +114,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
                assertNull(c.getTree());
                assertNull(c.parents);
 
-               c.parseCanonical(rw, body.toString().getBytes(UTF_8));
+               c.parseCanonical(rw, body.toString().getBytes(CHARSET));
                assertNotNull(c.getTree());
                assertEquals(treeId, c.getTree().getId());
                assertSame(rw.lookupTree(treeId), c.getTree());
@@ -148,7 +148,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
 
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
-               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
                return c;
        }
 
@@ -161,7 +161,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
 
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
-               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
 
                assertEquals("", c.getFullMessage());
                assertEquals("", c.getShortMessage());
@@ -176,7 +176,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
 
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
-               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
 
                assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent());
                assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent());
@@ -185,13 +185,13 @@ public class RevCommitParseTest extends RepositoryTestCase {
        @Test
        public void testParse_implicit_UTF8_encoded() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
-               b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8));
-               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
+               b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET));
+               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -205,13 +205,13 @@ public class RevCommitParseTest extends RepositoryTestCase {
        @Test
        public void testParse_implicit_mixed_encoded() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
                b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1));
-               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
+               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -260,14 +260,14 @@ public class RevCommitParseTest extends RepositoryTestCase {
        @Test
        public void testParse_explicit_bad_encoded() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
                b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1));
-               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
-               b.write("encoding EUC-JP\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Hi\n".getBytes(UTF_8));
+               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
+               b.write("encoding EUC-JP\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Hi\n".getBytes(CHARSET));
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -291,14 +291,14 @@ public class RevCommitParseTest extends RepositoryTestCase {
        @Test
        public void testParse_explicit_bad_encoded2() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
-               b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8));
-               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
-               b.write("encoding ISO-8859-1\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Hi\n".getBytes(UTF_8));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
+               b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET));
+               b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
+               b.write("encoding ISO-8859-1\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Hi\n".getBytes(CHARSET));
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -313,13 +313,13 @@ public class RevCommitParseTest extends RepositoryTestCase {
        public void testParse_incorrectUtf8Name() throws Exception {
                ByteArrayOutputStream b = new ByteArrayOutputStream();
                b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
-                               .getBytes(UTF_8));
-               b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
+                               .getBytes(CHARSET));
+               b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
                b.write("committer co <c@example.com> 1218123390 -0500\n"
-                               .getBytes(UTF_8));
-               b.write("encoding 'utf8'\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
+                               .getBytes(CHARSET));
+               b.write("encoding 'utf8'\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
 
                RevCommit c = new RevCommit(
                                id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
@@ -338,12 +338,12 @@ public class RevCommitParseTest extends RepositoryTestCase {
        @Test
        public void testParse_illegalEncoding() throws Exception {
                ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
-               b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
-               b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
-               b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("message\n".getBytes(UTF_8));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
+               b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
+               b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
+               b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("message\n".getBytes(CHARSET));
 
                RevCommit c = new RevCommit(
                                id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
@@ -365,12 +365,12 @@ public class RevCommitParseTest extends RepositoryTestCase {
        @Test
        public void testParse_unsupportedEncoding() throws Exception {
                ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
-               b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
-               b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
-               b.write("encoding it_IT.UTF8\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("message\n".getBytes(UTF_8));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
+               b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
+               b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
+               b.write("encoding it_IT.UTF8\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("message\n".getBytes(CHARSET));
 
                RevCommit c = new RevCommit(
                                id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
index 38bd371b909f83a76ee0126501b49831b2f6c0e8..8e9507961b2cbb2c62c2a78166e96dc304c3a1f7 100644 (file)
@@ -44,7 +44,7 @@
 package org.eclipse.jgit.revwalk;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -98,7 +98,7 @@ public class RevTagParseTest extends RepositoryTestCase {
                assertNull(c.getObject());
                assertNull(c.getTagName());
 
-               c.parseCanonical(rw, b.toString().getBytes(UTF_8));
+               c.parseCanonical(rw, b.toString().getBytes(CHARSET));
                assertNotNull(c.getObject());
                assertEquals(id, c.getObject().getId());
                assertSame(rw.lookupAny(id, typeCode), c.getObject());
@@ -141,7 +141,7 @@ public class RevTagParseTest extends RepositoryTestCase {
                assertNull(c.getObject());
                assertNull(c.getTagName());
 
-               c.parseCanonical(rw, body.toString().getBytes(UTF_8));
+               c.parseCanonical(rw, body.toString().getBytes(CHARSET));
                assertNotNull(c.getObject());
                assertEquals(treeId, c.getObject().getId());
                assertSame(rw.lookupTree(treeId), c.getObject());
@@ -189,7 +189,7 @@ public class RevTagParseTest extends RepositoryTestCase {
                assertNull(c.getObject());
                assertNull(c.getTagName());
 
-               c.parseCanonical(rw, body.toString().getBytes(UTF_8));
+               c.parseCanonical(rw, body.toString().getBytes(CHARSET));
                assertNotNull(c.getObject());
                assertEquals(treeId, c.getObject().getId());
                assertSame(rw.lookupTree(treeId), c.getObject());
@@ -213,7 +213,7 @@ public class RevTagParseTest extends RepositoryTestCase {
 
                final RevTag c;
                c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
-               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
                return c;
        }
 
@@ -221,17 +221,17 @@ public class RevTagParseTest extends RepositoryTestCase {
        public void testParse_implicit_UTF8_encoded() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
                b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
-                               .getBytes(UTF_8));
-               b.write("type tree\n".getBytes(UTF_8));
-               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
+                               .getBytes(CHARSET));
+               b.write("type tree\n".getBytes(CHARSET));
+               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
 
                b
                                .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
-                                               .getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
+                                               .getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
                final RevTag c;
                c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -246,15 +246,15 @@ public class RevTagParseTest extends RepositoryTestCase {
        public void testParse_implicit_mixed_encoded() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
                b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
-                               .getBytes(UTF_8));
-               b.write("type tree\n".getBytes(UTF_8));
-               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
+                               .getBytes(CHARSET));
+               b.write("type tree\n".getBytes(CHARSET));
+               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
                b.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
                                .getBytes(ISO_8859_1));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
                final RevTag c;
                c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -307,17 +307,17 @@ public class RevTagParseTest extends RepositoryTestCase {
        public void testParse_explicit_bad_encoded() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
                b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
-                               .getBytes(UTF_8));
-               b.write("type tree\n".getBytes(UTF_8));
-               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
+                               .getBytes(CHARSET));
+               b.write("type tree\n".getBytes(CHARSET));
+               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
                b
                                .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
                                                .getBytes(ISO_8859_1));
-               b.write("encoding EUC-JP\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Hi\n".getBytes(UTF_8));
+               b.write("encoding EUC-JP\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Hi\n".getBytes(CHARSET));
                final RevTag c;
                c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -342,17 +342,17 @@ public class RevTagParseTest extends RepositoryTestCase {
        public void testParse_explicit_bad_encoded2() throws Exception {
                final ByteArrayOutputStream b = new ByteArrayOutputStream();
                b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
-                               .getBytes(UTF_8));
-               b.write("type tree\n".getBytes(UTF_8));
-               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
+                               .getBytes(CHARSET));
+               b.write("type tree\n".getBytes(CHARSET));
+               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
                b
                                .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
-                                               .getBytes(UTF_8));
-               b.write("encoding ISO-8859-1\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("Hi\n".getBytes(UTF_8));
+                                               .getBytes(CHARSET));
+               b.write("encoding ISO-8859-1\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("Hi\n".getBytes(CHARSET));
                final RevTag c;
                c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                c.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -365,13 +365,13 @@ public class RevTagParseTest extends RepositoryTestCase {
        @Test
        public void testParse_illegalEncoding() throws Exception {
                ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
-               b.write("type tree\n".getBytes(UTF_8));
-               b.write("tag v1.0\n".getBytes(UTF_8));
-               b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8));
-               b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("message\n".getBytes(UTF_8));
+               b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
+               b.write("type tree\n".getBytes(CHARSET));
+               b.write("tag v1.0\n".getBytes(CHARSET));
+               b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET));
+               b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("message\n".getBytes(CHARSET));
 
                RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                t.parseCanonical(new RevWalk(db), b.toByteArray());
@@ -384,13 +384,13 @@ public class RevTagParseTest extends RepositoryTestCase {
        @Test
        public void testParse_unsupportedEncoding() throws Exception {
                ByteArrayOutputStream b = new ByteArrayOutputStream();
-               b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
-               b.write("type tree\n".getBytes(UTF_8));
-               b.write("tag v1.0\n".getBytes(UTF_8));
-               b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8));
-               b.write("encoding it_IT.UTF8\n".getBytes(UTF_8));
-               b.write("\n".getBytes(UTF_8));
-               b.write("message\n".getBytes(UTF_8));
+               b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
+               b.write("type tree\n".getBytes(CHARSET));
+               b.write("tag v1.0\n".getBytes(CHARSET));
+               b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET));
+               b.write("encoding it_IT.UTF8\n".getBytes(CHARSET));
+               b.write("\n".getBytes(CHARSET));
+               b.write("message\n".getBytes(CHARSET));
 
                RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                t.parseCanonical(new RevWalk(db), b.toByteArray());
index 7f0d60295c9936029877b8cbcb5f1cf8f51673b5..0dea5ce97b240cf14f971528da1484e0c3ae47fe 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.storage.file;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.util.FileUtils.pathToString;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -105,7 +105,7 @@ public class FileBasedConfigTest {
 
        @Test
        public void testUTF8withoutBOM() throws IOException, ConfigInvalidException {
-               final File file = createFile(CONTENT1.getBytes(UTF_8));
+               final File file = createFile(CONTENT1.getBytes(CHARSET));
                final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
                config.load();
                assertEquals(ALICE, config.getString(USER, null, NAME));
@@ -121,7 +121,7 @@ public class FileBasedConfigTest {
                bos1.write(0xEF);
                bos1.write(0xBB);
                bos1.write(0xBF);
-               bos1.write(CONTENT1.getBytes(UTF_8));
+               bos1.write(CONTENT1.getBytes(CHARSET));
 
                final File file = createFile(bos1.toByteArray());
                final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
@@ -135,7 +135,7 @@ public class FileBasedConfigTest {
                bos2.write(0xEF);
                bos2.write(0xBB);
                bos2.write(0xBF);
-               bos2.write(CONTENT2.getBytes(UTF_8));
+               bos2.write(CONTENT2.getBytes(CHARSET));
                assertArrayEquals(bos2.toByteArray(), IO.readFully(file));
        }
 
index 658b971acbb6512ec87bdeae55f1394bb13acbcc..d30ac840a6e553202c69733013f9a342a7915d06 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -199,7 +199,7 @@ public class BundleWriterTest extends SampleDataRepositoryTestCase {
                        Ref ref = repo.exactRef(refName);
                        assertNotNull(ref);
                        assertEquals(id, ref.getObjectId());
-                       assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), UTF_8));
+                       assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), CHARSET));
                }
        }
 
index cb04f83fb509a7b21db126b8b95c18651051476b..2251a3dc66e592e2c8f4ffc94aa9c9cbb0753b64 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListPBE;
 import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListTrans;
 import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.folderDelete;
@@ -360,7 +360,7 @@ public class WalkEncryptionTest {
                 * @throws Exception
                 */
                static String textRead(File file) throws Exception {
-                       return new String(Files.readAllBytes(file.toPath()), UTF_8);
+                       return new String(Files.readAllBytes(file.toPath()), CHARSET);
                }
 
                /**
@@ -371,7 +371,7 @@ public class WalkEncryptionTest {
                 * @throws Exception
                 */
                static void textWrite(File file, String text) throws Exception {
-                       Files.write(file.toPath(), text.getBytes(UTF_8));
+                       Files.write(file.toPath(), text.getBytes(CHARSET));
                }
 
                static void verifyFileContent(File fileOne, File fileTwo)
@@ -741,7 +741,7 @@ public class WalkEncryptionTest {
                        AmazonS3 s3 = new AmazonS3(props);
                        String file = JGIT_USER + "-" + UUID.randomUUID().toString();
                        String path = JGIT_REMOTE_DIR + "/" + file;
-                       s3.put(bucket, path, file.getBytes(UTF_8));
+                       s3.put(bucket, path, file.getBytes(CHARSET));
                        s3.delete(bucket, path);
                }
 
index e8566d243825ec8a7bc24482a7a3f5e249a98be7..a748b522155da7ab1cb5f1405f39da162cc4aafe 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.util;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
@@ -93,7 +93,7 @@ public class RawSubStringPatternTest extends RepositoryTestCase {
        }
 
        private static RawCharSequence raw(String text) {
-               byte[] bytes = text.getBytes(UTF_8);
+               byte[] bytes = text.getBytes(CHARSET);
                return new RawCharSequence(bytes, 0, bytes.length);
        }
 }
index 38199d8aaf628a547cbc8bd5a27ac7f80f0acdf1..8b955bae68d1e2deacc993087be59251c2c0f66a 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.util.io;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 
 import java.io.ByteArrayInputStream;
@@ -129,6 +129,6 @@ public class AutoLFInputStreamTest {
        }
 
        private static byte[] asBytes(String in) {
-               return in.getBytes(UTF_8);
+               return in.getBytes(CHARSET);
        }
 }
index e6045a91bd256f6471f436d89623429e59ce39fe..3c612e1bdddba2fb45aa0368d6d55b2f9757b098 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.util.sha1;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -95,15 +95,15 @@ public class SHA1Test {
                                .fromString("a9993e364706816aba3e25717850c26c9cd0d89d");
 
                MessageDigest m = MessageDigest.getInstance("SHA-1");
-               m.update(TEST1.getBytes(UTF_8));
+               m.update(TEST1.getBytes(CHARSET));
                ObjectId m1 = ObjectId.fromRaw(m.digest());
 
                SHA1 s = SHA1.newInstance();
-               s.update(TEST1.getBytes(UTF_8));
+               s.update(TEST1.getBytes(CHARSET));
                ObjectId s1 = ObjectId.fromRaw(s.digest());
 
                s.reset();
-               s.update(TEST1.getBytes(UTF_8));
+               s.update(TEST1.getBytes(CHARSET));
                ObjectId s2 = s.toObjectId();
 
                assertEquals(m1, s1);
@@ -117,15 +117,15 @@ public class SHA1Test {
                                .fromString("84983e441c3bd26ebaae4aa1f95129e5e54670f1");
 
                MessageDigest m = MessageDigest.getInstance("SHA-1");
-               m.update(TEST2.getBytes(UTF_8));
+               m.update(TEST2.getBytes(CHARSET));
                ObjectId m1 = ObjectId.fromRaw(m.digest());
 
                SHA1 s = SHA1.newInstance();
-               s.update(TEST2.getBytes(UTF_8));
+               s.update(TEST2.getBytes(CHARSET));
                ObjectId s1 = ObjectId.fromRaw(s.digest());
 
                s.reset();
-               s.update(TEST2.getBytes(UTF_8));
+               s.update(TEST2.getBytes(CHARSET));
                ObjectId s2 = s.toObjectId();
 
                assertEquals(m1, s1);
index ad43e2ca8354ca9651df6af2425c767f5f6bb99e..8a61d1b0b14c361291957a0da04db6e183ca3951 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.hooks;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -158,7 +158,7 @@ abstract class GitHook<T> implements Callable<T> {
                PrintStream hookErrRedirect = null;
                try {
                        hookErrRedirect = new PrintStream(errorByteArray, false,
-                                       UTF_8.name());
+                                       CHARSET.name());
                } catch (UnsupportedEncodingException e) {
                        // UTF-8 is guaranteed to be available
                }
@@ -167,7 +167,7 @@ abstract class GitHook<T> implements Callable<T> {
                                hookErrRedirect, getStdinArgs());
                if (result.isExecutedWithError()) {
                        throw new AbortedByHookException(
-                                       new String(errorByteArray.toByteArray(), UTF_8),
+                                       new String(errorByteArray.toByteArray(), CHARSET),
                                        getHookName(), result.getExitCode());
                }
        }
index 8793d831269fce3aaa56c9721d8474bb9d700ea0..c11f69670843f8d54be182c7043ce978506f9a65 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.dfs;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.util.Arrays;
 
@@ -67,7 +67,7 @@ public abstract class DfsStreamKey {
         */
        public static DfsStreamKey of(DfsRepositoryDescription repo, String name,
                        @Nullable PackExt ext) {
-               return new ByteArrayDfsStreamKey(repo, name.getBytes(UTF_8), ext);
+               return new ByteArrayDfsStreamKey(repo, name.getBytes(CHARSET), ext);
        }
 
        final int hash;
index bca7076aca46d1d0d22e9d7c40fbe49910eb3078..c159a947058605f1e07c073897aeeb0b98ec9d61 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.file;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -187,6 +187,6 @@ class GcLog {
                if (content.length() > 0) {
                        nonEmpty = true;
                }
-               lock.write(content.getBytes(UTF_8));
+               lock.write(content.getBytes(CHARSET));
        }
 }
index 3d0e9c71893f1ff3c4d3af71e2c7e4cb26803411..c82d52e79cf77cec95046323dc06fdcaff78c12c 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.file;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -86,7 +86,7 @@ public class LazyObjectIdSetFile implements ObjectIdSet {
        private ObjectIdOwnerMap<Entry> load() {
                ObjectIdOwnerMap<Entry> r = new ObjectIdOwnerMap<>();
                try (FileInputStream fin = new FileInputStream(src);
-                               Reader rin = new InputStreamReader(fin, UTF_8);
+                               Reader rin = new InputStreamReader(fin, CHARSET);
                                BufferedReader br = new BufferedReader(rin)) {
                        MutableObjectId id = new MutableObjectId();
                        for (String line; (line = br.readLine()) != null;) {
index ce2ba4a2e1bf19ef6c3f0f2903173ed33d742299..942d72fe231c8c2519fd7f48c322b1ba89098995 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.internal.storage.reftable.BlockWriter.compare;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_BLOCK_TYPE;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
@@ -138,7 +138,7 @@ class BlockReader {
                if (blockType == LOG_BLOCK_TYPE) {
                        len -= 9;
                }
-               return RawParseUtils.decode(UTF_8, nameBuf, 0, len);
+               return RawParseUtils.decode(CHARSET, nameBuf, 0, len);
        }
 
        boolean match(byte[] match, boolean matchIsPrefix) {
@@ -171,7 +171,7 @@ class BlockReader {
        }
 
        Ref readRef() throws IOException {
-               String name = RawParseUtils.decode(UTF_8, nameBuf, 0, nameLen);
+               String name = RawParseUtils.decode(CHARSET, nameBuf, 0, nameLen);
                switch (valueType & VALUE_TYPE_MASK) {
                case VALUE_NONE: // delete
                        return newRef(name);
@@ -266,7 +266,7 @@ class BlockReader {
        private String readValueString() {
                int len = readVarint32();
                int end = ptr + len;
-               String s = RawParseUtils.decode(UTF_8, buf, ptr, end);
+               String s = RawParseUtils.decode(CHARSET, buf, ptr, end);
                ptr = end;
                return s;
        }
index b3173e838c5856cd273fe2d601889a8b076eadb5..3d8fbf4996c7e7d6efb22b346ed900dd0759dc71 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.INDEX_BLOCK_TYPE;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.LOG_BLOCK_TYPE;
@@ -440,7 +440,7 @@ class BlockWriter {
                }
 
                private static byte[] nameUtf8(Ref ref) {
-                       return ref.getName().getBytes(UTF_8);
+                       return ref.getName().getBytes(CHARSET);
                }
        }
 
@@ -559,13 +559,13 @@ class BlockWriter {
                        this.newId = newId;
                        this.timeSecs = who.getWhen().getTime() / 1000L;
                        this.tz = (short) who.getTimeZoneOffset();
-                       this.name = who.getName().getBytes(UTF_8);
-                       this.email = who.getEmailAddress().getBytes(UTF_8);
-                       this.msg = message.getBytes(UTF_8);
+                       this.name = who.getName().getBytes(CHARSET);
+                       this.email = who.getEmailAddress().getBytes(CHARSET);
+                       this.msg = message.getBytes(CHARSET);
                }
 
                static byte[] key(String ref, long index) {
-                       byte[] name = ref.getBytes(UTF_8);
+                       byte[] name = ref.getBytes(CHARSET);
                        byte[] key = Arrays.copyOf(name, name.length + 1 + 8);
                        NB.encodeInt64(key, key.length - 8, reverseUpdateIndex(index));
                        return key;
index 1fc43c9fac17431649008d635f5699581860e757..44bbb16219dd07b054130d4c5ea2810bb1dc7aaf 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.INDEX_BLOCK_TYPE;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.LOG_BLOCK_TYPE;
@@ -160,7 +160,7 @@ class ReftableOutputStream extends OutputStream {
        }
 
        void writeVarintString(String s) {
-               writeVarintString(s.getBytes(UTF_8));
+               writeVarintString(s.getBytes(CHARSET));
        }
 
        void writeVarintString(byte[] msg) {
index 74877192f6f16c3b82cd863d4b9f31cd5f97c812..5356952b5da81eb2ce62c500ebd7e9f86d7adec7 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.internal.storage.reftable.BlockReader.decodeBlockLen;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_BLOCK_TYPE;
 import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_FOOTER_LEN;
@@ -182,7 +182,7 @@ public class ReftableReader extends Reftable {
        public RefCursor seekRef(String refName) throws IOException {
                initRefIndex();
 
-               byte[] key = refName.getBytes(UTF_8);
+               byte[] key = refName.getBytes(CHARSET);
                boolean prefix = key[key.length - 1] == '/';
 
                RefCursorImpl i = new RefCursorImpl(refEnd, key, prefix);
@@ -223,7 +223,7 @@ public class ReftableReader extends Reftable {
                initLogIndex();
                if (logPosition > 0) {
                        byte[] key = LogEntry.key(refName, updateIndex);
-                       byte[] match = refName.getBytes(UTF_8);
+                       byte[] match = refName.getBytes(CHARSET);
                        LogCursorImpl i = new LogCursorImpl(logEnd, match);
                        i.block = seek(LOG_BLOCK_TYPE, key, logIndex, logPosition, logEnd);
                        return i;
index 3ff92dc7398d505705ec4a5233dcf5540d8a057f..f44aeceb52624ecb2e854495ffc5af204f340c3c 100644 (file)
@@ -45,6 +45,8 @@
 
 package org.eclipse.jgit.lib;
 
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.text.MessageFormat;
@@ -81,8 +83,7 @@ public class BlobBasedConfig extends Config {
                super(base);
                final String decoded;
                if (isUtf8(blob)) {
-                       decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET,
-                                       blob, 3, blob.length);
+                       decoded = RawParseUtils.decode(CHARSET, blob, 3, blob.length);
                } else {
                        decoded = RawParseUtils.decode(blob);
                }
index 4d558c9fc2f5314efee53e49e72cb0c37d395fc1..285a56c87a337c738cf323954cdd88eaab04dcf4 100644 (file)
@@ -51,6 +51,8 @@
 
 package org.eclipse.jgit.lib;
 
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -1166,8 +1168,7 @@ public class Config {
 
                String decoded;
                if (isUtf8(bytes)) {
-                       decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET, bytes, 3,
-                                       bytes.length);
+                       decoded = RawParseUtils.decode(CHARSET, bytes, 3, bytes.length);
                } else {
                        decoded = RawParseUtils.decode(bytes);
                }
index 29189a9d747e73408df7a3f436feaf6c9dc9ff16..5c7cee6ca5f89f41d5be874981882b6c4135b671 100644 (file)
@@ -228,10 +228,10 @@ public final class Constants {
        public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };
 
        /** Native character encoding for commit messages, file names... */
-       public static final Charset CHARSET = UTF_8;
+       public static final Charset CHARSET;
 
        /** Native character encoding for commit messages, file names... */
-       public static final String CHARACTER_ENCODING = CHARSET.name();
+       public static final String CHARACTER_ENCODING;
 
        /** Default main branch name */
        public static final String MASTER = "master";
@@ -654,6 +654,8 @@ public final class Constants {
        static {
                if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
                        throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
+               CHARSET = UTF_8;
+               CHARACTER_ENCODING = CHARSET.name();
        }
 
        /** name of the file containing the commit msg for a merge commit */
index 06b4b227c8722fd1a065f76c83c69263c0c481e9..38716055b52ffafe414cb2b0ce2db028376e83a6 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.lib;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -183,7 +183,7 @@ public class RebaseTodoFile {
                        switch (tokenCount) {
                        case 0:
                                String actionToken = new String(buf, tokenBegin,
-                                               nextSpace - tokenBegin - 1, UTF_8);
+                                               nextSpace - tokenBegin - 1, CHARSET);
                                tokenBegin = nextSpace;
                                action = RebaseTodoLine.Action.parse(actionToken);
                                if (action == null)
@@ -192,7 +192,7 @@ public class RebaseTodoFile {
                        case 1:
                                nextSpace = RawParseUtils.next(buf, tokenBegin, ' ');
                                String commitToken = new String(buf, tokenBegin,
-                                               nextSpace - tokenBegin - 1, UTF_8);
+                                               nextSpace - tokenBegin - 1, CHARSET);
                                tokenBegin = nextSpace;
                                commit = AbbreviatedObjectId.fromString(commitToken);
                                break;
index 936ce3dcc85114bea0fdd0a3f8a3f0e324435353..2f759e53ca4ac63551488d553e57eef9f42f4a1c 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.lib;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.IOException;
 import java.io.OutputStreamWriter;
@@ -63,7 +63,7 @@ public class TextProgressMonitor extends BatchingProgressMonitor {
         * Initialize a new progress monitor.
         */
        public TextProgressMonitor() {
-               this(new PrintWriter(new OutputStreamWriter(System.err, UTF_8)));
+               this(new PrintWriter(new OutputStreamWriter(System.err, CHARSET)));
        }
 
        /**
index 9db146706f80eaf379c1305d437cd368d80b62fe..5c8371f918ba41df07681b84048d00dbc278a9c7 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.revwalk;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -539,7 +539,7 @@ public class RevCommit extends RevObject {
                try {
                        return getEncoding();
                } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
-                       return UTF_8;
+                       return CHARSET;
                }
        }
 
index d74837e860af7609efd502652bf3ed50d5bbf6aa..cbeda71a87c9dcafd800edf2fcbe1f5a622c1886 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.revwalk;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -169,7 +169,7 @@ public class RevTag extends RevObject {
 
                int p = pos.value += 4; // "tag "
                final int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
-               tagName = RawParseUtils.decode(UTF_8, rawTag, p, nameEnd);
+               tagName = RawParseUtils.decode(CHARSET, rawTag, p, nameEnd);
 
                if (walk.isRetainBody())
                        buffer = rawTag;
@@ -257,7 +257,7 @@ public class RevTag extends RevObject {
                try {
                        return RawParseUtils.parseEncoding(buffer);
                } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
-                       return UTF_8;
+                       return CHARSET;
                }
        }
 
index 9927daf3d5154af6dc0cafc3425b8d513e95f2aa..93ffb944c806e6a8acfc8a1ad02d669d3daad779 100644 (file)
@@ -49,6 +49,8 @@
 
 package org.eclipse.jgit.storage.file;
 
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -154,7 +156,7 @@ public class FileBasedConfig extends StoredConfig {
                        } else {
                                final String decoded;
                                if (isUtf8(in)) {
-                                       decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET,
+                                       decoded = RawParseUtils.decode(CHARSET,
                                                        in, 3, in.length);
                                        utf8Bom = true;
                                } else {
@@ -198,7 +200,7 @@ public class FileBasedConfig extends StoredConfig {
                        bos.write(0xEF);
                        bos.write(0xBB);
                        bos.write(0xBF);
-                       bos.write(text.getBytes(RawParseUtils.UTF8_CHARSET.name()));
+                       bos.write(text.getBytes(CHARSET));
                        out = bos.toByteArray();
                } else {
                        out = Constants.encode(text);
index d7c5b9d7f9fe8286c349a15024d9c15bf369693e..71e3d16c4794eb23e459500f3eb6a478cf9a709e 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -638,7 +638,7 @@ public class AmazonS3 {
                try {
                        final Mac m = Mac.getInstance(HMAC);
                        m.init(privateKey);
-                       sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(UTF_8)));
+                       sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(CHARSET)));
                } catch (NoSuchAlgorithmException e) {
                        throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage()));
                } catch (InvalidKeyException e) {
index 6c26b7026add7183da3ccdf55813f767206f9785..1415334c634e8070bd234ae4184c4c1d3c8f174d 100644 (file)
@@ -43,7 +43,7 @@
 package org.eclipse.jgit.transport;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.File;
 import java.security.InvalidKeyException;
@@ -102,7 +102,7 @@ public class HMACSHA1NonceGenerator implements NonceGenerator {
                }
 
                String input = path + ":" + String.valueOf(timestamp); //$NON-NLS-1$
-               byte[] rawHmac = mac.doFinal(input.getBytes(UTF_8));
+               byte[] rawHmac = mac.doFinal(input.getBytes(CHARSET));
                return Long.toString(timestamp) + "-" + toHex(rawHmac); //$NON-NLS-1$
        }
 
index c40d9635de9ac539a32c1fd2aac0663faa488ec2..de7a7dc1c7ecf5adb13e6c0a6b4199abdd83f400 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION;
 import static org.eclipse.jgit.util.HttpSupport.HDR_WWW_AUTHENTICATE;
 
@@ -315,7 +315,7 @@ abstract class HttpAuthMethod {
                @Override
                void configureRequest(final HttpConnection conn) throws IOException {
                        String ident = user + ":" + pass; //$NON-NLS-1$
-                       String enc = Base64.encodeBytes(ident.getBytes(UTF_8));
+                       String enc = Base64.encodeBytes(ident.getBytes(CHARSET));
                        conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
                                        + " " + enc); //$NON-NLS-1$
                }
@@ -430,15 +430,15 @@ abstract class HttpAuthMethod {
 
                private static String H(String data) {
                        MessageDigest md = newMD5();
-                       md.update(data.getBytes(UTF_8));
+                       md.update(data.getBytes(CHARSET));
                        return LHEX(md.digest());
                }
 
                private static String KD(String secret, String data) {
                        MessageDigest md = newMD5();
-                       md.update(secret.getBytes(UTF_8));
+                       md.update(secret.getBytes(CHARSET));
                        md.update((byte) ':');
-                       md.update(data.getBytes(UTF_8));
+                       md.update(data.getBytes(CHARSET));
                        return LHEX(md.digest());
                }
 
index 41af8078c8a1045421e14ff68c02f64082605620..2364434b0fac7b197acf36647561cc3609b3412a 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -141,7 +141,7 @@ public class ProgressSpinner {
        private void write(String s) {
                if (write) {
                        try {
-                               out.write(s.getBytes(UTF_8));
+                               out.write(s.getBytes(CHARSET));
                                out.flush();
                        } catch (IOException e) {
                                write = false;
index f9fddbe88908bc2f18f08a7030903cdf93f5848d..178c80d22e4a798b7dcb0201a0719b44801978b7 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.util.RawParseUtils.lastIndexOfTrim;
 
 import java.text.SimpleDateFormat;
@@ -95,7 +95,7 @@ public class PushCertificateIdent {
         */
        public static PushCertificateIdent parse(String str) {
                MutableInteger p = new MutableInteger();
-               byte[] raw = str.getBytes(UTF_8);
+               byte[] raw = str.getBytes(CHARSET);
                int tzBegin = raw.length - 1;
                tzBegin = lastIndexOfTrim(raw, ' ', tzBegin);
                if (tzBegin < 0 || raw[tzBegin] != ' ') {
@@ -129,7 +129,7 @@ public class PushCertificateIdent {
                                idEnd = raw.length;
                        }
                }
-               String id = new String(raw, 0, idEnd, UTF_8);
+               String id = new String(raw, 0, idEnd, CHARSET);
 
                return new PushCertificateIdent(str, id, when * 1000L, tz);
        }
index ab58a3317ae89fa756b9b6bade205d0eb1d60894..36d660234db64f0d98e8b5ed9783e292c6867d5b 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
 import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
 import static org.eclipse.jgit.lib.FileMode.TYPE_FILE;
@@ -292,7 +292,7 @@ public class PushCertificateStore implements AutoCloseable {
                ObjectLoader loader =
                                tw.getObjectReader().open(tw.getObjectId(0), OBJ_BLOB);
                try (InputStream in = loader.openStream();
-                               Reader r = new BufferedReader(new InputStreamReader(in, UTF_8))) {
+                               Reader r = new BufferedReader(new InputStreamReader(in, CHARSET))) {
                        return PushCertificateParser.fromReader(r);
                }
        }
@@ -473,7 +473,7 @@ public class PushCertificateStore implements AutoCloseable {
 
                DirCacheEditor editor = dc.editor();
                String certText = pc.cert.toText() + pc.cert.getSignature();
-               final ObjectId certId = inserter.insert(OBJ_BLOB, certText.getBytes(UTF_8));
+               final ObjectId certId = inserter.insert(OBJ_BLOB, certText.getBytes(CHARSET));
                boolean any = false;
                for (ReceiveCommand cmd : pc.cert.getCommands()) {
                        if (byRef != null && !commandsEqual(cmd, byRef.get(cmd.getRefName()))) {
index 5eb16617381515fcebf3a44896f4ec5bdb1f0392..6ad39e3ddd65a3b17302e1ffadc073765c64d161 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
 import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SYMREF;
 
@@ -74,7 +74,7 @@ import org.eclipse.jgit.util.RefMap;
 public abstract class RefAdvertiser {
        /** Advertiser which frames lines in a {@link PacketLineOut} format. */
        public static class PacketLineOutRefAdvertiser extends RefAdvertiser {
-               private final CharsetEncoder utf8 = UTF_8.newEncoder();
+               private final CharsetEncoder utf8 = CHARSET.newEncoder();
                private final PacketLineOut pckOut;
 
                private byte[] binArr = new byte[256];
index 8db796a83f2d9131a1706fc2020b008c2f660b81..ce321b014a95b4752a1cf38782684c95bb016583 100644 (file)
@@ -46,6 +46,7 @@
 
 package org.eclipse.jgit.transport;
 
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 import static org.eclipse.jgit.lib.RefDatabase.ALL;
 
 import java.io.BufferedReader;
@@ -147,7 +148,7 @@ public abstract class Transport implements AutoCloseable {
                BufferedReader br;
                try {
                        InputStream urlIn = url.openStream();
-                       br = new BufferedReader(new InputStreamReader(urlIn, "UTF-8")); //$NON-NLS-1$
+                       br = new BufferedReader(new InputStreamReader(urlIn, CHARSET));
                } catch (IOException err) {
                        // If we cannot read from the service list, go to the next.
                        //
index 0c27ced76b67943a5c63f4ecb6b0608fdf0c6ea6..442f0793fbe036380319e83e06266fdaea973cd7 100644 (file)
@@ -6,9 +6,8 @@
 
 package org.eclipse.jgit.util;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.lib.Constants.CHARSET;
 
-import java.nio.charset.StandardCharsets;
 import java.text.MessageFormat;
 import java.util.Arrays;
 
@@ -55,7 +54,7 @@ public class Base64 {
                                + "abcdefghijklmnopqrstuvwxyz" // //$NON-NLS-1$
                                + "0123456789" // //$NON-NLS-1$
                                + "+/" // //$NON-NLS-1$
-               ).getBytes(UTF_8);
+               ).getBytes(CHARSET);
 
                DEC = new byte[128];
                Arrays.fill(DEC, INVALID_DEC);
@@ -178,7 +177,7 @@ public class Base64 {
                        e += 4;
                }
 
-               return new String(outBuff, 0, e, StandardCharsets.UTF_8);
+               return new String(outBuff, 0, e, CHARSET);
        }
 
        /**
@@ -294,7 +293,7 @@ public class Base64 {
         * @return the decoded data
         */
        public static byte[] decode(String s) {
-               byte[] bytes = s.getBytes(UTF_8);
+               byte[] bytes = s.getBytes(CHARSET);
                return decode(bytes, 0, bytes.length);
        }
 }
index 64cdcc300d549526c83a0d6e966efbf612eff01c..0b0a5057ced472f97e536495c776ee135b4cd17e 100644 (file)
@@ -43,6 +43,8 @@
 
 package org.eclipse.jgit.util;
 
+import static org.eclipse.jgit.lib.Constants.CHARSET;
+
 import java.io.File;
 import java.io.PrintStream;
 import java.nio.file.Files;
@@ -124,7 +126,7 @@ public class FS_Win32_Cygwin extends FS_Win32 {
                        try {
                                w = readPipe(dir, //
                                        new String[] { cygpath, "--windows", "--absolute", pn }, // //$NON-NLS-1$ //$NON-NLS-2$
-                                       "UTF-8"); //$NON-NLS-1$
+                                       CHARSET.name());
                        } catch (CommandFailedException e) {
                                LOG.warn(e.getMessage());
                                return null;
index a5a858f85ee1ac2f87bd937bf170b5c2a19c3073..d070ed39d045a0ddeea6a936173ed5a3c288aa19 100644 (file)
@@ -44,6 +44,8 @@
 
 package org.eclipse.jgit.util;
 
+import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
+
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.ConnectException;
@@ -179,7 +181,7 @@ public class HttpSupport {
                if (key == null || key.length() == 0)
                        return;
                try {
-                       urlstr.append(URLEncoder.encode(key, "UTF-8")); //$NON-NLS-1$
+                       urlstr.append(URLEncoder.encode(key, CHARACTER_ENCODING));
                } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e);
                }