Browse Source

Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8

Change-Id: I6714fc3666e1bced22abba94ceb700477349586e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.0
David Pursehouse 7 years ago committed by Matthias Sohn
parent
commit
f07b60239c
  1. 7
      org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
  2. 4
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
  3. 6
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java
  4. 4
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
  5. 4
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
  6. 4
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
  7. 6
      org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/LfsServerTest.java
  8. 1
      org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF
  9. 6
      org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
  10. 8
      org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java
  11. 4
      org.eclipse.jgit.lfs.test/src/org/eclipse/jgit/lfs/test/LongObjectIdTestUtils.java
  12. 4
      org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java
  13. 8
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java
  14. 4
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java
  15. 5
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java
  16. 6
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
  17. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
  18. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
  19. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java
  20. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteReftable.java
  21. 6
      org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java
  22. 10
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolStreamTypeUtilTest.java
  23. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java
  24. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
  25. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
  26. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
  27. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java
  28. 24
      org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
  29. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java
  30. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java
  31. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java
  32. 16
      org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
  33. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java
  34. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java
  35. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java
  36. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
  37. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java
  38. 10
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
  39. 14
      org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
  40. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/GetTextTest.java
  41. 102
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
  42. 102
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
  43. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java
  44. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
  45. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java
  46. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawSubStringPatternTest.java
  47. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoLFInputStreamTest.java
  48. 14
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/sha1/SHA1Test.java
  49. 6
      org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
  50. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java
  51. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
  52. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java
  53. 8
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
  54. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java
  55. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java
  56. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
  57. 5
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java
  58. 5
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
  59. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
  60. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java
  61. 4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java
  62. 4
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
  63. 6
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java
  64. 6
      org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java
  65. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
  66. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
  67. 10
      org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
  68. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java
  69. 6
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java
  70. 6
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
  71. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java
  72. 3
      org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
  73. 9
      org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
  74. 4
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
  75. 4
      org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java

7
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java

@ -42,6 +42,8 @@
*/
package org.eclipse.jgit.archive;
import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
import java.io.IOException;
import java.io.OutputStream;
import java.text.MessageFormat;
@ -82,7 +84,8 @@ public final class TarFormat extends BaseFormat implements
@Override
public ArchiveOutputStream createArchiveOutputStream(OutputStream s,
Map<String, Object> o) throws IOException {
TarArchiveOutputStream out = new TarArchiveOutputStream(s, "UTF-8"); //$NON-NLS-1$
TarArchiveOutputStream out = new TarArchiveOutputStream(s,
CHARACTER_ENCODING);
out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
return applyFormatOptions(out, o);
@ -97,7 +100,7 @@ public final class TarFormat extends BaseFormat implements
final TarArchiveEntry entry = new TarArchiveEntry(
path, TarConstants.LF_SYMLINK);
entry.setLinkName(new String(
loader.getCachedBytes(100), "UTF-8")); //$NON-NLS-1$
loader.getCachedBytes(100), CHARACTER_ENCODING));
out.putArchiveEntry(entry);
out.closeArchiveEntry();
return;

4
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.http.test;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_ENCODING;
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_LENGTH;
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE;
@ -1084,7 +1084,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
public void testInvalidWant() throws Exception {
@SuppressWarnings("resource")
ObjectId id = new ObjectInserter.Formatter().idFor(Constants.OBJ_BLOB,
"testInvalidWant".getBytes(UTF_8));
"testInvalidWant".getBytes(CHARSET));
Repository dst = createBareRepository();
try (Transport t = Transport.open(dst, remoteURI);

6
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java

@ -45,7 +45,7 @@
package org.eclipse.jgit.junit;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.File;
import java.io.FileNotFoundException;
@ -246,7 +246,7 @@ public abstract class JGitTestUtil {
throws IOException {
FileUtils.mkdirs(f.getParentFile(), true);
try (Writer w = new OutputStreamWriter(new FileOutputStream(f),
UTF_8)) {
CHARSET)) {
w.write(body);
}
}
@ -263,7 +263,7 @@ public abstract class JGitTestUtil {
*/
public static String read(final File file) throws IOException {
final byte[] body = IO.readFully(file);
return new String(body, 0, body.length, UTF_8);
return new String(body, 0, body.length, CHARSET);
}
/**

4
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java

@ -45,7 +45,7 @@
package org.eclipse.jgit.junit;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
@ -352,7 +352,7 @@ public abstract class LocalDiskRepositoryTestCase {
if (0 != (includedOptions & CONTENT)) {
sb.append(", content:"
+ new String(repo.open(entry.getObjectId(),
Constants.OBJ_BLOB).getCachedBytes(), UTF_8));
Constants.OBJ_BLOB).getCachedBytes(), CHARSET));
}
if (0 != (includedOptions & ASSUME_UNCHANGED))
sb.append(", assume-unchanged:"

4
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java

@ -46,7 +46,7 @@
package org.eclipse.jgit.junit;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import java.io.File;
@ -199,7 +199,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
protected static void checkFile(File f, final String checkData)
throws IOException {
try (Reader r = new InputStreamReader(new FileInputStream(f),
UTF_8)) {
CHARSET)) {
if (checkData.length() > 0) {
char[] data = new char[checkData.length()];
assertEquals(data.length, r.read(data));

4
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.junit;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@ -268,7 +268,7 @@ public class TestRepository<R extends Repository> {
* @throws Exception
*/
public RevBlob blob(final String content) throws Exception {
return blob(content.getBytes(UTF_8));
return blob(content.getBytes(CHARSET));
}
/**

6
org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/LfsServerTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.lfs.server.fs;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import java.io.BufferedInputStream;
@ -211,11 +211,11 @@ public abstract class LfsServerTest {
if (buf.hasArray()) {
error = new String(buf.array(),
buf.arrayOffset() + buf.position(), buf.remaining(),
UTF_8);
CHARSET);
} else {
final byte[] b = new byte[buf.remaining()];
buf.duplicate().get(b);
error = new String(b, UTF_8);
error = new String(b, CHARSET);
}
} catch (IOException e) {
error = statusLine.getReasonPhrase();

1
org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF

@ -31,6 +31,7 @@ Import-Package: com.google.gson;version="[2.8.0,3.0.0)",
org.eclipse.jgit.lfs.errors;version="[5.0.0,5.1.0)",
org.eclipse.jgit.lfs.internal;version="[5.0.0,5.1.0)",
org.eclipse.jgit.lfs.lib;version="[5.0.0,5.1.0)",
org.eclipse.jgit.lib;version="[5.0.0,5.1.0)",
org.eclipse.jgit.nls;version="[5.0.0,5.1.0)",
org.eclipse.jgit.transport.http;version="[5.0.0,5.1.0)",
org.eclipse.jgit.transport.http.apache;version="[5.0.0,5.1.0)",

6
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.lfs.server;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.apache.http.HttpStatus.SC_FORBIDDEN;
import static org.apache.http.HttpStatus.SC_INSUFFICIENT_STORAGE;
import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
@ -202,10 +202,10 @@ public abstract class LfsProtocolServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Writer w = new BufferedWriter(
new OutputStreamWriter(res.getOutputStream(), UTF_8));
new OutputStreamWriter(res.getOutputStream(), CHARSET));
Reader r = new BufferedReader(
new InputStreamReader(req.getInputStream(), UTF_8));
new InputStreamReader(req.getInputStream(), CHARSET));
LfsRequest request = LfsGson.fromJson(r, LfsRequest.class);
String path = req.getPathInfo();

8
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java

@ -43,7 +43,7 @@
*/
package org.eclipse.jgit.lfs.server.s3;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION;
import java.io.UnsupportedEncodingException;
@ -359,13 +359,13 @@ class SignerV4 {
private static byte[] hash(String s) {
MessageDigest md = Constants.newMessageDigest();
md.update(s.getBytes(UTF_8));
md.update(s.getBytes(CHARSET));
return md.digest();
}
private static byte[] sign(String stringData, byte[] key) {
try {
byte[] data = stringData.getBytes(UTF_8);
byte[] data = stringData.getBytes(CHARSET);
Mac mac = Mac.getInstance(HMACSHA256);
mac.init(new SecretKeySpec(key, HMACSHA256));
return mac.doFinal(data);
@ -395,7 +395,7 @@ class SignerV4 {
private static String urlEncode(String url, boolean keepPathSlash) {
String encoded;
try {
encoded = URLEncoder.encode(url, UTF_8.name());
encoded = URLEncoder.encode(url, CHARSET.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(LfsServerText.get().unsupportedUtf8, e);
}

4
org.eclipse.jgit.lfs.test/src/org/eclipse/jgit/lfs/test/LongObjectIdTestUtils.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.lfs.test;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
@ -66,7 +66,7 @@ public class LongObjectIdTestUtils {
*/
public static LongObjectId hash(String s) {
MessageDigest md = Constants.newMessageDigest();
md.update(s.getBytes(UTF_8));
md.update(s.getBytes(CHARSET));
return LongObjectId.fromRaw(md.digest());
}

4
org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.lfs.lib;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
@ -66,7 +66,7 @@ public class LFSPointerTest {
assertEquals(
"version https://git-lfs.github.com/spec/v1\noid sha256:"
+ s + "\nsize 4\n",
baos.toString(UTF_8.name()));
baos.toString(CHARACTER_ENCODING));
}
}
}

8
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPointer.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.lfs;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.IOException;
@ -134,7 +134,7 @@ public class LfsPointer implements Comparable<LfsPointer> {
*/
public void encode(OutputStream out) {
try (PrintStream ps = new PrintStream(out, false,
UTF_8.name())) {
CHARSET.name())) {
ps.print("version "); //$NON-NLS-1$
ps.print(VERSION + "\n"); //$NON-NLS-1$
ps.print("oid " + HASH_FUNCTION_NAME + ":"); //$NON-NLS-1$ //$NON-NLS-2$
@ -143,7 +143,7 @@ public class LfsPointer implements Comparable<LfsPointer> {
ps.print(size + "\n"); //$NON-NLS-1$
} catch (UnsupportedEncodingException e) {
// should not happen, we are using a standard charset
throw new UnsupportedCharsetException(UTF_8.name());
throw new UnsupportedCharsetException(CHARSET.name());
}
}
@ -165,7 +165,7 @@ public class LfsPointer implements Comparable<LfsPointer> {
long sz = -1;
try (BufferedReader br = new BufferedReader(
new InputStreamReader(in, UTF_8))) {
new InputStreamReader(in, CHARSET))) {
for (String s = br.readLine(); s != null; s = br.readLine()) {
if (s.startsWith("#") || s.length() == 0) { //$NON-NLS-1$
continue;

4
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.lfs;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lfs.Protocol.OPERATION_UPLOAD;
import static org.eclipse.jgit.lfs.internal.LfsConnectionFactory.toRequest;
import static org.eclipse.jgit.transport.http.HttpConnection.HTTP_OK;
@ -204,7 +204,7 @@ public class LfsPrePushHook extends PrePushHook {
}
Gson gson = Protocol.gson();
api.getOutputStream().write(
gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(UTF_8));
gson.toJson(toRequest(OPERATION_UPLOAD, res)).getBytes(CHARSET));
int responseCode = api.getResponseCode();
if (responseCode != HTTP_OK) {
throw new IOException(

5
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java

@ -42,11 +42,12 @@
*/
package org.eclipse.jgit.lfs;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.MessageFormat;
@ -169,7 +170,7 @@ public class SmudgeFilter extends FilterCommand {
.write(gson
.toJson(LfsConnectionFactory
.toRequest(Protocol.OPERATION_DOWNLOAD, res))
.getBytes(StandardCharsets.UTF_8));
.getBytes(CHARSET));
int responseCode = lfsServerConn.getResponseCode();
if (responseCode != HttpConnection.HTTP_OK) {
throw new IOException(

6
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.pgm;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@ -612,7 +612,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
private BufferedReader readFromProcess(Process proc) throws Exception {
return new BufferedReader(
new InputStreamReader(proc.getInputStream(), UTF_8));
new InputStreamReader(proc.getInputStream(), CHARSET));
}
private void grepForEntry(String name, String mode, String... cmdline)
@ -750,7 +750,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
// found!
List<String> l = new ArrayList<>();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in, UTF_8));
new InputStreamReader(in, CHARSET));
String line;
while ((line = reader.readLine()) != null)
l.add(line);

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.pgm;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.IOException;
@ -151,7 +151,7 @@ public class CommandCatalog {
final BufferedReader cIn;
try {
final InputStream in = cUrl.openStream();
cIn = new BufferedReader(new InputStreamReader(in, UTF_8));
cIn = new BufferedReader(new InputStreamReader(in, CHARSET));
} catch (IOException err) {
// If we cannot read from the service list, go to the next.
//

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.pgm;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.File;
import java.io.IOException;
@ -217,7 +217,7 @@ public class Main {
}
PrintWriter createErrorWriter() {
return new PrintWriter(new OutputStreamWriter(System.err, UTF_8));
return new PrintWriter(new OutputStreamWriter(System.err, CHARSET));
}
private void execute(final String[] argv) throws Exception {

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.pgm.debug;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.eclipse.jgit.lib.Constants.MASTER;
import static org.eclipse.jgit.lib.Constants.R_HEADS;
@ -154,7 +154,7 @@ class BenchmarkReftable extends TextBuiltin {
throws IOException, FileNotFoundException {
RefList.Builder<Ref> list = new RefList.Builder<>();
try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(lsRemotePath), UTF_8))) {
new FileInputStream(lsRemotePath), CHARSET))) {
Ref last = null;
String line;
while ((line = br.readLine()) != null) {

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteReftable.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.pgm.debug;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.eclipse.jgit.lib.Constants.MASTER;
import static org.eclipse.jgit.lib.Constants.R_HEADS;
@ -192,7 +192,7 @@ class WriteReftable extends TextBuiltin {
static List<Ref> readRefs(String inputFile) throws IOException {
List<Ref> refs = new ArrayList<>();
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(inputFile), UTF_8))) {
new InputStreamReader(new FileInputStream(inputFile), CHARSET))) {
String line;
while ((line = br.readLine()) != null) {
ObjectId id = ObjectId.fromString(line.substring(0, 40));
@ -227,7 +227,7 @@ class WriteReftable extends TextBuiltin {
List<LogEntry> log = new ArrayList<>();
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(logPath), UTF_8))) {
new InputStreamReader(new FileInputStream(logPath), CHARSET))) {
@SuppressWarnings("nls")
Pattern pattern = Pattern.compile("([^,]+)" // 1: ref
+ ",([0-9]+(?:[.][0-9]+)?)" // 2: time

6
org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.ignore;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.File;
@ -158,7 +158,7 @@ public class CGitVsJGitRandomIgnorePatternTest {
this.gitDir = gitDir;
this.pattern = pattern;
Files.write(FileUtils.toPath(new File(gitDir, ".gitignore")),
(pattern + "\n").getBytes(UTF_8), StandardOpenOption.CREATE,
(pattern + "\n").getBytes(CHARSET), StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.WRITE);
}
@ -188,7 +188,7 @@ public class CGitVsJGitRandomIgnorePatternTest {
Process proc = Runtime.getRuntime().exec(command, new String[0],
gitDir);
try (OutputStream out = proc.getOutputStream()) {
out.write((path + "\n").getBytes(UTF_8));
out.write((path + "\n").getBytes(CHARSET));
out.flush();
}
return proc;

10
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolStreamTypeUtilTest.java

@ -42,7 +42,7 @@
package org.eclipse.jgit.api;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_CRLF;
import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_LF;
import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.DIRECT;
@ -150,8 +150,8 @@ public class EolStreamTypeUtilTest {
EolStreamType streamTypeWithBinaryCheck, String output,
String expectedConversion) throws Exception {
ByteArrayOutputStream b;
byte[] outputBytes = output.getBytes(UTF_8);
byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
byte[] outputBytes = output.getBytes(CHARSET);
byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
// test using output text and assuming it was declared TEXT
b = new ByteArrayOutputStream();
@ -277,8 +277,8 @@ public class EolStreamTypeUtilTest {
private void testCheckin(EolStreamType streamTypeText,
EolStreamType streamTypeWithBinaryCheck, String input,
String expectedConversion) throws Exception {
byte[] inputBytes = input.getBytes(UTF_8);
byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8);
byte[] inputBytes = input.getBytes(CHARSET);
byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET);
// test using input text and assuming it was declared TEXT
try (InputStream in = EolStreamTypeUtil.wrapInputStream(

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.api;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import java.util.List;
@ -88,7 +88,7 @@ public class NotesCommandTest extends RepositoryTestCase {
git.notesAdd().setObjectId(commit2).setMessage("data").call();
Note note = git.notesShow().setObjectId(commit2).call();
String content = new String(db.open(note.getData()).getCachedBytes(),
UTF_8);
CHARSET);
assertEquals(content, "data");
git.notesRemove().setObjectId(commit2).call();

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.api;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -592,7 +592,7 @@ public class PullCommandTest extends RepositoryTestCase {
private static void writeToFile(File actFile, String string)
throws IOException {
try (FileOutputStream fos = new FileOutputStream(actFile)) {
fos.write(string.getBytes(UTF_8));
fos.write(string.getBytes(CHARSET));
}
}
@ -606,7 +606,7 @@ public class PullCommandTest extends RepositoryTestCase {
bos.write(buffer, 0, read);
read = fis.read(buffer);
}
String content = new String(bos.toByteArray(), UTF_8);
String content = new String(bos.toByteArray(), CHARSET);
assertEquals(string, content);
}
}

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.api;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -396,7 +396,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
private static void writeToFile(File actFile, String string)
throws IOException {
try (FileOutputStream fos = new FileOutputStream(actFile)) {
fos.write(string.getBytes(UTF_8));
fos.write(string.getBytes(CHARSET));
}
}
@ -410,7 +410,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
bos.write(buffer, 0, read);
read = fis.read(buffer);
}
String content = new String(bos.toByteArray(), UTF_8);
String content = new String(bos.toByteArray(), CHARSET);
assertEquals(string, content);
}
}

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.api;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
@ -1464,7 +1464,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertEquals("GIT_AUTHOR_DATE='@123456789 -0100'", lines[2]);
PersonIdent parsedIdent = git.rebase().parseAuthor(
convertedAuthor.getBytes(UTF_8));
convertedAuthor.getBytes(CHARSET));
assertEquals(ident.getName(), parsedIdent.getName());
assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
// this is rounded to the last second
@ -1481,7 +1481,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertEquals("GIT_AUTHOR_DATE='@123456789 +0930'", lines[2]);
parsedIdent = git.rebase().parseAuthor(
convertedAuthor.getBytes(UTF_8));
convertedAuthor.getBytes(CHARSET));
assertEquals(ident.getName(), parsedIdent.getName());
assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress());
assertEquals(123456789000L, parsedIdent.getWhen().getTime());
@ -2104,7 +2104,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
int count = 0;
File todoFile = getTodoFile();
try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(todoFile), UTF_8))) {
new FileInputStream(todoFile), CHARSET))) {
String line = br.readLine();
while (line != null) {
int firstBlank = line.indexOf(' ');

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.diff;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -240,6 +240,6 @@ public abstract class AbstractDiffTestCase {
r.append(text.charAt(i));
r.append('\n');
}
return new RawText(r.toString().getBytes(UTF_8));
return new RawText(r.toString().getBytes(CHARSET));
}
}

24
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.diff;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@ -136,8 +136,8 @@ public class RawTextTest {
e = c.reduceCommonStartEnd(t("abQxy"), t("abRxy"), e);
assertEquals(new Edit(2, 3, 2, 3), e);
RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(UTF_8));
RawText b = new RawText("p\na b \nR\n c d \n".getBytes(UTF_8));
RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(CHARSET));
RawText b = new RawText("p\na b \nR\n c d \n".getBytes(CHARSET));
e = new Edit(0, 4, 0, 4);
e = RawTextComparator.WS_IGNORE_ALL.reduceCommonStartEnd(a, b, e);
assertEquals(new Edit(2, 3, 2, 3), e);
@ -149,14 +149,14 @@ public class RawTextTest {
RawText b;
Edit e;
a = new RawText("R\n y\n".getBytes(UTF_8));
b = new RawText("S\n\n y\n".getBytes(UTF_8));
a = new RawText("R\n y\n".getBytes(CHARSET));
b = new RawText("S\n\n y\n".getBytes(CHARSET));
e = new Edit(0, 2, 0, 3);
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
assertEquals(new Edit(0, 1, 0, 2), e);
a = new RawText("S\n\n y\n".getBytes(UTF_8));
b = new RawText("R\n y\n".getBytes(UTF_8));
a = new RawText("S\n\n y\n".getBytes(CHARSET));
b = new RawText("R\n y\n".getBytes(CHARSET));
e = new Edit(0, 3, 0, 2);
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
assertEquals(new Edit(0, 2, 0, 1), e);
@ -167,8 +167,8 @@ public class RawTextTest {
RawText a;
RawText b;
Edit e;
a = new RawText("start".getBytes(UTF_8));
b = new RawText("start of line".getBytes(UTF_8));
a = new RawText("start".getBytes(CHARSET));
b = new RawText("start of line".getBytes(CHARSET));
e = new Edit(0, 1, 0, 1);
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
assertEquals(new Edit(0, 1, 0, 1), e);
@ -179,8 +179,8 @@ public class RawTextTest {
RawText a;
RawText b;
Edit e;
a = new RawText("start".getBytes(UTF_8));
b = new RawText("start of\nlastline".getBytes(UTF_8));
a = new RawText("start".getBytes(CHARSET));
b = new RawText("start of\nlastline".getBytes(CHARSET));
e = new Edit(0, 1, 0, 2);
e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e);
assertEquals(new Edit(0, 1, 0, 2), e);
@ -239,6 +239,6 @@ public class RawTextTest {
r.append(text.charAt(i));
r.append('\n');
}
return new RawText(r.toString().getBytes(UTF_8));
return new RawText(r.toString().getBytes(CHARSET));
}
}

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.diff;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -82,7 +82,7 @@ public class SimilarityIndexTest {
+ "A\n" //
+ "B\n" //
+ "B\n" //
+ "B\n").getBytes(UTF_8);
+ "B\n").getBytes(CHARSET);
SimilarityIndex si = new SimilarityIndex();
si.hash(new ByteArrayInputStream(in), in.length, false);
assertEquals(2, si.size());
@ -130,12 +130,12 @@ public class SimilarityIndexTest {
+ "D\r\n" //
+ "B\r\n";
SimilarityIndex src = new SimilarityIndex();
byte[] bytes1 = text.getBytes(UTF_8);
byte[] bytes1 = text.getBytes(CHARSET);
src.hash(new ByteArrayInputStream(bytes1), bytes1.length, true);
src.sort();
SimilarityIndex dst = new SimilarityIndex();
byte[] bytes2 = text.replace("\r", "").getBytes(UTF_8);
byte[] bytes2 = text.replace("\r", "").getBytes(CHARSET);
dst.hash(new ByteArrayInputStream(bytes2), bytes2.length, true);
dst.sort();

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java vendored

@ -43,7 +43,7 @@
package org.eclipse.jgit.dircache;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@ -236,7 +236,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
private static Map<String, CGitIndexRecord> readLsFiles() throws Exception {
final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<>();
try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(pathOf("gitgit.lsfiles")), UTF_8))) {
new FileInputStream(pathOf("gitgit.lsfiles")), CHARSET))) {
String line;
while ((line = br.readLine()) != null) {
final CGitIndexRecord cr = new CGitIndexRecord(line);
@ -249,7 +249,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
private static Map<String, CGitLsTreeRecord> readLsTree() throws Exception {
final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<>();
try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(pathOf("gitgit.lstree")), UTF_8))) {
new FileInputStream(pathOf("gitgit.lstree")), CHARSET))) {
String line;
while ((line = br.readLine()) != null) {
final CGitLsTreeRecord cr = new CGitLsTreeRecord(line);

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.gitrepo;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -82,7 +82,7 @@ public class ManifestParserTest {
ManifestParser parser = new ManifestParser(
null, null, "master", baseUrl, null, null);
parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)));
parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)));
// Unfiltered projects should have them all.
results.clear();
results.add("foo");
@ -136,7 +136,7 @@ public class ManifestParserTest {
baseUrl, null, null);
try {
parser.read(new ByteArrayInputStream(
xmlContent.toString().getBytes(UTF_8)));
xmlContent.toString().getBytes(CHARSET)));
fail("ManifestParser did not throw exception for missing fetch");
} catch (IOException e) {
assertTrue(e.getCause() instanceof SAXException);

16
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.gitrepo;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@ -214,7 +214,7 @@ public class RepoCommandTest extends RepositoryTestCase {
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(UTF_8)))
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("platform/")
.setTargetURI("platform/superproject")
@ -225,7 +225,7 @@ public class RepoCommandTest extends RepositoryTestCase {
String firstIdStr = commit.getId().name() + ":" + ".gitmodules";
commit = new RepoCommand(dest)
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(UTF_8)))
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("platform/")
.setTargetURI("platform/superproject")
@ -266,7 +266,7 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put("platform/base", child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("platform/")
.setTargetURI("platform/superproject")
@ -308,7 +308,7 @@ public class RepoCommandTest extends RepositoryTestCase {
RevCommit commit = new RepoCommand(dest)
.setInputStream(new ByteArrayInputStream(
xmlContent.toString().getBytes(UTF_8)))
xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(new IndexedRepos())
.setURI("platform/")
.setTargetURI("platform/superproject")
@ -358,7 +358,7 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put("plugins/cookbook", child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI("")
.setTargetURI("gerrit")
@ -412,7 +412,7 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put(repoUrl, child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI(baseUrl)
.setTargetURI("gerrit")
@ -469,7 +469,7 @@ public class RepoCommandTest extends RepositoryTestCase {
repos.put(repoUrl, child);
RevCommit commit = cmd
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8)))
.setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET)))
.setRemoteReader(repos)
.setURI(baseUrl)
.setTargetURI(abs + "/superproject")

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.ignore;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -765,6 +765,6 @@ public class IgnoreNodeTest extends RepositoryTestCase {
for (String line : rules) {
data.append(line + "\n");
}
return new ByteArrayInputStream(data.toString().getBytes(UTF_8));
return new ByteArrayInputStream(data.toString().getBytes(CHARSET));
}
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java

@ -41,7 +41,7 @@
*/
package org.eclipse.jgit.indexdiff;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -128,7 +128,7 @@ public class IndexDiffWithSymlinkTest extends LocalDiskRepositoryTestCase {
File restoreScript = new File(testDir, name + ".sh");
try (OutputStream out = new BufferedOutputStream(
new FileOutputStream(restoreScript));
Writer writer = new OutputStreamWriter(out, UTF_8)) {
Writer writer = new OutputStreamWriter(out, CHARSET)) {
writer.write("echo `which git` 1>&2\n");
writer.write("echo `git --version` 1>&2\n");
writer.write("git init " + name + " && \\\n");

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java

@ -45,7 +45,7 @@
package org.eclipse.jgit.internal.storage.file;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -252,7 +252,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
ObjectId blobId;
try (ObjectInserter ins = bareRepo.newObjectInserter()) {
blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(UTF_8));
blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(CHARSET));
ins.flush();
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java

@ -47,7 +47,7 @@
package org.eclipse.jgit.internal.storage.file;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -522,7 +522,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
4294967295000L, 60));
commit.setCommitter(new PersonIdent("Joe Hacker", "joe2@example.com",
4294967295000L, 60));
commit.setEncoding(UTF_8);
commit.setEncoding(CHARSET);
commit.setMessage("\u00dcbergeeks");
ObjectId cid = insertCommit(commit);
assertEquals("4680908112778718f37e686cbebcc912730b3154", cid.name());

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.junit;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@ -418,6 +418,6 @@ public class TestRepositoryTest {
RevObject obj = tr.get(rw.parseTree(treeish), path);
assertSame(RevBlob.class, obj.getClass());
ObjectLoader loader = rw.getObjectReader().open(obj);
return new String(loader.getCachedBytes(), UTF_8);
return new String(loader.getCachedBytes(), CHARSET);
}
}

10
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java

@ -45,7 +45,7 @@
package org.eclipse.jgit.lib;
import static java.lang.Integer.valueOf;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.junit.JGitTestUtil.concat;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH;
import static org.eclipse.jgit.lib.Constants.OBJ_BAD;
@ -1454,7 +1454,7 @@ public class ObjectCheckerTest {
StringBuilder b = new StringBuilder();
entry(b, "100644 A");
entry(b, "100644 a");
byte[] data = b.toString().getBytes(UTF_8);
byte[] data = b.toString().getBytes(CHARSET);
checker.setSafeForWindows(true);
assertCorrupt("duplicate entry names", OBJ_TREE, data);
assertSkipListAccepts(OBJ_TREE, data);
@ -1468,7 +1468,7 @@ public class ObjectCheckerTest {
StringBuilder b = new StringBuilder();
entry(b, "100644 A");
entry(b, "100644 a");
byte[] data = b.toString().getBytes(UTF_8);
byte[] data = b.toString().getBytes(CHARSET);
checker.setSafeForMacOS(true);
assertCorrupt("duplicate entry names", OBJ_TREE, data);
assertSkipListAccepts(OBJ_TREE, data);
@ -1482,7 +1482,7 @@ public class ObjectCheckerTest {
StringBuilder b = new StringBuilder();
entry(b, "100644 \u0065\u0301");
entry(b, "100644 \u00e9");
byte[] data = b.toString().getBytes(UTF_8);
byte[] data = b.toString().getBytes(CHARSET);
checker.setSafeForMacOS(true);
assertCorrupt("duplicate entry names", OBJ_TREE, data);
assertSkipListAccepts(OBJ_TREE, data);
@ -1496,7 +1496,7 @@ public class ObjectCheckerTest {
StringBuilder b = new StringBuilder();
entry(b, "100644 A");
checker.setSafeForMacOS(true);
checker.checkTree(b.toString().getBytes(UTF_8));
checker.checkTree(b.toString().getBytes(CHARSET));
}
@Test

14
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.merge;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -756,7 +756,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
}
binary[50] = '\0';
writeTrashFile("file", new String(binary, UTF_8));
writeTrashFile("file", new String(binary, CHARSET));
git.add().addFilepattern("file").call();
RevCommit first = git.commit().setMessage("added file").call();
@ -764,7 +764,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
int idx = LINELEN * 1200 + 1;
byte save = binary[idx];
binary[idx] = '@';
writeTrashFile("file", new String(binary, UTF_8));
writeTrashFile("file", new String(binary, CHARSET));
binary[idx] = save;
git.add().addFilepattern("file").call();
@ -773,7 +773,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
git.checkout().setCreateBranch(true).setStartPoint(first).setName("side").call();
binary[LINELEN * 1500 + 1] = '!';
writeTrashFile("file", new String(binary, UTF_8));
writeTrashFile("file", new String(binary, CHARSET));
git.add().addFilepattern("file").call();
RevCommit sideCommit = git.commit().setAll(true)
.setMessage("modified file l 1500").call();
@ -935,7 +935,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
merger.getMergeResults().get("file");
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
fmt.formatMerge(out, merger.getMergeResults().get("file"),
"BASE", "OURS", "THEIRS", UTF_8.name());
"BASE", "OURS", "THEIRS", CHARSET.name());
String expected = "<<<<<<< OURS\n"
+ "1master\n"
+ "=======\n"
@ -943,7 +943,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
+ ">>>>>>> THEIRS\n"
+ "2\n"
+ "3";
assertEquals(expected, new String(out.toByteArray(), UTF_8));
assertEquals(expected, new String(out.toByteArray(), CHARSET));
}
}
}
@ -1328,6 +1328,6 @@ public class ResolveMergerTest extends RepositoryTestCase {
if (obj == null) {
return null;
}
return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), UTF_8);
return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), CHARSET);
}
}

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/GetTextTest.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.patch;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -83,7 +83,7 @@ public class GetTextTest {
@Test
public void testGetText_Convert() throws IOException {
final Charset csOld = ISO_8859_1;
final Charset csNew = UTF_8;
final Charset csNew = CHARSET;
final Patch p = parseTestPatchFile();
assertTrue(p.getErrors().isEmpty());
assertEquals(1, p.getFiles().size());
@ -103,7 +103,7 @@ public class GetTextTest {
@Test
public void testGetText_DiffCc() throws IOException {
final Charset csOld = ISO_8859_1;
final Charset csNew = UTF_8;
final Charset csNew = CHARSET;
final Patch p = parseTestPatchFile();
assertTrue(p.getErrors().isEmpty());
assertEquals(1, p.getFiles().size());

102
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.revwalk;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@ -114,7 +114,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
assertNull(c.getTree());
assertNull(c.parents);
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
c.parseCanonical(rw, body.toString().getBytes(CHARSET));
assertNotNull(c.getTree());
assertEquals(treeId, c.getTree().getId());
assertSame(rw.lookupTree(treeId), c.getTree());
@ -148,7 +148,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
final RevCommit c;
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
return c;
}
@ -161,7 +161,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
final RevCommit c;
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
assertEquals("", c.getFullMessage());
assertEquals("", c.getShortMessage());
@ -176,7 +176,7 @@ public class RevCommitParseTest extends RepositoryTestCase {
final RevCommit c;
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent());
assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent());
@ -185,13 +185,13 @@ public class RevCommitParseTest extends RepositoryTestCase {
@Test
public void testParse_implicit_UTF8_encoded() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
final RevCommit c;
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -205,13 +205,13 @@ public class RevCommitParseTest extends RepositoryTestCase {
@Test
public void testParse_implicit_mixed_encoded() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
final RevCommit c;
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -260,14 +260,14 @@ public class RevCommitParseTest extends RepositoryTestCase {
@Test
public void testParse_explicit_bad_encoded() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
b.write("encoding EUC-JP\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Hi\n".getBytes(UTF_8));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
b.write("encoding EUC-JP\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Hi\n".getBytes(CHARSET));
final RevCommit c;
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -291,14 +291,14 @@ public class RevCommitParseTest extends RepositoryTestCase {
@Test
public void testParse_explicit_bad_encoded2() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
b.write("encoding ISO-8859-1\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Hi\n".getBytes(UTF_8));
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET));
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
b.write("encoding ISO-8859-1\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Hi\n".getBytes(CHARSET));
final RevCommit c;
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -313,13 +313,13 @@ public class RevCommitParseTest extends RepositoryTestCase {
public void testParse_incorrectUtf8Name() throws Exception {
ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
.getBytes(UTF_8));
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
b.write("committer co <c@example.com> 1218123390 -0500\n"
.getBytes(UTF_8));
b.write("encoding 'utf8'\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("encoding 'utf8'\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
RevCommit c = new RevCommit(
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
@ -338,12 +338,12 @@ public class RevCommitParseTest extends RepositoryTestCase {
@Test
public void testParse_illegalEncoding() throws Exception {
ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("message\n".getBytes(UTF_8));
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("message\n".getBytes(CHARSET));
RevCommit c = new RevCommit(
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
@ -365,12 +365,12 @@ public class RevCommitParseTest extends RepositoryTestCase {
@Test
public void testParse_unsupportedEncoding() throws Exception {
ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8));
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8));
b.write("encoding it_IT.UTF8\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("message\n".getBytes(UTF_8));
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET));
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET));
b.write("encoding it_IT.UTF8\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("message\n".getBytes(CHARSET));
RevCommit c = new RevCommit(
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));

102
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.revwalk;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@ -98,7 +98,7 @@ public class RevTagParseTest extends RepositoryTestCase {
assertNull(c.getObject());
assertNull(c.getTagName());
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
c.parseCanonical(rw, b.toString().getBytes(CHARSET));
assertNotNull(c.getObject());
assertEquals(id, c.getObject().getId());
assertSame(rw.lookupAny(id, typeCode), c.getObject());
@ -141,7 +141,7 @@ public class RevTagParseTest extends RepositoryTestCase {
assertNull(c.getObject());
assertNull(c.getTagName());
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
c.parseCanonical(rw, body.toString().getBytes(CHARSET));
assertNotNull(c.getObject());
assertEquals(treeId, c.getObject().getId());
assertSame(rw.lookupTree(treeId), c.getObject());
@ -189,7 +189,7 @@ public class RevTagParseTest extends RepositoryTestCase {
assertNull(c.getObject());
assertNull(c.getTagName());
c.parseCanonical(rw, body.toString().getBytes(UTF_8));
c.parseCanonical(rw, body.toString().getBytes(CHARSET));
assertNotNull(c.getObject());
assertEquals(treeId, c.getObject().getId());
assertSame(rw.lookupTree(treeId), c.getObject());
@ -213,7 +213,7 @@ public class RevTagParseTest extends RepositoryTestCase {
final RevTag c;
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8));
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET));
return c;
}
@ -221,17 +221,17 @@ public class RevTagParseTest extends RepositoryTestCase {
public void testParse_implicit_UTF8_encoded() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
.getBytes(UTF_8));
b.write("type tree\n".getBytes(UTF_8));
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("type tree\n".getBytes(CHARSET));
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
b
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
.getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
final RevTag c;
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -246,15 +246,15 @@ public class RevTagParseTest extends RepositoryTestCase {
public void testParse_implicit_mixed_encoded() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
.getBytes(UTF_8));
b.write("type tree\n".getBytes(UTF_8));
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("type tree\n".getBytes(CHARSET));
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
b.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
.getBytes(ISO_8859_1));
b.write("\n".getBytes(UTF_8));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
b.write("\n".getBytes(CHARSET));
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
final RevTag c;
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -307,17 +307,17 @@ public class RevTagParseTest extends RepositoryTestCase {
public void testParse_explicit_bad_encoded() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
.getBytes(UTF_8));
b.write("type tree\n".getBytes(UTF_8));
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("type tree\n".getBytes(CHARSET));
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
b
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
.getBytes(ISO_8859_1));
b.write("encoding EUC-JP\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Hi\n".getBytes(UTF_8));
b.write("encoding EUC-JP\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Hi\n".getBytes(CHARSET));
final RevTag c;
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -342,17 +342,17 @@ public class RevTagParseTest extends RepositoryTestCase {
public void testParse_explicit_bad_encoded2() throws Exception {
final ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
.getBytes(UTF_8));
b.write("type tree\n".getBytes(UTF_8));
b.write("tag v1.2.3.4.5\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("type tree\n".getBytes(CHARSET));
b.write("tag v1.2.3.4.5\n".getBytes(CHARSET));
b
.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n"
.getBytes(UTF_8));
b.write("encoding ISO-8859-1\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("Hi\n".getBytes(UTF_8));
.getBytes(CHARSET));
b.write("encoding ISO-8859-1\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("Hi\n".getBytes(CHARSET));
final RevTag c;
c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
c.parseCanonical(new RevWalk(db), b.toByteArray());
@ -365,13 +365,13 @@ public class RevTagParseTest extends RepositoryTestCase {
@Test
public void testParse_illegalEncoding() throws Exception {
ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("type tree\n".getBytes(UTF_8));
b.write("tag v1.0\n".getBytes(UTF_8));
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8));
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("message\n".getBytes(UTF_8));
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("type tree\n".getBytes(CHARSET));
b.write("tag v1.0\n".getBytes(CHARSET));
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET));
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("message\n".getBytes(CHARSET));
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
t.parseCanonical(new RevWalk(db), b.toByteArray());
@ -384,13 +384,13 @@ public class RevTagParseTest extends RepositoryTestCase {
@Test
public void testParse_unsupportedEncoding() throws Exception {
ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8));
b.write("type tree\n".getBytes(UTF_8));
b.write("tag v1.0\n".getBytes(UTF_8));
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8));
b.write("encoding it_IT.UTF8\n".getBytes(UTF_8));
b.write("\n".getBytes(UTF_8));
b.write("message\n".getBytes(UTF_8));
b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET));
b.write("type tree\n".getBytes(CHARSET));
b.write("tag v1.0\n".getBytes(CHARSET));
b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET));
b.write("encoding it_IT.UTF8\n".getBytes(CHARSET));
b.write("\n".getBytes(CHARSET));
b.write("message\n".getBytes(CHARSET));
RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
t.parseCanonical(new RevWalk(db), b.toByteArray());

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.storage.file;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.util.FileUtils.pathToString;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@ -105,7 +105,7 @@ public class FileBasedConfigTest {
@Test
public void testUTF8withoutBOM() throws IOException, ConfigInvalidException {
final File file = createFile(CONTENT1.getBytes(UTF_8));
final File file = createFile(CONTENT1.getBytes(CHARSET));
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
config.load();
assertEquals(ALICE, config.getString(USER, null, NAME));
@ -121,7 +121,7 @@ public class FileBasedConfigTest {
bos1.write(0xEF);
bos1.write(0xBB);
bos1.write(0xBF);
bos1.write(CONTENT1.getBytes(UTF_8));
bos1.write(CONTENT1.getBytes(CHARSET));
final File file = createFile(bos1.toByteArray());
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
@ -135,7 +135,7 @@ public class FileBasedConfigTest {
bos2.write(0xEF);
bos2.write(0xBB);
bos2.write(0xBF);
bos2.write(CONTENT2.getBytes(UTF_8));
bos2.write(CONTENT2.getBytes(CHARSET));
assertArrayEquals(bos2.toByteArray(), IO.readFully(file));
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java

@ -45,7 +45,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -199,7 +199,7 @@ public class BundleWriterTest extends SampleDataRepositoryTestCase {
Ref ref = repo.exactRef(refName);
assertNotNull(ref);
assertEquals(id, ref.getObjectId());
assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), UTF_8));
assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), CHARSET));
}
}

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListPBE;
import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListTrans;
import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.folderDelete;
@ -360,7 +360,7 @@ public class WalkEncryptionTest {
* @throws Exception
*/
static String textRead(File file) throws Exception {
return new String(Files.readAllBytes(file.toPath()), UTF_8);
return new String(Files.readAllBytes(file.toPath()), CHARSET);
}
/**
@ -371,7 +371,7 @@ public class WalkEncryptionTest {
* @throws Exception
*/
static void textWrite(File file, String text) throws Exception {
Files.write(file.toPath(), text.getBytes(UTF_8));
Files.write(file.toPath(), text.getBytes(CHARSET));
}
static void verifyFileContent(File fileOne, File fileTwo)
@ -741,7 +741,7 @@ public class WalkEncryptionTest {
AmazonS3 s3 = new AmazonS3(props);
String file = JGIT_USER + "-" + UUID.randomUUID().toString();
String path = JGIT_REMOTE_DIR + "/" + file;
s3.put(bucket, path, file.getBytes(UTF_8));
s3.put(bucket, path, file.getBytes(CHARSET));
s3.delete(bucket, path);
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawSubStringPatternTest.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.util;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -93,7 +93,7 @@ public class RawSubStringPatternTest extends RepositoryTestCase {
}
private static RawCharSequence raw(String text) {
byte[] bytes = text.getBytes(UTF_8);
byte[] bytes = text.getBytes(CHARSET);
return new RawCharSequence(bytes, 0, bytes.length);
}
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoLFInputStreamTest.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.util.io;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
@ -129,6 +129,6 @@ public class AutoLFInputStreamTest {
}
private static byte[] asBytes(String in) {
return in.getBytes(UTF_8);
return in.getBytes(CHARSET);
}
}

14
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/sha1/SHA1Test.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.util.sha1;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -95,15 +95,15 @@ public class SHA1Test {
.fromString("a9993e364706816aba3e25717850c26c9cd0d89d");
MessageDigest m = MessageDigest.getInstance("SHA-1");
m.update(TEST1.getBytes(UTF_8));
m.update(TEST1.getBytes(CHARSET));
ObjectId m1 = ObjectId.fromRaw(m.digest());
SHA1 s = SHA1.newInstance();
s.update(TEST1.getBytes(UTF_8));
s.update(TEST1.getBytes(CHARSET));
ObjectId s1 = ObjectId.fromRaw(s.digest());
s.reset();
s.update(TEST1.getBytes(UTF_8));
s.update(TEST1.getBytes(CHARSET));
ObjectId s2 = s.toObjectId();
assertEquals(m1, s1);
@ -117,15 +117,15 @@ public class SHA1Test {
.fromString("84983e441c3bd26ebaae4aa1f95129e5e54670f1");
MessageDigest m = MessageDigest.getInstance("SHA-1");
m.update(TEST2.getBytes(UTF_8));
m.update(TEST2.getBytes(CHARSET));
ObjectId m1 = ObjectId.fromRaw(m.digest());
SHA1 s = SHA1.newInstance();
s.update(TEST2.getBytes(UTF_8));
s.update(TEST2.getBytes(CHARSET));
ObjectId s1 = ObjectId.fromRaw(s.digest());
s.reset();
s.update(TEST2.getBytes(UTF_8));
s.update(TEST2.getBytes(CHARSET));
ObjectId s2 = s.toObjectId();
assertEquals(m1, s1);

6
org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java

@ -42,7 +42,7 @@
*/
package org.eclipse.jgit.hooks;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -158,7 +158,7 @@ abstract class GitHook<T> implements Callable<T> {
PrintStream hookErrRedirect = null;
try {
hookErrRedirect = new PrintStream(errorByteArray, false,
UTF_8.name());
CHARSET.name());
} catch (UnsupportedEncodingException e) {
// UTF-8 is guaranteed to be available
}
@ -167,7 +167,7 @@ abstract class GitHook<T> implements Callable<T> {
hookErrRedirect, getStdinArgs());
if (result.isExecutedWithError()) {
throw new AbortedByHookException(
new String(errorByteArray.toByteArray(), UTF_8),
new String(errorByteArray.toByteArray(), CHARSET),
getHookName(), result.getExitCode());
}
}

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.dfs;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.util.Arrays;
@ -67,7 +67,7 @@ public abstract class DfsStreamKey {
*/
public static DfsStreamKey of(DfsRepositoryDescription repo, String name,
@Nullable PackExt ext) {
return new ByteArrayDfsStreamKey(repo, name.getBytes(UTF_8), ext);
return new ByteArrayDfsStreamKey(repo, name.getBytes(CHARSET), ext);
}
final int hash;

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.file;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.File;
@ -187,6 +187,6 @@ class GcLog {
if (content.length() > 0) {
nonEmpty = true;
}
lock.write(content.getBytes(UTF_8));
lock.write(content.getBytes(CHARSET));
}
}

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LazyObjectIdSetFile.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.file;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedReader;
import java.io.File;
@ -86,7 +86,7 @@ public class LazyObjectIdSetFile implements ObjectIdSet {
private ObjectIdOwnerMap<Entry> load() {
ObjectIdOwnerMap<Entry> r = new ObjectIdOwnerMap<>();
try (FileInputStream fin = new FileInputStream(src);
Reader rin = new InputStreamReader(fin, UTF_8);
Reader rin = new InputStreamReader(fin, CHARSET);
BufferedReader br = new BufferedReader(rin)) {
MutableObjectId id = new MutableObjectId();
for (String line; (line = br.readLine()) != null;) {

8
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.BlockWriter.compare;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
@ -138,7 +138,7 @@ class BlockReader {
if (blockType == LOG_BLOCK_TYPE) {
len -= 9;
}
return RawParseUtils.decode(UTF_8, nameBuf, 0, len);
return RawParseUtils.decode(CHARSET, nameBuf, 0, len);
}
boolean match(byte[] match, boolean matchIsPrefix) {
@ -171,7 +171,7 @@ class BlockReader {
}
Ref readRef() throws IOException {
String name = RawParseUtils.decode(UTF_8, nameBuf, 0, nameLen);
String name = RawParseUtils.decode(CHARSET, nameBuf, 0, nameLen);
switch (valueType & VALUE_TYPE_MASK) {
case VALUE_NONE: // delete
return newRef(name);
@ -266,7 +266,7 @@ class BlockReader {
private String readValueString() {
int len = readVarint32();
int end = ptr + len;
String s = RawParseUtils.decode(UTF_8, buf, ptr, end);
String s = RawParseUtils.decode(CHARSET, buf, ptr, end);
ptr = end;
return s;
}

12
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.INDEX_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.LOG_BLOCK_TYPE;
@ -440,7 +440,7 @@ class BlockWriter {
}
private static byte[] nameUtf8(Ref ref) {
return ref.getName().getBytes(UTF_8);
return ref.getName().getBytes(CHARSET);
}
}
@ -559,13 +559,13 @@ class BlockWriter {
this.newId = newId;
this.timeSecs = who.getWhen().getTime() / 1000L;
this.tz = (short) who.getTimeZoneOffset();
this.name = who.getName().getBytes(UTF_8);
this.email = who.getEmailAddress().getBytes(UTF_8);
this.msg = message.getBytes(UTF_8);
this.name = who.getName().getBytes(CHARSET);
this.email = who.getEmailAddress().getBytes(CHARSET);
this.msg = message.getBytes(CHARSET);
}
static byte[] key(String ref, long index) {
byte[] name = ref.getBytes(UTF_8);
byte[] name = ref.getBytes(CHARSET);
byte[] key = Arrays.copyOf(name, name.length + 1 + 8);
NB.encodeInt64(key, key.length - 8, reverseUpdateIndex(index));
return key;

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableOutputStream.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_HEADER_LEN;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.INDEX_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.LOG_BLOCK_TYPE;
@ -160,7 +160,7 @@ class ReftableOutputStream extends OutputStream {
}
void writeVarintString(String s) {
writeVarintString(s.getBytes(UTF_8));
writeVarintString(s.getBytes(CHARSET));
}
void writeVarintString(byte[] msg) {

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.internal.storage.reftable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.internal.storage.reftable.BlockReader.decodeBlockLen;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_BLOCK_TYPE;
import static org.eclipse.jgit.internal.storage.reftable.ReftableConstants.FILE_FOOTER_LEN;
@ -182,7 +182,7 @@ public class ReftableReader extends Reftable {
public RefCursor seekRef(String refName) throws IOException {
initRefIndex();
byte[] key = refName.getBytes(UTF_8);
byte[] key = refName.getBytes(CHARSET);
boolean prefix = key[key.length - 1] == '/';
RefCursorImpl i = new RefCursorImpl(refEnd, key, prefix);
@ -223,7 +223,7 @@ public class ReftableReader extends Reftable {
initLogIndex();
if (logPosition > 0) {
byte[] key = LogEntry.key(refName, updateIndex);
byte[] match = refName.getBytes(UTF_8);
byte[] match = refName.getBytes(CHARSET);
LogCursorImpl i = new LogCursorImpl(logEnd, match);
i.block = seek(LOG_BLOCK_TYPE, key, logIndex, logPosition, logEnd);
return i;

5
org.eclipse.jgit/src/org/eclipse/jgit/lib/BlobBasedConfig.java

@ -45,6 +45,8 @@
package org.eclipse.jgit.lib;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.MessageFormat;
@ -81,8 +83,7 @@ public class BlobBasedConfig extends Config {
super(base);
final String decoded;
if (isUtf8(blob)) {
decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET,
blob, 3, blob.length);
decoded = RawParseUtils.decode(CHARSET, blob, 3, blob.length);
} else {
decoded = RawParseUtils.decode(blob);
}

5
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

@ -51,6 +51,8 @@
package org.eclipse.jgit.lib;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
@ -1166,8 +1168,7 @@ public class Config {
String decoded;
if (isUtf8(bytes)) {
decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET, bytes, 3,
bytes.length);
decoded = RawParseUtils.decode(CHARSET, bytes, 3, bytes.length);
} else {
decoded = RawParseUtils.decode(bytes);
}

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java

@ -228,10 +228,10 @@ public final class Constants {
public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };
/** Native character encoding for commit messages, file names... */
public static final Charset CHARSET = UTF_8;
public static final Charset CHARSET;
/** Native character encoding for commit messages, file names... */
public static final String CHARACTER_ENCODING = CHARSET.name();
public static final String CHARACTER_ENCODING;
/** Default main branch name */
public static final String MASTER = "master";
@ -654,6 +654,8 @@ public final class Constants {
static {
if (OBJECT_ID_LENGTH != newMessageDigest().getDigestLength())
throw new LinkageError(JGitText.get().incorrectOBJECT_ID_LENGTH);
CHARSET = UTF_8;
CHARACTER_ENCODING = CHARSET.name();
}
/** name of the file containing the commit msg for a merge commit */

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.lib;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.BufferedOutputStream;
import java.io.File;
@ -183,7 +183,7 @@ public class RebaseTodoFile {
switch (tokenCount) {
case 0:
String actionToken = new String(buf, tokenBegin,
nextSpace - tokenBegin - 1, UTF_8);
nextSpace - tokenBegin - 1, CHARSET);
tokenBegin = nextSpace;
action = RebaseTodoLine.Action.parse(actionToken);
if (action == null)
@ -192,7 +192,7 @@ public class RebaseTodoFile {
case 1:
nextSpace = RawParseUtils.next(buf, tokenBegin, ' ');
String commitToken = new String(buf, tokenBegin,
nextSpace - tokenBegin - 1, UTF_8);
nextSpace - tokenBegin - 1, CHARSET);
tokenBegin = nextSpace;
commit = AbbreviatedObjectId.fromString(commitToken);
break;

4
org.eclipse.jgit/src/org/eclipse/jgit/lib/TextProgressMonitor.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.lib;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.io.OutputStreamWriter;
@ -63,7 +63,7 @@ public class TextProgressMonitor extends BatchingProgressMonitor {
* Initialize a new progress monitor.
*/
public TextProgressMonitor() {
this(new PrintWriter(new OutputStreamWriter(System.err, UTF_8)));
this(new PrintWriter(new OutputStreamWriter(System.err, CHARSET)));
}
/**

4
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java

@ -44,7 +44,7 @@
package org.eclipse.jgit.revwalk;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.nio.charset.Charset;
@ -539,7 +539,7 @@ public class RevCommit extends RevObject {
try {
return getEncoding();
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
return UTF_8;
return CHARSET;
}
}

6
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java

@ -45,7 +45,7 @@
package org.eclipse.jgit.revwalk;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.nio.charset.Charset;
@ -169,7 +169,7 @@ public class RevTag extends RevObject {
int p = pos.value += 4; // "tag "
final int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
tagName = RawParseUtils.decode(UTF_8, rawTag, p, nameEnd);
tagName = RawParseUtils.decode(CHARSET, rawTag, p, nameEnd);
if (walk.isRetainBody())
buffer = rawTag;
@ -257,7 +257,7 @@ public class RevTag extends RevObject {
try {
return RawParseUtils.parseEncoding(buffer);
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
return UTF_8;
return CHARSET;
}
}

6
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java

@ -49,6 +49,8 @@
package org.eclipse.jgit.storage.file;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
@ -154,7 +156,7 @@ public class FileBasedConfig extends StoredConfig {
} else {
final String decoded;
if (isUtf8(in)) {
decoded = RawParseUtils.decode(RawParseUtils.UTF8_CHARSET,
decoded = RawParseUtils.decode(CHARSET,
in, 3, in.length);
utf8Bom = true;
} else {
@ -198,7 +200,7 @@ public class FileBasedConfig extends StoredConfig {
bos.write(0xEF);
bos.write(0xBB);
bos.write(0xBF);
bos.write(text.getBytes(RawParseUtils.UTF8_CHARSET.name()));
bos.write(text.getBytes(CHARSET));
out = bos.toByteArray();
} else {
out = Constants.encode(text);

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -638,7 +638,7 @@ public class AmazonS3 {
try {
final Mac m = Mac.getInstance(HMAC);
m.init(privateKey);
sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(UTF_8)));
sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(CHARSET)));
} catch (NoSuchAlgorithmException e) {
throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage()));
} catch (InvalidKeyException e) {

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.File;
import java.security.InvalidKeyException;
@ -102,7 +102,7 @@ public class HMACSHA1NonceGenerator implements NonceGenerator {
}
String input = path + ":" + String.valueOf(timestamp); //$NON-NLS-1$
byte[] rawHmac = mac.doFinal(input.getBytes(UTF_8));
byte[] rawHmac = mac.doFinal(input.getBytes(CHARSET));
return Long.toString(timestamp) + "-" + toHex(rawHmac); //$NON-NLS-1$
}

10
org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION;
import static org.eclipse.jgit.util.HttpSupport.HDR_WWW_AUTHENTICATE;
@ -315,7 +315,7 @@ abstract class HttpAuthMethod {
@Override
void configureRequest(final HttpConnection conn) throws IOException {
String ident = user + ":" + pass; //$NON-NLS-1$
String enc = Base64.encodeBytes(ident.getBytes(UTF_8));
String enc = Base64.encodeBytes(ident.getBytes(CHARSET));
conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
+ " " + enc); //$NON-NLS-1$
}
@ -430,15 +430,15 @@ abstract class HttpAuthMethod {
private static String H(String data) {
MessageDigest md = newMD5();
md.update(data.getBytes(UTF_8));
md.update(data.getBytes(CHARSET));
return LHEX(md.digest());
}
private static String KD(String secret, String data) {
MessageDigest md = newMD5();
md.update(secret.getBytes(UTF_8));
md.update(secret.getBytes(CHARSET));
md.update((byte) ':');
md.update(data.getBytes(UTF_8));
md.update(data.getBytes(CHARSET));
return LHEX(md.digest());
}

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/ProgressSpinner.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.IOException;
import java.io.OutputStream;
@ -141,7 +141,7 @@ public class ProgressSpinner {
private void write(String s) {
if (write) {
try {
out.write(s.getBytes(UTF_8));
out.write(s.getBytes(CHARSET));
out.flush();
} catch (IOException e) {
write = false;

6
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateIdent.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.util.RawParseUtils.lastIndexOfTrim;
import java.text.SimpleDateFormat;
@ -95,7 +95,7 @@ public class PushCertificateIdent {
*/
public static PushCertificateIdent parse(String str) {
MutableInteger p = new MutableInteger();
byte[] raw = str.getBytes(UTF_8);
byte[] raw = str.getBytes(CHARSET);
int tzBegin = raw.length - 1;
tzBegin = lastIndexOfTrim(raw, ' ', tzBegin);
if (tzBegin < 0 || raw[tzBegin] != ' ') {
@ -129,7 +129,7 @@ public class PushCertificateIdent {
idEnd = raw.length;
}
}
String id = new String(raw, 0, idEnd, UTF_8);
String id = new String(raw, 0, idEnd, CHARSET);
return new PushCertificateIdent(str, id, when * 1000L, tz);
}

6
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
import static org.eclipse.jgit.lib.FileMode.TYPE_FILE;
@ -292,7 +292,7 @@ public class PushCertificateStore implements AutoCloseable {
ObjectLoader loader =
tw.getObjectReader().open(tw.getObjectId(0), OBJ_BLOB);
try (InputStream in = loader.openStream();
Reader r = new BufferedReader(new InputStreamReader(in, UTF_8))) {
Reader r = new BufferedReader(new InputStreamReader(in, CHARSET))) {
return PushCertificateParser.fromReader(r);
}
}
@ -473,7 +473,7 @@ public class PushCertificateStore implements AutoCloseable {
DirCacheEditor editor = dc.editor();
String certText = pc.cert.toText() + pc.cert.getSignature();
final ObjectId certId = inserter.insert(OBJ_BLOB, certText.getBytes(UTF_8));
final ObjectId certId = inserter.insert(OBJ_BLOB, certText.getBytes(CHARSET));
boolean any = false;
for (ReceiveCommand cmd : pc.cert.getCommands()) {
if (byRef != null && !commandsEqual(cmd, byRef.get(cmd.getRefName()))) {

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SYMREF;
@ -74,7 +74,7 @@ import org.eclipse.jgit.util.RefMap;
public abstract class RefAdvertiser {
/** Advertiser which frames lines in a {@link PacketLineOut} format. */
public static class PacketLineOutRefAdvertiser extends RefAdvertiser {
private final CharsetEncoder utf8 = UTF_8.newEncoder();
private final CharsetEncoder utf8 = CHARSET.newEncoder();
private final PacketLineOut pckOut;
private byte[] binArr = new byte[256];

3
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java

@ -46,6 +46,7 @@
package org.eclipse.jgit.transport;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.io.BufferedReader;
@ -147,7 +148,7 @@ public abstract class Transport implements AutoCloseable {
BufferedReader br;
try {
InputStream urlIn = url.openStream();
br = new BufferedReader(new InputStreamReader(urlIn, "UTF-8")); //$NON-NLS-1$
br = new BufferedReader(new InputStreamReader(urlIn, CHARSET));
} catch (IOException err) {
// If we cannot read from the service list, go to the next.
//

9
org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java

@ -6,9 +6,8 @@
package org.eclipse.jgit.util;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Arrays;
@ -55,7 +54,7 @@ public class Base64 {
+ "abcdefghijklmnopqrstuvwxyz" // //$NON-NLS-1$
+ "0123456789" // //$NON-NLS-1$
+ "+/" // //$NON-NLS-1$
).getBytes(UTF_8);
).getBytes(CHARSET);
DEC = new byte[128];
Arrays.fill(DEC, INVALID_DEC);
@ -178,7 +177,7 @@ public class Base64 {
e += 4;
}
return new String(outBuff, 0, e, StandardCharsets.UTF_8);
return new String(outBuff, 0, e, CHARSET);
}
/**
@ -294,7 +293,7 @@ public class Base64 {
* @return the decoded data
*/
public static byte[] decode(String s) {
byte[] bytes = s.getBytes(UTF_8);
byte[] bytes = s.getBytes(CHARSET);
return decode(bytes, 0, bytes.length);
}
}

4
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java

@ -43,6 +43,8 @@
package org.eclipse.jgit.util;
import static org.eclipse.jgit.lib.Constants.CHARSET;
import java.io.File;
import java.io.PrintStream;
import java.nio.file.Files;
@ -124,7 +126,7 @@ public class FS_Win32_Cygwin extends FS_Win32 {
try {
w = readPipe(dir, //
new String[] { cygpath, "--windows", "--absolute", pn }, // //$NON-NLS-1$ //$NON-NLS-2$
"UTF-8"); //$NON-NLS-1$
CHARSET.name());
} catch (CommandFailedException e) {
LOG.warn(e.getMessage());
return null;

4
org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java

@ -44,6 +44,8 @@
package org.eclipse.jgit.util;
import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.ConnectException;
@ -179,7 +181,7 @@ public class HttpSupport {
if (key == null || key.length() == 0)
return;
try {
urlstr.append(URLEncoder.encode(key, "UTF-8")); //$NON-NLS-1$
urlstr.append(URLEncoder.encode(key, CHARACTER_ENCODING));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e);
}

Loading…
Cancel
Save