]> source.dussan.org Git - jgit.git/commitdiff
Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8 87/128587/1
authorDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 4 Sep 2018 01:53:10 +0000 (10:53 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 4 Sep 2018 01:53:10 +0000 (10:53 +0900)
Change-Id: I3b748620f067582afef20f144feebe40d0332be2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
105 files changed:
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.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/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/LongObjectIdTest.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/RebuildCommitGraph.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/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.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/attributes/CGitAttributesTest.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/CGitIgnoreTest.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/internal/storage/file/WindowCacheGetTest.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/CrissCrossMergeTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.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/NetRCTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.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/attributes/AttributesNode.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java
org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.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/file/RefDirectory.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/CommitBuilder.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/TagBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java
org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java
org.eclipse.jgit/src/org/eclipse/jgit/patch/FormatError.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/BundleFetchConnection.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.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/PacketLineIn.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineOut.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/SideBandInputStream.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/AbstractTreeIterator.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.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/FileUtils.java
org.eclipse.jgit/src/org/eclipse/jgit/util/QuotedString.java
org.eclipse.jgit/src/org/eclipse/jgit/util/io/MessageWriter.java

index 0f4633b5e33346639988e439d3b69c69f49ac300..1a9d192450d3504cc9a8aebce72170b473012f6e 100644 (file)
@@ -43,6 +43,7 @@
 
 package org.eclipse.jgit.http.server;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.http.server.ServletUtils.getRepository;
 
 import java.io.IOException;
@@ -73,7 +74,7 @@ class InfoRefsServlet extends HttpServlet {
                final Repository db = getRepository(req);
                try (OutputStreamWriter out = new OutputStreamWriter(
                                new SmartOutputStream(req, rsp, true),
-                               Constants.CHARSET)) {
+                               UTF_8)) {
                        final RefAdvertiser adv = new RefAdvertiser() {
                                @Override
                                protected void writeOne(CharSequence line)
index 42db0fecdee40880899df8b52d9b0d494736b01d..51aa5f2ba71369ecdd0ca9b09d37578b32747965 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.http.test;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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;
@@ -1081,7 +1081,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
        public void testInvalidWant() throws Exception {
                @SuppressWarnings("resource")
                ObjectId id = new ObjectInserter.Formatter().idFor(Constants.OBJ_BLOB,
-                               "testInvalidWant".getBytes(CHARSET));
+                               "testInvalidWant".getBytes(UTF_8));
 
                Repository dst = createBareRepository();
                try (Transport t = Transport.open(dst, remoteURI);
index a102da1f4995df49d432b351d380a7681ccaea54..b59b71499df8e35aa4b3319f58f0e49c12f9e1b7 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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),
-                               CHARSET)) {
+                               UTF_8)) {
                        w.write(body);
                }
        }
@@ -263,7 +263,7 @@ public abstract class JGitTestUtil {
         */
        public static String read(File file) throws IOException {
                final byte[] body = IO.readFully(file);
-               return new String(body, 0, body.length, CHARSET);
+               return new String(body, 0, body.length, UTF_8);
        }
 
        /**
index 6cdd0eb23c92a17ac4f296c71d54a5b1ae5ccf81..12b216950008d59dfa944e7a7c6116e3b3c4e9ce 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(), CHARSET));
+                                                               Constants.OBJ_BLOB).getCachedBytes(), UTF_8));
                        }
                        if (0 != (includedOptions & ASSUME_UNCHANGED))
                                sb.append(", assume-unchanged:"
index e983e5dfb62acf2b19441c89c0f67667690db23c..95fe18b83c76870922d5f457756c483d77aaf289 100644 (file)
@@ -46,7 +46,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 
 import java.io.File;
@@ -192,7 +192,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
        protected static void checkFile(File f, String checkData)
                        throws IOException {
                try (Reader r = new InputStreamReader(new FileInputStream(f),
-                               CHARSET)) {
+                               UTF_8)) {
                        if (checkData.length() > 0) {
                                char[] data = new char[checkData.length()];
                                assertEquals(data.length, r.read(data));
index 49715e559635c5a5e15593b7b9756d3dc2fea8dc..c9fa2f506c38f135cddbf363653f3ddf195f9048 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(String content) throws Exception {
-               return blob(content.getBytes(CHARSET));
+               return blob(content.getBytes(UTF_8));
        }
 
        /**
index 50a06f94d68199d8ebad1ee782860122f3359364..10823b878845359a0467cd8ea54ef2bd2efcd8b8 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs.server.fs;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(),
-                                                       CHARSET);
+                                                       UTF_8);
                                } else {
                                        final byte[] b = new byte[buf.remaining()];
                                        buf.duplicate().get(b);
-                                       error = new String(b, CHARSET);
+                                       error = new String(b, UTF_8);
                                }
                        } catch (IOException e) {
                                error = statusLine.getReasonPhrase();
index d22d45967edfb5a60d002c109b7de6d1862f29cd..c7f55dd3c1daa49da2ac19efae22f0b5207d1d72 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs.server;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(), CHARSET));
+                               new OutputStreamWriter(res.getOutputStream(), UTF_8));
 
                Reader r = new BufferedReader(
-                               new InputStreamReader(req.getInputStream(), CHARSET));
+                               new InputStreamReader(req.getInputStream(), UTF_8));
                LfsRequest request = LfsGson.fromJson(r, LfsRequest.class);
                String path = req.getPathInfo();
 
index 374a560581a4557cedced0b8d1369ceec423fede..b21c94e4e6488640fba293ca952f216962a653fc 100644 (file)
@@ -43,7 +43,7 @@
  */
 package org.eclipse.jgit.lfs.server.s3;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+               md.update(s.getBytes(UTF_8));
                return md.digest();
        }
 
        private static byte[] sign(String stringData, byte[] key) {
                try {
-                       byte[] data = stringData.getBytes(CHARSET);
+                       byte[] data = stringData.getBytes(UTF_8);
                        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, CHARSET.name());
+                       encoded = URLEncoder.encode(url, UTF_8.name());
                } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(LfsServerText.get().unsupportedUtf8, e);
                }
index e3c6ef80bc43386ccd3a40e1e0d186f895074d2d..c3c38594675bf10c9d79531e68393047483b6230 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs.test;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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(CHARSET));
+               md.update(s.getBytes(UTF_8));
                return LongObjectId.fromRaw(md.digest());
        }
 
index 8642e7eb3b24c2a2b145fb6a8b4fdc26df4e00db..92a8176f577773f81660455b9f51079f585c39f6 100644 (file)
@@ -43,6 +43,7 @@
 
 package org.eclipse.jgit.lfs.lib;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.nio.charset.StandardCharsets.US_ASCII;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -62,7 +63,6 @@ import java.util.Locale;
 import org.eclipse.jgit.junit.JGitTestUtil;
 import org.eclipse.jgit.lfs.errors.InvalidLongObjectIdException;
 import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.util.FileUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -393,7 +393,7 @@ public class LongObjectIdTest {
                AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
                ByteArrayOutputStream os = new ByteArrayOutputStream(64);
                try (OutputStreamWriter w = new OutputStreamWriter(os,
-                               Constants.CHARSET)) {
+                               UTF_8)) {
                        id1.copyTo(w);
                }
                assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
@@ -404,7 +404,7 @@ public class LongObjectIdTest {
                AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
                ByteArrayOutputStream os = new ByteArrayOutputStream(64);
                try (OutputStreamWriter w = new OutputStreamWriter(os,
-                               Constants.CHARSET)) {
+                               UTF_8)) {
                        char[] buf = new char[64];
                        id1.copyTo(buf, w);
                }
index 4f959409fca50da199a87f7206aa568bba226085..0e3830c098f0b525952b8a92db77a6239eaf0fb8 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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,
-                               CHARSET.name())) {
+                               UTF_8.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(CHARSET.name());
+                       throw new UnsupportedCharsetException(UTF_8.name());
                }
        }
 
@@ -165,7 +165,7 @@ public class LfsPointer implements Comparable<LfsPointer> {
                long sz = -1;
 
                try (BufferedReader br = new BufferedReader(
-                               new InputStreamReader(in, CHARSET))) {
+                               new InputStreamReader(in, UTF_8))) {
                        for (String s = br.readLine(); s != null; s = br.readLine()) {
                                if (s.startsWith("#") || s.length() == 0) { //$NON-NLS-1$
                                        continue;
index 4da3a74f2faed967cdbf10622ab2208d19450298..3e6a26159b0e4cdbbb24f1347ea5380d9523e0e2 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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;
@@ -208,7 +208,7 @@ public class LfsPrePushHook extends PrePushHook {
                }
                Gson gson = Protocol.gson();
                api.getOutputStream().write(
-                               gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(CHARSET));
+                               gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(UTF_8));
                int responseCode = api.getResponseCode();
                if (responseCode != HTTP_OK) {
                        throw new IOException(
@@ -221,7 +221,7 @@ public class LfsPrePushHook extends PrePushHook {
        private void uploadContents(HttpConnection api,
                        Map<String, LfsPointer> oid2ptr) throws IOException {
                try (JsonReader reader = new JsonReader(
-                               new InputStreamReader(api.getInputStream(), CHARSET))) {
+                               new InputStreamReader(api.getInputStream(), UTF_8))) {
                        for (Protocol.ObjectInfo o : parseObjects(reader)) {
                                if (o.actions == null) {
                                        continue;
index 6a758cfd44b8bece20b0d2252e6f35841b273b8d..fac87c177ed430b1541c9057584a49e945b09e31 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.lfs;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -170,7 +170,7 @@ public class SmudgeFilter extends FilterCommand {
                                .write(gson
                                                .toJson(LfsConnectionFactory
                                                                .toRequest(Protocol.OPERATION_DOWNLOAD, res))
-                                               .getBytes(CHARSET));
+                                               .getBytes(UTF_8));
                int responseCode = lfsServerConn.getResponseCode();
                if (responseCode != HttpConnection.HTTP_OK) {
                        throw new IOException(
@@ -180,7 +180,7 @@ public class SmudgeFilter extends FilterCommand {
                }
                try (JsonReader reader = new JsonReader(
                                new InputStreamReader(lfsServerConn.getInputStream(),
-                                               CHARSET))) {
+                                               UTF_8))) {
                        Protocol.Response resp = gson.fromJson(reader,
                                        Protocol.Response.class);
                        for (Protocol.ObjectInfo o : resp.objects) {
index ecc00d37f5fa66f3e917ba4e20ecdc0454b16948..47eb156c550c25736a7a23cce709e3bf8cd19170 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.pgm;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(), CHARSET));
+                               new InputStreamReader(proc.getInputStream(), UTF_8));
        }
 
        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, CHARSET));
+                                       new InputStreamReader(in, UTF_8));
                        String line;
                        while ((line = reader.readLine()) != null)
                                l.add(line);
index 2b0e5a717d7be5e9146b0bd3ba1135395a559592..dbdccc10e2fa0c78fc0b12c5e7f422a84710f0ab 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.pgm;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -148,7 +148,7 @@ public class CommandCatalog {
 
        private void scan(URL cUrl) {
                try (BufferedReader cIn = new BufferedReader(
-                               new InputStreamReader(cUrl.openStream(), CHARSET))) {
+                               new InputStreamReader(cUrl.openStream(), UTF_8))) {
                        String line;
                        while ((line = cIn.readLine()) != null) {
                                if (line.length() > 0 && !line.startsWith("#")) //$NON-NLS-1$
index 6fa92d3b0be883bcf463229988e880a9ecdf55da..5ed286baa9b57890f1db2a72c04732628cdfc4ac 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.pgm;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.File;
 import java.io.IOException;
@@ -227,7 +227,7 @@ public class Main {
        }
 
        PrintWriter createErrorWriter() {
-               return new PrintWriter(new OutputStreamWriter(System.err, CHARSET));
+               return new PrintWriter(new OutputStreamWriter(System.err, UTF_8));
        }
 
        private void execute(String[] argv) throws Exception {
index 575a12215870bd1df8bf6707707c53e0420db93f..248eaac8ad22039a52d79f362b65bfcb5ed5859d 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.pgm.debug;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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), CHARSET))) {
+                               new FileInputStream(lsRemotePath), UTF_8))) {
                        Ref last = null;
                        String line;
                        while ((line = br.readLine()) != null) {
index 2d16fefa711f8e3eff3149efda96ff5c546e65f1..8948c27537c51ca371d109b11193ae231015a679 100644 (file)
@@ -43,6 +43,8 @@
 
 package org.eclipse.jgit.pgm.debug;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -141,7 +143,7 @@ class RebuildCommitGraph extends TextBuiltin {
                try (RevWalk rw = new RevWalk(db);
                                final BufferedReader br = new BufferedReader(
                                                new InputStreamReader(new FileInputStream(graph),
-                                                               Constants.CHARSET))) {
+                                                               UTF_8))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                final String[] parts = line.split("[ \t]{1,}"); //$NON-NLS-1$
@@ -280,7 +282,7 @@ class RebuildCommitGraph extends TextBuiltin {
                try (RevWalk rw = new RevWalk(db);
                                BufferedReader br = new BufferedReader(
                                                new InputStreamReader(new FileInputStream(refList),
-                                                               Constants.CHARSET))) {
+                                                               UTF_8))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                final String[] parts = line.split("[ \t]{1,}"); //$NON-NLS-1$
index c5ea028be8160ece13f390410f945843628f74c5..6cbc1b082bb7868ffb598ee06332755f8026bdb2 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.pgm.debug;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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), CHARSET))) {
+                               new InputStreamReader(new FileInputStream(inputFile), UTF_8))) {
                        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), CHARSET))) {
+                               new InputStreamReader(new FileInputStream(logPath), UTF_8))) {
                        @SuppressWarnings("nls")
                        Pattern pattern = Pattern.compile("([^,]+)" // 1: ref
                                        + ",([0-9]+(?:[.][0-9]+)?)" // 2: time
index 4d9e864227e26761042c489db16ead5c4aa6a341..438d2d625b2aadb4d4a3637815504f7d6a4725fb 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.ignore;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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(CHARSET), StandardOpenOption.CREATE,
+                                       (pattern + "\n").getBytes(UTF_8), 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(CHARSET));
+                               out.write((path + "\n").getBytes(UTF_8));
                                out.flush();
                        }
                        return proc;
index 79d8d0e10b0002083f7512f93d555eca6b2873f6..f597f2fe3c3722bcaf4c7d1ab4f45ada90d9831e 100644 (file)
@@ -44,6 +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.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -56,7 +57,6 @@ import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.HashSet;
 
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.util.MutableInteger;
 import org.eclipse.jgit.util.RawParseUtils;
 import org.eclipse.jgit.util.TemporaryBuffer;
@@ -176,7 +176,7 @@ public class EGitPatchHistoryTest {
                                i.added = RawParseUtils.parseBase10(buf, ptr.value, ptr);
                                i.deleted = RawParseUtils.parseBase10(buf, ptr.value + 1, ptr);
                                final int eol = RawParseUtils.nextLF(buf, ptr.value);
-                               final String name = RawParseUtils.decode(Constants.CHARSET,
+                               final String name = RawParseUtils.decode(UTF_8,
                                                buf, ptr.value + 1, eol - 1);
                                files.put(name, i);
                                ptr.value = eol;
index bb303cc4115246467fdbd7d64c5c5ccbc0a305be..1e3a39aad82b301a12d2e7069a777322443557ea 100644 (file)
@@ -42,7 +42,7 @@
 
 package org.eclipse.jgit.api;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET);
-               byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
+               byte[] outputBytes = output.getBytes(UTF_8);
+               byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
 
                // 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(CHARSET);
-               byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
+               byte[] inputBytes = input.getBytes(UTF_8);
+               byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
 
                // test using input text and assuming it was declared TEXT
                try (InputStream in = EolStreamTypeUtil.wrapInputStream(
index e234aa339c2be2c943a0d921b1393d770daac5e4..6e06e9545a9c2be264dedc908bdb1665b90bec2f 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(),
-                               CHARSET);
+                               UTF_8);
                assertEquals(content, "data");
 
                git.notesRemove().setObjectId(commit2).call();
index 0b0e3bf3ea6536105bda282388acbc2f613b2084..9461c42500431683fc7d0e86c60fd8f07ed2b393 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+                       fos.write(string.getBytes(UTF_8));
                }
        }
 
@@ -606,7 +606,7 @@ public class PullCommandTest extends RepositoryTestCase {
                                bos.write(buffer, 0, read);
                                read = fis.read(buffer);
                        }
-                       String content = new String(bos.toByteArray(), CHARSET);
+                       String content = new String(bos.toByteArray(), UTF_8);
                        assertEquals(string, content);
                }
        }
index b349c66cabbbb75ccca374c6d025aebed860b99e..913b4ac434a99095cf7e71bbbebff32da1728fca 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+                       fos.write(string.getBytes(UTF_8));
                }
        }
 
@@ -410,7 +410,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
                                bos.write(buffer, 0, read);
                                read = fis.read(buffer);
                        }
-                       String content = new String(bos.toByteArray(), CHARSET);
+                       String content = new String(bos.toByteArray(), UTF_8);
                        assertEquals(string, content);
                }
        }
index 621e061c7912b31e9bdf59a9abf2e9fe9953e80d..4401bcedb37366e17ec8d573ea01715e36172b75 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.api;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -1468,7 +1468,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
                assertEquals("GIT_AUTHOR_DATE='@123456789 -0100'", lines[2]);
 
                PersonIdent parsedIdent = git.rebase().parseAuthor(
-                               convertedAuthor.getBytes(CHARSET));
+                               convertedAuthor.getBytes(UTF_8));
                assertEquals(ident.getName(), parsedIdent.getName());
                assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
                // this is rounded to the last second
@@ -1485,7 +1485,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
                assertEquals("GIT_AUTHOR_DATE='@123456789 +0930'", lines[2]);
 
                parsedIdent = git.rebase().parseAuthor(
-                               convertedAuthor.getBytes(CHARSET));
+                               convertedAuthor.getBytes(UTF_8));
                assertEquals(ident.getName(), parsedIdent.getName());
                assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
                assertEquals(123456789000L, parsedIdent.getWhen().getTime());
@@ -2164,7 +2164,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
                int count = 0;
                File todoFile = getTodoFile();
                try (BufferedReader br = new BufferedReader(new InputStreamReader(
-                               new FileInputStream(todoFile), CHARSET))) {
+                               new FileInputStream(todoFile), UTF_8))) {
                        String line = br.readLine();
                        while (line != null) {
                                int firstBlank = line.indexOf(' ');
index 344d1af6a0e8247733629c2e3c61cb7af5d9dff8..b6615075c0139e9d1a91656d3ebeb23a67ec275d 100644 (file)
@@ -42,6 +42,7 @@
  */
 package org.eclipse.jgit.attributes;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
@@ -57,7 +58,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.eclipse.jgit.junit.RepositoryTestCase;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.StoredConfig;
 import org.eclipse.jgit.treewalk.FileTreeIterator;
 import org.eclipse.jgit.treewalk.TreeWalk;
@@ -127,14 +127,14 @@ public class CGitAttributesTest extends RepositoryTestCase {
                builder.directory(db.getWorkTree());
                builder.environment().put("HOME", fs.userHome().getAbsolutePath());
                ExecutionResult result = fs.execute(builder, new ByteArrayInputStream(
-                               input.toString().getBytes(Constants.CHARSET)));
+                               input.toString().getBytes(UTF_8)));
                String errorOut = toString(result.getStderr());
                assertEquals("External git failed", "exit 0\n",
                                "exit " + result.getRc() + '\n' + errorOut);
                LinkedHashMap<String, Attributes> map = new LinkedHashMap<>();
                try (BufferedReader r = new BufferedReader(new InputStreamReader(
                                new BufferedInputStream(result.getStdout().openInputStream()),
-                               Constants.CHARSET))) {
+                               UTF_8))) {
                        r.lines().forEach(line -> {
                                // Parse the line and add to result map
                                int start = 0;
index 32f34213ecdb0afbef91add01be412ece8039941..0f13a68b256c870a6063921cc8686feec66e4bac 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.diff;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+               return new RawText(r.toString().getBytes(UTF_8));
        }
 }
index 58a8b2d468d05805b483fe9318f718d124eb7d7c..5885d9b7e6616e5490ba6fe46c15bd9c767aa7d9 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.diff;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -147,8 +147,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(CHARSET));
-               RawText b = new RawText("p\na  b \nR\n c  d \n".getBytes(CHARSET));
+               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));
                e = new Edit(0, 4, 0, 4);
                e = RawTextComparator.WS_IGNORE_ALL.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(2, 3, 2, 3), e);
@@ -160,14 +160,14 @@ public class RawTextTest {
                RawText b;
                Edit e;
 
-               a = new RawText("R\n y\n".getBytes(CHARSET));
-               b = new RawText("S\n\n y\n".getBytes(CHARSET));
+               a = new RawText("R\n y\n".getBytes(UTF_8));
+               b = new RawText("S\n\n y\n".getBytes(UTF_8));
                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(CHARSET));
-               b = new RawText("R\n y\n".getBytes(CHARSET));
+               a = new RawText("S\n\n y\n".getBytes(UTF_8));
+               b = new RawText("R\n y\n".getBytes(UTF_8));
                e = new Edit(0, 3, 0, 2);
                e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(0, 2, 0, 1), e);
@@ -178,8 +178,8 @@ public class RawTextTest {
                RawText a;
                RawText b;
                Edit e;
-               a = new RawText("start".getBytes(CHARSET));
-               b = new RawText("start of line".getBytes(CHARSET));
+               a = new RawText("start".getBytes(UTF_8));
+               b = new RawText("start of line".getBytes(UTF_8));
                e = new Edit(0, 1, 0, 1);
                e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(0, 1, 0, 1), e);
@@ -190,8 +190,8 @@ public class RawTextTest {
                RawText a;
                RawText b;
                Edit e;
-               a = new RawText("start".getBytes(CHARSET));
-               b = new RawText("start of\nlastline".getBytes(CHARSET));
+               a = new RawText("start".getBytes(UTF_8));
+               b = new RawText("start of\nlastline".getBytes(UTF_8));
                e = new Edit(0, 1, 0, 2);
                e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
                assertEquals(new Edit(0, 1, 0, 2), e);
@@ -250,6 +250,6 @@ public class RawTextTest {
                        r.append(text.charAt(i));
                        r.append('\n');
                }
-               return new RawText(r.toString().getBytes(CHARSET));
+               return new RawText(r.toString().getBytes(UTF_8));
        }
 }
index 51a6f8121c2650d420ec558ed9f1e11c6e177a4b..f168e832846e7c02b87309ac1d21ea8042ebd212 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.diff;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET);
+                               + "B\n").getBytes(UTF_8);
                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(CHARSET);
+               byte[] bytes1 = text.getBytes(UTF_8);
                src.hash(new ByteArrayInputStream(bytes1), bytes1.length, true);
                src.sort();
 
                SimilarityIndex dst = new SimilarityIndex();
-               byte[] bytes2 = text.replace("\r", "").getBytes(CHARSET);
+               byte[] bytes2 = text.replace("\r", "").getBytes(UTF_8);
                dst.hash(new ByteArrayInputStream(bytes2), bytes2.length, true);
                dst.sort();
 
index c362e7497c2a42e307f3cdb6befa6b75c626eb9c..847d0abad45ef5fd188fcf77ed71803377cdda5a 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.dircache;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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")), CHARSET))) {
+                               new FileInputStream(pathOf("gitgit.lsfiles")), UTF_8))) {
                        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")), CHARSET))) {
+                               new FileInputStream(pathOf("gitgit.lstree")), UTF_8))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                final CGitLsTreeRecord cr = new CGitLsTreeRecord(line);
index 024f05480743598acb05bfe3d4e307c923cd77e4..88a077630ef6236f6c4dc2aa383122c43624c41e 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.gitrepo;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -85,7 +85,7 @@ public class ManifestParserTest {
 
                ManifestParser parser = new ManifestParser(
                                null, null, "master", baseUrl, null, null);
-               parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)));
+               parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)));
                // Unfiltered projects should have them all.
                results.clear();
                results.add("foo");
@@ -139,7 +139,7 @@ public class ManifestParserTest {
                                baseUrl, null, null);
                try {
                        parser.read(new ByteArrayInputStream(
-                                       xmlContent.toString().getBytes(CHARSET)));
+                                       xmlContent.toString().getBytes(UTF_8)));
                        fail("ManifestParser did not throw exception for missing fetch");
                } catch (IOException e) {
                        assertTrue(e.getCause() instanceof SAXException);
@@ -164,7 +164,7 @@ public class ManifestParserTest {
                ManifestParser parser = new ManifestParser(null, null, "master",
                                "https://git.google.com/", null, null);
                parser.read(new ByteArrayInputStream(
-                               xmlContent.toString().getBytes(CHARSET)));
+                               xmlContent.toString().getBytes(UTF_8)));
 
                assertEquals(Stream.of("bar", "baz").collect(Collectors.toSet()),
                                parser.getProjects().stream().map(RepoProject::getName)
index 1eca587bfbe6bfc383a5699adc25048ecaa02ab9..92f0cf619662d1fb021f4514d630a248885d258a 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.gitrepo;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -217,7 +217,7 @@ public class RepoCommandTest extends RepositoryTestCase {
 
                        RevCommit commit = cmd
                                        .setInputStream(new ByteArrayInputStream(
-                                                       xmlContent.toString().getBytes(CHARSET)))
+                                                       xmlContent.toString().getBytes(UTF_8)))
                                        .setRemoteReader(repos).setURI("platform/")
                                        .setTargetURI("platform/superproject")
                                        .setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
@@ -226,7 +226,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                        String firstIdStr = commit.getId().name() + ":" + ".gitmodules";
                        commit = new RepoCommand(dest)
                                        .setInputStream(new ByteArrayInputStream(
-                                                       xmlContent.toString().getBytes(CHARSET)))
+                                                       xmlContent.toString().getBytes(UTF_8)))
                                        .setRemoteReader(repos).setURI("platform/")
                                        .setTargetURI("platform/superproject")
                                        .setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
@@ -254,7 +254,7 @@ public class RepoCommandTest extends RepositoryTestCase {
 
                        RevCommit commit = cmd
                                        .setInputStream(new ByteArrayInputStream(
-                                                       xmlContent.toString().getBytes(CHARSET)))
+                                                       xmlContent.toString().getBytes(UTF_8)))
                                        .setRemoteReader(repos).setURI("platform/")
                                        .setTargetURI("platform/superproject")
                                        .setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
@@ -288,7 +288,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                try (Repository dest = cloneRepository(db, true)) {
                        RevCommit commit = new RepoCommand(dest)
                                        .setInputStream(new ByteArrayInputStream(
-                                                       xmlContent.toString().getBytes(CHARSET)))
+                                                       xmlContent.toString().getBytes(UTF_8)))
                                        .setRemoteReader(new IndexedRepos()).setURI("platform/")
                                        .setTargetURI("platform/superproject")
                                        .setRecordRemoteBranch(true).setIgnoreRemoteFailures(true)
@@ -327,7 +327,7 @@ public class RepoCommandTest extends RepositoryTestCase {
 
                        RevCommit commit = cmd
                                        .setInputStream(new ByteArrayInputStream(
-                                                       xmlContent.toString().getBytes(CHARSET)))
+                                                       xmlContent.toString().getBytes(UTF_8)))
                                        .setRemoteReader(repos).setURI("").setTargetURI("gerrit")
                                        .setRecordRemoteBranch(true).setRecordSubmoduleLabels(true)
                                        .call();
@@ -376,7 +376,7 @@ public class RepoCommandTest extends RepositoryTestCase {
 
                                        RevCommit commit = cmd
                                                        .setInputStream(new ByteArrayInputStream(
-                                                                       xmlContent.toString().getBytes(CHARSET)))
+                                                                       xmlContent.toString().getBytes(UTF_8)))
                                                        .setRemoteReader(repos).setURI(baseUrl)
                                                        .setTargetURI("gerrit").setRecordRemoteBranch(true)
                                                        .setRecordSubmoduleLabels(true).call();
@@ -431,7 +431,7 @@ public class RepoCommandTest extends RepositoryTestCase {
 
                                        RevCommit commit = cmd
                                                        .setInputStream(new ByteArrayInputStream(
-                                                                       xmlContent.toString().getBytes(CHARSET)))
+                                                                       xmlContent.toString().getBytes(UTF_8)))
                                                        .setRemoteReader(repos).setURI(baseUrl)
                                                        .setTargetURI(abs + "/superproject")
                                                        .setRecordRemoteBranch(true)
index 0c6ed0c19eb020b948141a7f1c83e22b2c0ebfec..b4c20a7e4ca3001c2679041ec9ffc30da36c61dc 100644 (file)
@@ -42,6 +42,7 @@
  */
 package org.eclipse.jgit.ignore;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -56,7 +57,6 @@ import java.util.LinkedHashSet;
 import java.util.Set;
 
 import org.eclipse.jgit.junit.RepositoryTestCase;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.StoredConfig;
 import org.eclipse.jgit.treewalk.FileTreeIterator;
 import org.eclipse.jgit.treewalk.TreeWalk;
@@ -113,7 +113,7 @@ public class CGitIgnoreTest extends RepositoryTestCase {
                                "exit " + result.getRc() + '\n' + errorOut);
                try (BufferedReader r = new BufferedReader(new InputStreamReader(
                                new BufferedInputStream(result.getStdout().openInputStream()),
-                               Constants.CHARSET))) {
+                               UTF_8))) {
                        return r.lines().toArray(String[]::new);
                }
        }
@@ -131,7 +131,7 @@ public class CGitIgnoreTest extends RepositoryTestCase {
                                "exit " + result.getRc() + '\n' + errorOut);
                try (BufferedReader r = new BufferedReader(new InputStreamReader(
                                new BufferedInputStream(result.getStdout().openInputStream()),
-                               Constants.CHARSET))) {
+                               UTF_8))) {
                        return r.lines().toArray(String[]::new);
                }
        }
index 78d9a82c24cb1d0dc3e48899685f97a6e7dd2fbf..cbc07614636c2f377ca8645d830328f12f6b01be 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.ignore;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.junit.Assert.assertEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -767,6 +767,6 @@ public class IgnoreNodeTest extends RepositoryTestCase {
                for (String line : rules) {
                        data.append(line + "\n");
                }
-               return new ByteArrayInputStream(data.toString().getBytes(CHARSET));
+               return new ByteArrayInputStream(data.toString().getBytes(UTF_8));
        }
 }
index 2a99da0c1e29486ea3ce2b25f5302b5be84d2491..7e513d2c39e604024952d2ead1989a6955cc7642 100644 (file)
@@ -41,7 +41,7 @@
  */
 package org.eclipse.jgit.indexdiff;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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, CHARSET)) {
+                               Writer writer = new OutputStreamWriter(out, UTF_8)) {
                        writer.write("echo `which git` 1>&2\n");
                        writer.write("echo `git --version` 1>&2\n");
                        writer.write("git init " + name + " && \\\n");
@@ -170,7 +170,7 @@ public class IndexDiffWithSymlinkTest extends LocalDiskRepositoryTestCase {
 
        private String readStream(InputStream stream) throws IOException {
                try (BufferedReader in = new BufferedReader(
-                               new InputStreamReader(stream, CHARSET))) {
+                               new InputStreamReader(stream, UTF_8))) {
                        StringBuilder out = new StringBuilder();
                        String line;
                        while ((line = in.readLine()) != null) {
index e1adeedc546c77372850ca03290b0923a8a5ad63..3a435641800d71a766608c9fc86eb53fe780d7d2 100644 (file)
@@ -46,7 +46,7 @@
 package org.eclipse.jgit.internal.storage.file;
 
 import static org.eclipse.jgit.junit.Assert.assertEquals;
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.Constants.LOCK_SUFFIX;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -263,7 +263,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
 
                ObjectId blobId;
                try (ObjectInserter ins = bareRepo.newObjectInserter()) {
-                       blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(CHARSET));
+                       blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(UTF_8));
                        ins.flush();
                }
 
index e113db12acc654216e85bcc3fa31e5d19b4ec0f4..02073226d0db3a1082bb12f8ac45b368154d2886 100644 (file)
@@ -47,7 +47,7 @@
 package org.eclipse.jgit.internal.storage.file;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -368,7 +368,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                                + "  email = A U Thor <thor@example.com> # Just an example...\n"
                                + " name = \"A  Thor \\\\ \\\"\\t \"\n"
                                + "    defaultCheckInComment = a many line\\ncomment\\n to test\n";
-               assertEquals(expectedStr, new String(IO.readFully(cfg), Constants.CHARSET));
+               assertEquals(expectedStr, new String(IO.readFully(cfg), UTF_8));
        }
 
        @Test
@@ -517,7 +517,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                                4294967295000L, 60));
                commit.setCommitter(new PersonIdent("Joe Hacker", "joe2@example.com",
                                4294967295000L, 60));
-               commit.setEncoding(CHARSET);
+               commit.setEncoding(UTF_8);
                commit.setMessage("\u00dcbergeeks");
                ObjectId cid = insertCommit(commit);
                assertEquals("4680908112778718f37e686cbebcc912730b3154", cid.name());
@@ -559,7 +559,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                final ObjectId treeId;
                try (ObjectInserter oi = db.newObjectInserter()) {
                        final ObjectId blobId = oi.insert(Constants.OBJ_BLOB,
-                                       "and this is the data in me\n".getBytes(Constants.CHARSET
+                                       "and this is the data in me\n".getBytes(UTF_8
                                                        .name()));
                        TreeFormatter fmt = new TreeFormatter();
                        fmt.append("i-am-a-file", FileMode.REGULAR_FILE, blobId);
@@ -666,9 +666,9 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
                ObjectId id2;
                try (ObjectInserter ins = db.newObjectInserter()) {
                        id1 = ins.insert(
-                                       Constants.OBJ_BLOB, "contents1".getBytes(Constants.CHARSET));
+                                       Constants.OBJ_BLOB, "contents1".getBytes(UTF_8));
                        id2 = ins.insert(
-                                       Constants.OBJ_BLOB, "contents2".getBytes(Constants.CHARSET));
+                                       Constants.OBJ_BLOB, "contents2".getBytes(UTF_8));
                        ins.flush();
                }
 
index 82ad28ed217d2511e829c0b3a5fce040dffa0a2c..01426eeb8cfe8a709285872580b8deac7b9b6716 100644 (file)
@@ -43,6 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.file;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -77,7 +78,7 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase {
                try (BufferedReader br = new BufferedReader(new InputStreamReader(
                                new FileInputStream(JGitTestUtil
                                                .getTestResourceFile("all_packed_objects.txt")),
-                               Constants.CHARSET))) {
+                               UTF_8))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                final String[] parts = line.split(" {1,}");
index 965899e7a088402a928b109f12a12a58d6527864..b7027f3272954e933719fdc2cccff35574b1f7de 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.junit;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(), CHARSET);
+               return new String(loader.getCachedBytes(), UTF_8);
        }
 }
index b8e8a12d53ff49bc8209a21585a723f45289636a..7ea504374c1e378b043ba2aee4446a7ff066ee39 100644 (file)
@@ -45,7 +45,7 @@
 package org.eclipse.jgit.lib;
 
 import static java.lang.Integer.valueOf;
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET);
+               byte[] data = b.toString().getBytes(UTF_8);
                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(CHARSET);
+               byte[] data = b.toString().getBytes(UTF_8);
                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(CHARSET);
+               byte[] data = b.toString().getBytes(UTF_8);
                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(CHARSET));
+               checker.checkTree(b.toString().getBytes(UTF_8));
        }
 
        @Test
index 974750df4609430eba3cfef06f6dba3e07db4c05..a67c750dbac5eea507a8d1604d312503f12dcb12 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.merge;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -883,7 +883,7 @@ public class CrissCrossMergeTest extends RepositoryTestCase {
                StringBuilder result = new StringBuilder();
                ObjectReader or = r.newObjectReader();
                try (BufferedReader br = new BufferedReader(
-                               new InputStreamReader(or.open(blobId).openStream(), CHARSET))) {
+                               new InputStreamReader(or.open(blobId).openStream(), UTF_8))) {
                        String line;
                        boolean first = true;
                        while ((line = br.readLine()) != null) {
index da4513d1f7ee61c7903789cca23a089e8c5c2955..8f12dd7b275d2181e4c7d5a0033ec405e10955b7 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.merge;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -793,7 +793,7 @@ public class MergerTest extends RepositoryTestCase {
                }
                binary[50] = '\0';
 
-               writeTrashFile("file", new String(binary, CHARSET));
+               writeTrashFile("file", new String(binary, UTF_8));
                git.add().addFilepattern("file").call();
                RevCommit first = git.commit().setMessage("added file").call();
 
@@ -801,7 +801,7 @@ public class MergerTest extends RepositoryTestCase {
                int idx = LINELEN * 1200 + 1;
                byte save = binary[idx];
                binary[idx] = '@';
-               writeTrashFile("file", new String(binary, CHARSET));
+               writeTrashFile("file", new String(binary, UTF_8));
 
                binary[idx] = save;
                git.add().addFilepattern("file").call();
@@ -810,7 +810,7 @@ public class MergerTest extends RepositoryTestCase {
 
                git.checkout().setCreateBranch(true).setStartPoint(first).setName("side").call();
                binary[LINELEN * 1500 + 1] = '!';
-               writeTrashFile("file", new String(binary, CHARSET));
+               writeTrashFile("file", new String(binary, UTF_8));
                git.add().addFilepattern("file").call();
                RevCommit sideCommit = git.commit().setAll(true)
                        .setMessage("modified file l 1500").call();
@@ -972,7 +972,7 @@ public class MergerTest extends RepositoryTestCase {
                        merger.getMergeResults().get("file");
                        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
                                fmt.formatMerge(out, merger.getMergeResults().get("file"),
-                                               "BASE", "OURS", "THEIRS", CHARSET.name());
+                                               "BASE", "OURS", "THEIRS", UTF_8.name());
                                String expected = "<<<<<<< OURS\n"
                                                + "1master\n"
                                                + "=======\n"
@@ -980,7 +980,7 @@ public class MergerTest extends RepositoryTestCase {
                                                + ">>>>>>> THEIRS\n"
                                                + "2\n"
                                                + "3";
-                               assertEquals(expected, new String(out.toByteArray(), CHARSET));
+                               assertEquals(expected, new String(out.toByteArray(), UTF_8));
                        }
                }
        }
@@ -1367,6 +1367,7 @@ public class MergerTest extends RepositoryTestCase {
                if (obj == null) {
                        return null;
                }
-               return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), CHARSET);
+               return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(),
+                               UTF_8);
        }
 }
index 7b5868a393c918a20e7c22cb8d95f3a498af1f9b..e383f36bcab04758625bc5b986e3f2f576cf3d6b 100644 (file)
@@ -44,7 +44,7 @@
 package org.eclipse.jgit.patch;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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 = CHARSET;
+               final Charset csNew = UTF_8;
                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 = CHARSET;
+               final Charset csNew = UTF_8;
                final Patch p = parseTestPatchFile();
                assertTrue(p.getErrors().isEmpty());
                assertEquals(1, p.getFiles().size());
index cfefac3aa1014e4242e62f8ff47ccf05a7cd06e7..d55fb4467b54c262df571dab70f12b26066f0663 100644 (file)
@@ -44,7 +44,7 @@
 package org.eclipse.jgit.revwalk;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+               c.parseCanonical(rw, body.toString().getBytes(UTF_8));
                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(CHARSET));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
                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(CHARSET));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
 
                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(CHARSET));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
 
                assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent());
                assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent());
@@ -185,18 +185,18 @@ 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(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));
+               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));
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new RevWalk(db), b.toByteArray());
 
-               assertSame(Constants.CHARSET, c.getEncoding());
+               assertSame(UTF_8, c.getEncoding());
                assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
                assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
                assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage());
@@ -205,18 +205,18 @@ 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(CHARSET));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
                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(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));
+               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));
                final RevCommit c;
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new RevWalk(db), b.toByteArray());
 
-               assertSame(Constants.CHARSET, c.getEncoding());
+               assertSame(UTF_8, c.getEncoding());
                assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName());
                assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
                assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage());
@@ -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(CHARSET));
+               b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
                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(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));
+               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));
                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(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));
+               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));
                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(CHARSET));
-               b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
+                               .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(CHARSET));
-               b.write("encoding 'utf8'\n".getBytes(CHARSET));
-               b.write("\n".getBytes(CHARSET));
-               b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
+                               .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));
 
                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(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));
+               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));
 
                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(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));
+               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));
 
                RevCommit c = new RevCommit(
                                id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
index e11cef7c92d7a939b579505c42f8c828b46d0942..1b45473066d0cb338eea801bf31ed09c3c1dd96a 100644 (file)
@@ -44,7 +44,7 @@
 package org.eclipse.jgit.revwalk;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+               c.parseCanonical(rw, b.toString().getBytes(UTF_8));
                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(CHARSET));
+               c.parseCanonical(rw, body.toString().getBytes(UTF_8));
                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(CHARSET));
+               c.parseCanonical(rw, body.toString().getBytes(UTF_8));
                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(CHARSET));
+               c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
                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(CHARSET));
-               b.write("type tree\n".getBytes(CHARSET));
-               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
+                               .getBytes(UTF_8));
+               b.write("type tree\n".getBytes(UTF_8));
+               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
 
                b
                                .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\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));
+                                               .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));
                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(CHARSET));
-               b.write("type tree\n".getBytes(CHARSET));
-               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
+                               .getBytes(UTF_8));
+               b.write("type tree\n".getBytes(UTF_8));
+               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
                b.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
                                .getBytes(ISO_8859_1));
-               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));
+               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));
                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(CHARSET));
-               b.write("type tree\n".getBytes(CHARSET));
-               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
+                               .getBytes(UTF_8));
+               b.write("type tree\n".getBytes(UTF_8));
+               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
                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(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));
+               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));
                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(CHARSET));
-               b.write("type tree\n".getBytes(CHARSET));
-               b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
+                               .getBytes(UTF_8));
+               b.write("type tree\n".getBytes(UTF_8));
+               b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
                b
                                .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\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));
+                                               .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));
                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(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));
+               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));
 
                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(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));
+               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));
 
                RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                t.parseCanonical(new RevWalk(db), b.toByteArray());
index 0dea5ce97b240cf14f971528da1484e0c3ae47fe..7f0d60295c9936029877b8cbcb5f1cf8f51673b5 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.storage.file;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+               final File file = createFile(CONTENT1.getBytes(UTF_8));
                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(CHARSET));
+               bos1.write(CONTENT1.getBytes(UTF_8));
 
                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(CHARSET));
+               bos2.write(CONTENT2.getBytes(UTF_8));
                assertArrayEquals(bos2.toByteArray(), IO.readFully(file));
        }
 
index d30ac840a6e553202c69733013f9a342a7915d06..7b31bfa3adf7a96717631ae485f7b6eae590c36d 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -199,7 +199,8 @@ 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(), CHARSET));
+                       assertEquals(data,
+                                       new String(repo.open(id, OBJ_BLOB).getBytes(), UTF_8));
                }
        }
 
index 4e5d56acb2ff14b8d7df911f26b8fa99c7f009a3..2a4e492e3d04edcb81f4e9c407c44759f1154415 100644 (file)
@@ -42,7 +42,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
@@ -76,7 +76,7 @@ public class NetRCTest extends RepositoryTestCase {
 
        private void config(String data) throws IOException {
                try (OutputStreamWriter fw = new OutputStreamWriter(
-                               new FileOutputStream(configFile), CHARSET)) {
+                               new FileOutputStream(configFile), UTF_8)) {
                        fw.write(data);
                }
        }
index abf80ecd4d22fff650ab56abdbf873143e110e9e..19fcbfd7a2207b302cffef9b3d63366b88f1d490 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -94,7 +94,7 @@ public class OpenSshConfigTest extends RepositoryTestCase {
                long lastMtime = configFile.lastModified();
                do {
                        try (final OutputStreamWriter fw = new OutputStreamWriter(
-                                       new FileOutputStream(configFile), CHARSET)) {
+                                       new FileOutputStream(configFile), UTF_8)) {
                                fw.write(data);
                        }
                } while (lastMtime == configFile.lastModified());
index 97f392e63405eb9d440e6c5c1bb68c89debb210c..f2fb0224ef36c2bc04a6102796b40e89b0fe0cd6 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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()), CHARSET);
+                       return new String(Files.readAllBytes(file.toPath()), UTF_8);
                }
 
                /**
@@ -371,7 +371,7 @@ public class WalkEncryptionTest {
                 * @throws Exception
                 */
                static void textWrite(File file, String text) throws Exception {
-                       Files.write(file.toPath(), text.getBytes(CHARSET));
+                       Files.write(file.toPath(), text.getBytes(UTF_8));
                }
 
                static void verifyFileContent(File fileOne, File fileTwo)
@@ -420,7 +420,7 @@ public class WalkEncryptionTest {
                                c.setConnectTimeout(500);
                                c.setReadTimeout(500);
                                try (BufferedReader reader = new BufferedReader(
-                                               new InputStreamReader(c.getInputStream(), CHARSET))) {
+                                               new InputStreamReader(c.getInputStream(), UTF_8))) {
                                        return reader.readLine();
                                }
                        } catch (UnknownHostException | SocketTimeoutException e) {
@@ -738,7 +738,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(CHARSET));
+                       s3.put(bucket, path, file.getBytes(UTF_8));
                        s3.delete(bucket, path);
                }
 
index 6195e640fbb90d0572675ea9166cc44fab74d48f..41bd355a2f23f985f60313826f92c56251eba214 100644 (file)
@@ -43,6 +43,7 @@
 
 package org.eclipse.jgit.treewalk;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE;
 import static org.eclipse.jgit.lib.FileMode.SYMLINK;
 import static org.junit.Assert.assertEquals;
@@ -110,7 +111,7 @@ public class CanonicalTreeParserTest {
        }
 
        private String path() {
-               return RawParseUtils.decode(Constants.CHARSET, ctp.path,
+               return RawParseUtils.decode(UTF_8, ctp.path,
                                ctp.pathOffset, ctp.pathLen);
        }
 
@@ -370,7 +371,7 @@ public class CanonicalTreeParserTest {
                final String name = b.toString();
                ctp.reset(entry(m644, name, hash_a));
                assertFalse(ctp.eof());
-               assertEquals(name, RawParseUtils.decode(Constants.CHARSET, ctp.path,
+               assertEquals(name, RawParseUtils.decode(UTF_8, ctp.path,
                                ctp.pathOffset, ctp.pathLen));
        }
 
index e0316783399641c04a030bd0ea56000261c5f532..33e32cd8134feebbbb0fa84e685fd21ec55ed8b2 100644 (file)
@@ -43,6 +43,7 @@
 
 package org.eclipse.jgit.treewalk;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -822,6 +823,6 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
        }
 
        private static String nameOf(AbstractTreeIterator i) {
-               return RawParseUtils.decode(Constants.CHARSET, i.path, 0, i.pathLen);
+               return RawParseUtils.decode(UTF_8, i.path, 0, i.pathLen);
        }
 }
index a748b522155da7ab1cb5f1405f39da162cc4aafe..e8566d243825ec8a7bc24482a7a3f5e249a98be7 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.util;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET);
+               byte[] bytes = text.getBytes(UTF_8);
                return new RawCharSequence(bytes, 0, bytes.length);
        }
 }
index 505816580267a1e51840c3b569410248151037d5..37ca951f673c93509768ee2fbbbdcba183220185 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.util.io;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 
 import java.io.ByteArrayInputStream;
@@ -132,6 +132,6 @@ public class AutoLFInputStreamTest {
        }
 
        private static byte[] asBytes(String in) {
-               return in.getBytes(CHARSET);
+               return in.getBytes(UTF_8);
        }
 }
index 3c612e1bdddba2fb45aa0368d6d55b2f9757b098..e6045a91bd256f6471f436d89623429e59ce39fe 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.util.sha1;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+               m.update(TEST1.getBytes(UTF_8));
                ObjectId m1 = ObjectId.fromRaw(m.digest());
 
                SHA1 s = SHA1.newInstance();
-               s.update(TEST1.getBytes(CHARSET));
+               s.update(TEST1.getBytes(UTF_8));
                ObjectId s1 = ObjectId.fromRaw(s.digest());
 
                s.reset();
-               s.update(TEST1.getBytes(CHARSET));
+               s.update(TEST1.getBytes(UTF_8));
                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(CHARSET));
+               m.update(TEST2.getBytes(UTF_8));
                ObjectId m1 = ObjectId.fromRaw(m.digest());
 
                SHA1 s = SHA1.newInstance();
-               s.update(TEST2.getBytes(CHARSET));
+               s.update(TEST2.getBytes(UTF_8));
                ObjectId s1 = ObjectId.fromRaw(s.digest());
 
                s.reset();
-               s.update(TEST2.getBytes(CHARSET));
+               s.update(TEST2.getBytes(UTF_8));
                ObjectId s2 = s.toObjectId();
 
                assertEquals(m1, s1);
index 62bf9f273701be1eacfbcf1e4aa5500d50ec7bce..bcd72311dd39d0919ea9b9a22bf4c2697d8d232a 100644 (file)
@@ -42,6 +42,8 @@
  */
 package org.eclipse.jgit.attributes;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -50,8 +52,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.eclipse.jgit.lib.Constants;
-
 /**
  * Represents a bundle of attributes inherited from a base directory.
  *
@@ -115,7 +115,7 @@ public class AttributesNode {
        }
 
        private static BufferedReader asReader(InputStream in) {
-               return new BufferedReader(new InputStreamReader(in, Constants.CHARSET));
+               return new BufferedReader(new InputStreamReader(in, UTF_8));
        }
 
        /**
index fee9f51000cc7857210a743f76b0d936e62834de..6b1d4f4d8aba97206c5f5c411dbceb2b1d465564 100644 (file)
@@ -46,6 +46,8 @@
 
 package org.eclipse.jgit.dircache;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.ByteArrayOutputStream;
 import java.io.EOFException;
 import java.io.IOException;
@@ -772,7 +774,7 @@ public class DirCacheEntry {
        }
 
        static String toString(byte[] path) {
-               return Constants.CHARSET.decode(ByteBuffer.wrap(path)).toString();
+               return UTF_8.decode(ByteBuffer.wrap(path)).toString();
        }
 
        static int getMaximumInfoLength(boolean extended) {
index b605f3ca8e8639a0734defc03eb5471407eade3d..11a3474a35c989cd32da36eb5be3fece878e2a89 100644 (file)
@@ -44,6 +44,7 @@
 
 package org.eclipse.jgit.dircache;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.FileMode.TREE;
 import static org.eclipse.jgit.lib.TreeFormatter.entrySize;
 
@@ -276,7 +277,7 @@ public class DirCacheTree {
         */
        public String getNameString() {
                final ByteBuffer bb = ByteBuffer.wrap(encodedName);
-               return Constants.CHARSET.decode(bb).toString();
+               return UTF_8.decode(bb).toString();
        }
 
        /**
index 8a61d1b0b14c361291957a0da04db6e183ca3951..ad43e2ca8354ca9651df6af2425c767f5f6bb99e 100644 (file)
@@ -42,7 +42,7 @@
  */
 package org.eclipse.jgit.hooks;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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,
-                                       CHARSET.name());
+                                       UTF_8.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(), CHARSET),
+                                       new String(errorByteArray.toByteArray(), UTF_8),
                                        getHookName(), result.getExitCode());
                }
        }
index d570fde36fadac5308fc26bc7e1e6d6720256a3a..864f8bfc02c13d019e9fe1401e818743b9b26bc4 100644 (file)
@@ -42,6 +42,8 @@
  */
 package org.eclipse.jgit.ignore;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -50,8 +52,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.eclipse.jgit.lib.Constants;
-
 /**
  * Represents a bundle of ignore rules inherited from a base directory.
  *
@@ -121,7 +121,7 @@ public class IgnoreNode {
        }
 
        private static BufferedReader asReader(InputStream in) {
-               return new BufferedReader(new InputStreamReader(in, Constants.CHARSET));
+               return new BufferedReader(new InputStreamReader(in, UTF_8));
        }
 
        /**
index c11f69670843f8d54be182c7043ce978506f9a65..8793d831269fce3aaa56c9721d8474bb9d700ea0 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.dfs;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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(CHARSET), ext);
+               return new ByteArrayDfsStreamKey(repo, name.getBytes(UTF_8), ext);
        }
 
        final int hash;
index 0e587ce8277616a4140be0a927ee219517fec9dc..82458c1acf6a37fedb4930b389c1c4977e4084cd 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.file;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.File;
 import java.io.IOException;
@@ -171,6 +171,6 @@ class GcLog {
                if (content.length() > 0) {
                        nonEmpty = true;
                }
-               lock.write(content.getBytes(CHARSET));
+               lock.write(content.getBytes(UTF_8));
        }
 }
index c82d52e79cf77cec95046323dc06fdcaff78c12c..3d0e9c71893f1ff3c4d3af71e2c7e4cb26803411 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.file;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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, CHARSET);
+                               Reader rin = new InputStreamReader(fin, UTF_8);
                                BufferedReader br = new BufferedReader(rin)) {
                        MutableObjectId id = new MutableObjectId();
                        for (String line; (line = br.readLine()) != null;) {
index 6a18df86e2b6b287ed14820efb4f9b91cbae8096..de7e4b3f258931451de74efd2d7b423d3f2233f0 100644 (file)
@@ -46,7 +46,7 @@
 
 package org.eclipse.jgit.internal.storage.file;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.Constants.HEAD;
 import static org.eclipse.jgit.lib.Constants.LOGS;
 import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
@@ -945,7 +945,7 @@ public class RefDirectory extends RefDatabase {
                        try (BufferedReader br = new BufferedReader(new InputStreamReader(
                                        new DigestInputStream(new FileInputStream(packedRefsFile),
                                                        digest),
-                                       CHARSET))) {
+                                       UTF_8))) {
                                try {
                                        return new PackedRefList(parsePackedRefs(br), snapshot,
                                                        ObjectId.fromRaw(digest.digest()));
index 942d72fe231c8c2519fd7f48c322b1ba89098995..ce2ba4a2e1bf19ef6c3f0f2903173ed33d742299 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET, nameBuf, 0, len);
+               return RawParseUtils.decode(UTF_8, nameBuf, 0, len);
        }
 
        boolean match(byte[] match, boolean matchIsPrefix) {
@@ -171,7 +171,7 @@ class BlockReader {
        }
 
        Ref readRef() throws IOException {
-               String name = RawParseUtils.decode(CHARSET, nameBuf, 0, nameLen);
+               String name = RawParseUtils.decode(UTF_8, 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(CHARSET, buf, ptr, end);
+               String s = RawParseUtils.decode(UTF_8, buf, ptr, end);
                ptr = end;
                return s;
        }
index 3d8fbf4996c7e7d6efb22b346ed900dd0759dc71..b3173e838c5856cd273fe2d601889a8b076eadb5 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET);
+                       return ref.getName().getBytes(UTF_8);
                }
        }
 
@@ -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(CHARSET);
-                       this.email = who.getEmailAddress().getBytes(CHARSET);
-                       this.msg = message.getBytes(CHARSET);
+                       this.name = who.getName().getBytes(UTF_8);
+                       this.email = who.getEmailAddress().getBytes(UTF_8);
+                       this.msg = message.getBytes(UTF_8);
                }
 
                static byte[] key(String ref, long index) {
-                       byte[] name = ref.getBytes(CHARSET);
+                       byte[] name = ref.getBytes(UTF_8);
                        byte[] key = Arrays.copyOf(name, name.length + 1 + 8);
                        NB.encodeInt64(key, key.length - 8, reverseUpdateIndex(index));
                        return key;
index 44bbb16219dd07b054130d4c5ea2810bb1dc7aaf..1fc43c9fac17431649008d635f5699581860e757 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET));
+               writeVarintString(s.getBytes(UTF_8));
        }
 
        void writeVarintString(byte[] msg) {
index bd52256c2b4d6669c742e99e6d2368e7b4fad671..81b30e4cb984b7189c35006fb5bae3fa84aa4357 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.internal.storage.reftable;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET);
+               byte[] key = refName.getBytes(UTF_8);
                RefCursorImpl i = new RefCursorImpl(refEnd, key, false);
                i.block = seek(REF_BLOCK_TYPE, key, refIndex, 0, refEnd);
                return i;
@@ -193,7 +193,7 @@ public class ReftableReader extends Reftable {
        public RefCursor seekRefsWithPrefix(String prefix) throws IOException {
                initRefIndex();
 
-               byte[] key = prefix.getBytes(CHARSET);
+               byte[] key = prefix.getBytes(UTF_8);
                RefCursorImpl i = new RefCursorImpl(refEnd, key, true);
                i.block = seek(REF_BLOCK_TYPE, key, refIndex, 0, refEnd);
                return i;
@@ -232,7 +232,7 @@ public class ReftableReader extends Reftable {
                initLogIndex();
                if (logPosition > 0) {
                        byte[] key = LogEntry.key(refName, updateIndex);
-                       byte[] match = refName.getBytes(CHARSET);
+                       byte[] match = refName.getBytes(UTF_8);
                        LogCursorImpl i = new LogCursorImpl(logEnd, match);
                        i.block = seek(LOG_BLOCK_TYPE, key, logIndex, logPosition, logEnd);
                        return i;
index e008be3a3c6077f973e21c2a2c3c9d6e09da0456..59154b78bfec096215808d0738d34f7c88035b7f 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.lib;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -83,7 +83,7 @@ public class BlobBasedConfig extends Config {
                super(base);
                final String decoded;
                if (isUtf8(blob)) {
-                       decoded = RawParseUtils.decode(CHARSET, blob, 3, blob.length);
+                       decoded = RawParseUtils.decode(UTF_8, blob, 3, blob.length);
                } else {
                        decoded = RawParseUtils.decode(blob);
                }
index 59a13f6550de1243af27abe5e3c328a6da1f2312..c30833d0a6df248763b014f1008eb555f3fc4fa8 100644 (file)
@@ -45,6 +45,8 @@
 
 package org.eclipse.jgit.lib;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
@@ -93,7 +95,7 @@ public class CommitBuilder {
         */
        public CommitBuilder() {
                parentIds = EMPTY_OBJECTID_LIST;
-               encoding = Constants.CHARSET;
+               encoding = UTF_8;
        }
 
        /**
@@ -314,7 +316,7 @@ public class CommitBuilder {
                        w.flush();
                        os.write('\n');
 
-                       if (getEncoding() != Constants.CHARSET) {
+                       if (getEncoding() != UTF_8) {
                                os.write(hencoding);
                                os.write(' ');
                                os.write(Constants.encodeASCII(getEncoding().name()));
@@ -375,7 +377,7 @@ public class CommitBuilder {
                r.append(committer != null ? committer.toString() : "NOT_SET");
                r.append("\n");
 
-               if (encoding != null && encoding != Constants.CHARSET) {
+               if (encoding != null && encoding != UTF_8) {
                        r.append("encoding ");
                        r.append(encoding.name());
                        r.append("\n");
index 0e01cca99b4747fac4170d97b818aa6757522093..b666f21d0b2bbceff7e63bfc383934037a006e35 100644 (file)
@@ -51,7 +51,7 @@
 
 package org.eclipse.jgit.lib;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -1168,7 +1168,7 @@ public class Config {
 
                String decoded;
                if (isUtf8(bytes)) {
-                       decoded = RawParseUtils.decode(CHARSET, bytes, 3, bytes.length);
+                       decoded = RawParseUtils.decode(UTF_8, bytes, 3, bytes.length);
                } else {
                        decoded = RawParseUtils.decode(bytes);
                }
index 9a4a3a2a0181ba89f5f079ed99fdde2add5b15a7..f02e95a3d2858bca984040e812052fd9ea3cf12b 100644 (file)
@@ -227,7 +227,13 @@ public final class Constants {
         */
        public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };
 
-       /** Native character encoding for commit messages, file names... */
+       /**
+        * Native character encoding for commit messages, file names...
+        *
+        * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly
+        *             instead.
+        **/
+       @Deprecated
        public static final Charset CHARSET;
 
        /** Native character encoding for commit messages, file names... */
@@ -638,7 +644,7 @@ public final class Constants {
         * @see #CHARACTER_ENCODING
         */
        public static byte[] encode(String str) {
-               final ByteBuffer bb = Constants.CHARSET.encode(str);
+               final ByteBuffer bb = UTF_8.encode(str);
                final int len = bb.limit();
                if (bb.hasArray() && bb.arrayOffset() == 0) {
                        final byte[] arr = bb.array();
@@ -655,7 +661,7 @@ public final class Constants {
                if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
                        throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
                CHARSET = UTF_8;
-               CHARACTER_ENCODING = CHARSET.name();
+               CHARACTER_ENCODING = UTF_8.name();
        }
 
        /** name of the file containing the commit msg for a merge commit */
index 38716055b52ffafe414cb2b0ce2db028376e83a6..06b4b227c8722fd1a065f76c83c69263c0c481e9 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.lib;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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, CHARSET);
+                                               nextSpace - tokenBegin - 1, UTF_8);
                                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, CHARSET);
+                                               nextSpace - tokenBegin - 1, UTF_8);
                                tokenBegin = nextSpace;
                                commit = AbbreviatedObjectId.fromString(commitToken);
                                break;
index bd0316580525bc5312bdde3f592ce7cade4b9ca9..7669e95acc147b753d5eeeb6e8415e6f02886b20 100644 (file)
@@ -45,6 +45,8 @@
 
 package org.eclipse.jgit.lib;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
@@ -181,7 +183,7 @@ public class TagBuilder {
        public byte[] build() {
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                try (OutputStreamWriter w = new OutputStreamWriter(os,
-                               Constants.CHARSET)) {
+                               UTF_8)) {
                        w.write("object "); //$NON-NLS-1$
                        getObjectId().copyTo(w);
                        w.write('\n');
index 2f759e53ca4ac63551488d553e57eef9f42f4a1c..936ce3dcc85114bea0fdd0a3f8a3f0e324435353 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.lib;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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, CHARSET)));
+               this(new PrintWriter(new OutputStreamWriter(System.err, UTF_8)));
        }
 
        /**
index d0a5216e1ecfc4535acbc0764862014d9009317d..1f4beb017fe59ba5289737053168d1d6dc30cfdc 100644 (file)
@@ -43,6 +43,7 @@
 
 package org.eclipse.jgit.patch;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.Constants.encodeASCII;
 import static org.eclipse.jgit.util.RawParseUtils.decode;
 import static org.eclipse.jgit.util.RawParseUtils.decodeNoFallback;
@@ -63,7 +64,6 @@ import org.eclipse.jgit.diff.DiffEntry;
 import org.eclipse.jgit.diff.EditList;
 import org.eclipse.jgit.internal.JGitText;
 import org.eclipse.jgit.lib.AbbreviatedObjectId;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.FileMode;
 import org.eclipse.jgit.util.QuotedString;
 import org.eclipse.jgit.util.RawParseUtils;
@@ -198,7 +198,7 @@ public class FileHeader extends DiffEntry {
         * Convert the patch script for this file into a string.
         * <p>
         * The default character encoding
-        * ({@link org.eclipse.jgit.lib.Constants#CHARSET}) is assumed for both the
+        * ({@link java.nio.charset.StandardCharsets#UTF_8}) is assumed for both the
         * old and new files.
         *
         * @return the patch script, as a Unicode string.
@@ -240,8 +240,9 @@ public class FileHeader extends DiffEntry {
 
                if (trySimpleConversion(charsetGuess)) {
                        Charset cs = charsetGuess != null ? charsetGuess[0] : null;
-                       if (cs == null)
-                               cs = Constants.CHARSET;
+                       if (cs == null) {
+                               cs = UTF_8;
+                       }
                        try {
                                return decodeNoFallback(cs, buf, startOffset, endOffset);
                        } catch (CharacterCodingException cee) {
@@ -290,8 +291,9 @@ public class FileHeader extends DiffEntry {
                        final String[] r = new String[tmp.length];
                        for (int i = 0; i < tmp.length; i++) {
                                Charset cs = csGuess != null ? csGuess[i] : null;
-                               if (cs == null)
-                                       cs = Constants.CHARSET;
+                               if (cs == null) {
+                                       cs = UTF_8;
+                               }
                                r[i] = RawParseUtils.decode(cs, tmp[i].toByteArray());
                        }
                        return r;
@@ -429,7 +431,7 @@ public class FileHeader extends DiffEntry {
                                        oldPath = QuotedString.GIT_PATH.dequote(buf, bol, sp - 1);
                                        oldPath = p1(oldPath);
                                } else {
-                                       oldPath = decode(Constants.CHARSET, buf, aStart, sp - 1);
+                                       oldPath = decode(UTF_8, buf, aStart, sp - 1);
                                }
                                newPath = oldPath;
                                return eol;
@@ -572,7 +574,7 @@ public class FileHeader extends DiffEntry {
                                tab--;
                        if (ptr == tab)
                                tab = end;
-                       r = decode(Constants.CHARSET, buf, ptr, tab - 1);
+                       r = decode(UTF_8, buf, ptr, tab - 1);
                }
 
                if (r.equals(DEV_NULL))
index 1dd24d732e6f2d586e52534d1bfd41bc761aa468..10ea778343cbf12f19f401c6ffce42fe31b4371d 100644 (file)
 
 package org.eclipse.jgit.patch;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.util.Locale;
 
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.util.RawParseUtils;
 
 /**
@@ -120,7 +121,7 @@ public class FormatError {
         */
        public String getLineText() {
                final int eol = RawParseUtils.nextLF(buf, offset);
-               return RawParseUtils.decode(Constants.CHARSET, buf, offset, eol);
+               return RawParseUtils.decode(UTF_8, buf, offset, eol);
        }
 
        /** {@inheritDoc} */
index 3de442afb62f446cd7c0204a36ab665d885d69d7..5bd5dd63688fed5cb6cdbc8da7d73c87c00d03d0 100644 (file)
@@ -44,7 +44,7 @@
 
 package org.eclipse.jgit.revwalk;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -541,7 +541,7 @@ public class RevCommit extends RevObject {
                try {
                        return getEncoding();
                } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
-                       return CHARSET;
+                       return UTF_8;
                }
        }
 
index 0050bac0ae93472b08b1400586b38da0c4f7d708..32e7adfb0c806ef87f90464a223c6d83c30c9a2a 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.revwalk;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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(CHARSET, rawTag, p, nameEnd);
+               tagName = RawParseUtils.decode(UTF_8, 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 CHARSET;
+                       return UTF_8;
                }
        }
 
index 4b272ba7a421b78cfba36effdf3392c7375fd89e..93b3baa61f9f73e4dd78a02d946b6f937fef01f8 100644 (file)
@@ -49,7 +49,7 @@
 
 package org.eclipse.jgit.storage.file;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -166,7 +166,7 @@ public class FileBasedConfig extends StoredConfig {
                                } else {
                                        final String decoded;
                                        if (isUtf8(in)) {
-                                               decoded = RawParseUtils.decode(CHARSET,
+                                               decoded = RawParseUtils.decode(UTF_8,
                                                                in, 3, in.length);
                                                utf8Bom = true;
                                        } else {
@@ -224,7 +224,7 @@ public class FileBasedConfig extends StoredConfig {
                        bos.write(0xEF);
                        bos.write(0xBB);
                        bos.write(0xBF);
-                       bos.write(text.getBytes(CHARSET));
+                       bos.write(text.getBytes(UTF_8));
                        out = bos.toByteArray();
                } else {
                        out = Constants.encode(text);
index a0fc57ca1f06409373eaff47bf85c3f585c83be9..f6ec4b90ebdbd3cf41adb59c0741fdb28806c97f 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -635,7 +635,7 @@ public class AmazonS3 {
                try {
                        final Mac m = Mac.getInstance(HMAC);
                        m.init(privateKey);
-                       sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(CHARSET)));
+                       sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(UTF_8)));
                } catch (NoSuchAlgorithmException e) {
                        throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage()));
                } catch (InvalidKeyException e) {
index 449f52944762a20b73d27723b69aba9d5fb74613..4b20f6c8b01da4b860ac27422de935f104b0f734 100644 (file)
@@ -47,6 +47,8 @@
 
 package org.eclipse.jgit.transport;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -66,7 +68,6 @@ import org.eclipse.jgit.errors.PackProtocolException;
 import org.eclipse.jgit.errors.TransportException;
 import org.eclipse.jgit.internal.JGitText;
 import org.eclipse.jgit.internal.storage.file.PackLock;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.NullProgressMonitor;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.ObjectIdRef;
@@ -173,7 +174,7 @@ class BundleFetchConnection extends BaseFetchConnection {
                                IO.skipFully(bin, 1);
                                done = true;
                        }
-                       line.append(RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf));
+                       line.append(RawParseUtils.decode(UTF_8, hdrbuf, 0, lf));
                }
                return line.toString();
        }
index f2a261bbe6e74f9e831c3f7d8df414368ed6df07..56aaede80dca0f275345aa2f27b5c914c3fee82e 100644 (file)
@@ -43,6 +43,8 @@
 
 package org.eclipse.jgit.transport;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -231,7 +233,7 @@ public class BundleWriter {
                                packWriter.setTagTargets(tagTargets);
                        packWriter.preparePack(monitor, inc, exc);
 
-                       final Writer w = new OutputStreamWriter(os, Constants.CHARSET);
+                       final Writer w = new OutputStreamWriter(os, UTF_8);
                        w.write(TransportBundle.V2_BUNDLE_SIGNATURE);
                        w.write('\n');
 
index 1415334c634e8070bd234ae4184c4c1d3c8f174d..6c26b7026add7183da3ccdf55813f767206f9785 100644 (file)
@@ -43,7 +43,7 @@
 package org.eclipse.jgit.transport;
 
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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(CHARSET));
+               byte[] rawHmac = mac.doFinal(input.getBytes(UTF_8));
                return Long.toString(timestamp) + "-" + toHex(rawHmac); //$NON-NLS-1$
        }
 
index fb03190b0276c69c3ac0b68883d4a2ce3670c5e7..69745eb31092cde4617e0d9a5e9b2538c92393b1 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(HttpConnection conn) throws IOException {
                        String ident = user + ":" + pass; //$NON-NLS-1$
-                       String enc = Base64.encodeBytes(ident.getBytes(CHARSET));
+                       String enc = Base64.encodeBytes(ident.getBytes(UTF_8));
                        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(CHARSET));
+                       md.update(data.getBytes(UTF_8));
                        return LHEX(md.digest());
                }
 
                private static String KD(String secret, String data) {
                        MessageDigest md = newMD5();
-                       md.update(secret.getBytes(CHARSET));
+                       md.update(secret.getBytes(UTF_8));
                        md.update((byte) ':');
-                       md.update(data.getBytes(CHARSET));
+                       md.update(data.getBytes(UTF_8));
                        return LHEX(md.digest());
                }
 
index cc556f8af6c480bed09fc42c523e8a35efe987b6..c6e19d5762280903a91baa5f004f3b845a92c628 100644 (file)
 
 package org.eclipse.jgit.transport;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.MessageFormat;
 
 import org.eclipse.jgit.errors.PackProtocolException;
 import org.eclipse.jgit.internal.JGitText;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.MutableObjectId;
 import org.eclipse.jgit.util.IO;
 import org.eclipse.jgit.util.RawParseUtils;
@@ -186,7 +187,7 @@ public class PacketLineIn {
                if (raw[len - 1] == '\n')
                        len--;
 
-               String s = RawParseUtils.decode(Constants.CHARSET, raw, 0, len);
+               String s = RawParseUtils.decode(UTF_8, raw, 0, len);
                log.debug("git< " + s); //$NON-NLS-1$
                return s;
        }
@@ -218,7 +219,7 @@ public class PacketLineIn {
 
                IO.readFully(in, raw, 0, len);
 
-               String s = RawParseUtils.decode(Constants.CHARSET, raw, 0, len);
+               String s = RawParseUtils.decode(UTF_8, raw, 0, len);
                log.debug("git< " + s); //$NON-NLS-1$
                return s;
        }
index a26d1d77d6fe57e065dc79db1c86ad6d8d2952bd..e9400919a89247782a49c050828ad15cbacb1431 100644 (file)
@@ -45,6 +45,8 @@
 
 package org.eclipse.jgit.transport;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.io.OutputStream;
 
@@ -141,7 +143,7 @@ public class PacketLineOut {
                out.write(lenbuffer, 0, 4);
                out.write(buf, pos, len);
                if (log.isDebugEnabled()) {
-                       String s = RawParseUtils.decode(Constants.CHARSET, buf, pos, len);
+                       String s = RawParseUtils.decode(UTF_8, buf, pos, len);
                        log.debug("git> " + s); //$NON-NLS-1$
                }
        }
index 2364434b0fac7b197acf36647561cc3609b3412a..41af8078c8a1045421e14ff68c02f64082605620 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 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(CHARSET));
+                               out.write(s.getBytes(UTF_8));
                                out.flush();
                        } catch (IOException e) {
                                write = false;
index 178c80d22e4a798b7dcb0201a0719b44801978b7..f9fddbe88908bc2f18f08a7030903cdf93f5848d 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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(CHARSET);
+               byte[] raw = str.getBytes(UTF_8);
                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, CHARSET);
+               String id = new String(raw, 0, idEnd, UTF_8);
 
                return new PushCertificateIdent(str, id, when * 1000L, tz);
        }
index 7f5a3408e3383aa58024447698d4d985316c6b64..aeca63500ac2da93a4c823a2dd8fcc4953996ab9 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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,8 @@ 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, CHARSET))) {
+                               Reader r = new BufferedReader(
+                                               new InputStreamReader(in, UTF_8))) {
                        return PushCertificateParser.fromReader(r);
                }
        }
@@ -473,7 +474,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(CHARSET));
+               final ObjectId certId = inserter.insert(OBJ_BLOB, certText.getBytes(UTF_8));
                boolean any = false;
                for (ReceiveCommand cmd : pc.cert.getCommands()) {
                        if (byRef != null && !commandsEqual(cmd, byRef.get(cmd.getRefName()))) {
index dc1871b729821253be8c16b96d101b4e9e1848f3..4662435ea781c45b21483c40f2c6558351348f70 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 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.lib.Repository;
 public abstract class RefAdvertiser {
        /** Advertiser which frames lines in a {@link PacketLineOut} format. */
        public static class PacketLineOutRefAdvertiser extends RefAdvertiser {
-               private final CharsetEncoder utf8 = CHARSET.newEncoder();
+               private final CharsetEncoder utf8 = UTF_8.newEncoder();
                private final PacketLineOut pckOut;
 
                private byte[] binArr = new byte[256];
index 3100cb444a4ac7835402c7c2d8f9a990e660e9fa..90600cbb98f51c837a44a2f9b087daf1ac407c10 100644 (file)
@@ -44,6 +44,7 @@
 
 package org.eclipse.jgit.transport;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.transport.SideBandOutputStream.HDR_SIZE;
 
 import java.io.IOException;
@@ -57,7 +58,6 @@ import java.util.regex.Pattern;
 import org.eclipse.jgit.errors.PackProtocolException;
 import org.eclipse.jgit.errors.TransportException;
 import org.eclipse.jgit.internal.JGitText;
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.ProgressMonitor;
 import org.eclipse.jgit.util.IO;
 import org.eclipse.jgit.util.RawParseUtils;
@@ -257,6 +257,6 @@ public class SideBandInputStream extends InputStream {
        private String readString(int len) throws IOException {
                final byte[] raw = new byte[len];
                IO.readFully(rawIn, raw, 0, len);
-               return RawParseUtils.decode(Constants.CHARSET, raw, 0, len);
+               return RawParseUtils.decode(UTF_8, raw, 0, len);
        }
 }
index d342ef46dfcc7dbbf7adfd25d3a5672dfae0dcc0..621c2ea56c7c8f85277857ab600b93125992a9b5 100644 (file)
@@ -46,7 +46,7 @@
 
 package org.eclipse.jgit.transport;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -144,7 +144,7 @@ public abstract class Transport implements AutoCloseable {
 
        private static void scan(ClassLoader ldr, URL url) {
                try (BufferedReader br = new BufferedReader(
-                               new InputStreamReader(url.openStream(), CHARSET))) {
+                               new InputStreamReader(url.openStream(), UTF_8))) {
                        String line;
                        while ((line = br.readLine()) != null) {
                                line = line.trim();
index ee64a87f764c0fde17598bd4bccf16c5d2fbdcfb..8b41ab046647a61b732256356b185b22c6bd2d2b 100644 (file)
@@ -46,6 +46,7 @@
 
 package org.eclipse.jgit.transport;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.lib.Constants.HEAD;
 import static org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP;
 import static org.eclipse.jgit.util.HttpSupport.ENCODING_X_GZIP;
@@ -426,7 +427,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
        }
 
        private BufferedReader toBufferedReader(InputStream in) {
-               return new BufferedReader(new InputStreamReader(in, Constants.CHARSET));
+               return new BufferedReader(new InputStreamReader(in, UTF_8));
        }
 
        /** {@inheritDoc} */
@@ -952,7 +953,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
                        // Line oriented readable content is likely to compress well.
                        // Request gzip encoding.
                        InputStream is = open(path, AcceptEncoding.GZIP).in;
-                       return new BufferedReader(new InputStreamReader(is, Constants.CHARSET));
+                       return new BufferedReader(new InputStreamReader(is, UTF_8));
                }
 
                @Override
index aa71c9445a3a38ed77a73b16e3d3fe3bf6b4e9d3..6d4df4fbadb725142a20e06dc3752564d3ab77e8 100644 (file)
@@ -43,6 +43,8 @@
 
 package org.eclipse.jgit.transport;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
@@ -363,7 +365,7 @@ abstract class WalkRemoteObjectDatabase {
         */
        BufferedReader openReader(String path) throws IOException {
                final InputStream is = open(path).in;
-               return new BufferedReader(new InputStreamReader(is, Constants.CHARSET));
+               return new BufferedReader(new InputStreamReader(is, UTF_8));
        }
 
        /**
index 470ed0284170fba63630ccbd0e7ef8462aa9c803..335abe1b5b4c42b617cb3b4ad7da441fba4c3b09 100644 (file)
@@ -45,6 +45,8 @@
 
 package org.eclipse.jgit.treewalk;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -182,7 +184,7 @@ public abstract class AbstractTreeIterator {
                if (prefix != null && prefix.length() > 0) {
                        final ByteBuffer b;
 
-                       b = Constants.CHARSET.encode(CharBuffer.wrap(prefix));
+                       b = UTF_8.encode(CharBuffer.wrap(prefix));
                        pathLen = b.limit();
                        path = new byte[Math.max(DEFAULT_PATH_SIZE, pathLen + 1)];
                        b.get(path, 0, pathLen);
index d500aae681abe94b025a6b358580b079ba2048d7..82675859ddbc58ed22632b0cf91cc918c9290e6f 100644 (file)
@@ -44,6 +44,8 @@
 
 package org.eclipse.jgit.treewalk;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -1045,7 +1047,7 @@ public class TreeWalk implements AutoCloseable, AttributesProvider {
                final AbstractTreeIterator t = currentHead;
                final int off = t.pathOffset;
                final int end = t.pathLen;
-               return RawParseUtils.decode(Constants.CHARSET, t.path, off, end);
+               return RawParseUtils.decode(UTF_8, t.path, off, end);
        }
 
        /**
@@ -1378,11 +1380,11 @@ public class TreeWalk implements AutoCloseable, AttributesProvider {
        }
 
        static String pathOf(AbstractTreeIterator t) {
-               return RawParseUtils.decode(Constants.CHARSET, t.path, 0, t.pathLen);
+               return RawParseUtils.decode(UTF_8, t.path, 0, t.pathLen);
        }
 
        static String pathOf(byte[] buf, int pos, int end) {
-               return RawParseUtils.decode(Constants.CHARSET, buf, pos, end);
+               return RawParseUtils.decode(UTF_8, buf, pos, end);
        }
 
        /**
index 179fd467912e61e8dcbfe56b46779dd54547e2d8..7c6bfb9d63935625ef7afc32073bd7197c3b112f 100644 (file)
@@ -46,6 +46,8 @@
 
 package org.eclipse.jgit.treewalk;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -1413,7 +1415,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
 
                IteratorState(WorkingTreeOptions options) {
                        this.options = options;
-                       this.nameEncoder = Constants.CHARSET.newEncoder();
+                       this.nameEncoder = UTF_8.newEncoder();
                }
 
                void initializeReadBuffer() {
index 442f0793fbe036380319e83e06266fdaea973cd7..69f85474527d5c39f427c008b563a73e4d9286ab 100644 (file)
@@ -6,7 +6,7 @@
 
 package org.eclipse.jgit.util;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.text.MessageFormat;
 import java.util.Arrays;
@@ -54,7 +54,7 @@ public class Base64 {
                                + "abcdefghijklmnopqrstuvwxyz" // //$NON-NLS-1$
                                + "0123456789" // //$NON-NLS-1$
                                + "+/" // //$NON-NLS-1$
-               ).getBytes(CHARSET);
+               ).getBytes(UTF_8);
 
                DEC = new byte[128];
                Arrays.fill(DEC, INVALID_DEC);
@@ -177,7 +177,7 @@ public class Base64 {
                        e += 4;
                }
 
-               return new String(outBuff, 0, e, CHARSET);
+               return new String(outBuff, 0, e, UTF_8);
        }
 
        /**
@@ -293,7 +293,7 @@ public class Base64 {
         * @return the decoded data
         */
        public static byte[] decode(String s) {
-               byte[] bytes = s.getBytes(CHARSET);
+               byte[] bytes = s.getBytes(UTF_8);
                return decode(bytes, 0, bytes.length);
        }
 }
index 3393fbfd1d1187b48bc77ec9038295b67f74d5e9..e5c8d9d398ce178e2e0ac4a4b1fddd9591071b9c 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.util;
 
-import static org.eclipse.jgit.lib.Constants.CHARSET;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.File;
 import java.io.PrintStream;
@@ -126,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$
-                                       CHARSET.name());
+                                       UTF_8.name());
                        } catch (CommandFailedException e) {
                                LOG.warn(e.getMessage());
                                return null;
index 2f547c15b0361a04c46e4fbfea8a40ffa54f0aee..ecfd31647d483a3161c017f2ab35c33e0be13f25 100644 (file)
@@ -45,6 +45,8 @@
 
 package org.eclipse.jgit.util;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.AtomicMoveNotSupportedException;
@@ -712,7 +714,7 @@ public class FileUtils {
                Path nioPath = toPath(file);
                if (Files.isSymbolicLink(nioPath))
                        return Files.readSymbolicLink(nioPath).toString()
-                                       .getBytes(Constants.CHARSET).length;
+                                       .getBytes(UTF_8).length;
                return Files.size(nioPath);
        }
 
index 4d58d0614a723e8d14950603a7d8fecb2a12fcfa..a55cad3705577a4bf9ea1fb2944dd756300205ed 100644 (file)
@@ -43,6 +43,8 @@
 
 package org.eclipse.jgit.util;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.util.Arrays;
 
 import org.eclipse.jgit.lib.Constants;
@@ -181,7 +183,7 @@ public abstract class QuotedString {
                                        continue;
                                }
                        }
-                       return RawParseUtils.decode(Constants.CHARSET, r, 0, rPtr);
+                       return RawParseUtils.decode(UTF_8, r, 0, rPtr);
                }
        }
 
@@ -294,7 +296,7 @@ public abstract class QuotedString {
                public String dequote(byte[] in, int inPtr, int inEnd) {
                        if (2 <= inEnd - inPtr && in[inPtr] == '"' && in[inEnd - 1] == '"')
                                return dq(in, inPtr + 1, inEnd - 1);
-                       return RawParseUtils.decode(Constants.CHARSET, in, inPtr, inEnd);
+                       return RawParseUtils.decode(UTF_8, in, inPtr, inEnd);
                }
 
                private static String dq(byte[] in, int inPtr, int inEnd) {
@@ -370,7 +372,7 @@ public abstract class QuotedString {
                                }
                        }
 
-                       return RawParseUtils.decode(Constants.CHARSET, r, 0, rPtr);
+                       return RawParseUtils.decode(UTF_8, r, 0, rPtr);
                }
 
                private GitPathStyle() {
index 94e5ef3d7438e5d3bee72d6ee0524a49001d41b5..12d809b5138d90dfba8e0eeadbbaf433c4e4db45 100644 (file)
 
 package org.eclipse.jgit.util.io;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 
-import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.util.RawParseUtils;
 
 /**
@@ -80,7 +81,7 @@ public class MessageWriter extends Writer {
         */
        public MessageWriter() {
                buf = new ByteArrayOutputStream();
-               enc = new OutputStreamWriter(getRawStream(), Constants.CHARSET);
+               enc = new OutputStreamWriter(getRawStream(), UTF_8);
        }
 
        /** {@inheritDoc} */