diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java index 725a5902d..ad02cd311 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.http.test; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.BufferedReader; @@ -120,7 +121,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/a").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test", r.readLine()); assertEquals("", r.readLine()); assertEquals("/a", r.readLine()); @@ -129,7 +131,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/b").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test", r.readLine()); assertEquals("", r.readLine()); assertEquals("/b", r.readLine()); @@ -155,7 +158,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/a").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test1", r.readLine()); assertEquals("", r.readLine()); assertEquals("/a", r.readLine()); @@ -183,7 +187,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/a/b").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test1", r.readLine()); assertEquals("", r.readLine()); // No RegexGroupFilter defaults to first group. @@ -193,7 +198,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/c/d").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test2", r.readLine()); assertEquals("", r.readLine()); assertEquals("/c", r.readLine()); @@ -202,7 +208,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/e/f/g").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test3", r.readLine()); assertEquals("/e/f", r.readLine()); assertEquals("/g", r.readLine()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java index 0647167ea..4bf26b628 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java @@ -42,6 +42,7 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -334,7 +335,7 @@ public class PushCertificateParserTest { assertFalse(input.contains(PushCertificateParser.END_CERT)); input += input; Reader reader = new InputStreamReader( - new ByteArrayInputStream(Constants.encode(input))); + new ByteArrayInputStream(Constants.encode(input)), UTF_8); assertNotNull(PushCertificateParser.fromReader(reader)); assertNotNull(PushCertificateParser.fromReader(reader)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java index 68e012952..fa4fd6506 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.lib.ObjectId.zeroId; import static org.eclipse.jgit.lib.RefUpdate.Result.FAST_FORWARD; import static org.eclipse.jgit.lib.RefUpdate.Result.LOCK_FAILURE; @@ -96,7 +97,9 @@ public class PushCertificateStoreTest { + "-----END PGP SIGNATURE-----\n"); try { return PushCertificateParser.fromReader(new InputStreamReader( - new ByteArrayInputStream(Constants.encode(cert.toString())))); + new ByteArrayInputStream( + Constants.encode(cert.toString())), + UTF_8)); } catch (IOException e) { throw new IllegalArgumentException(e); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java index 928fb2ed9..fa303ec28 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.util; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.BufferedReader; @@ -105,7 +106,7 @@ public class IOReadLineTest { private Reader newReader(String in) { Reader r = new InputStreamReader( - new ByteArrayInputStream(Constants.encode(in))); + new ByteArrayInputStream(Constants.encode(in)), UTF_8); if (buffered) { r = new BufferedReader(r); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java index 480055c2e..a5fa3fee3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java @@ -43,6 +43,8 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -241,7 +243,8 @@ public class OpenSshConfig implements ConfigRepository { private Map parse(InputStream in) throws IOException { final Map m = new LinkedHashMap<>(); - final BufferedReader br = new BufferedReader(new InputStreamReader(in)); + final BufferedReader br = new BufferedReader( + new InputStreamReader(in, UTF_8)); final List current = new ArrayList<>(4); String line;