Browse Source

Explicitly specify charset in constructor of InputStreamReader

Change-Id: Id43e27c590f41f7435c2ca1d127f27e45745da7f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.2
David Pursehouse 6 years ago
parent
commit
dbabe5f37a
  1. 19
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java
  2. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
  3. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java
  4. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java
  5. 5
      org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java

19
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java

@ -43,6 +43,7 @@
package org.eclipse.jgit.http.test; package org.eclipse.jgit.http.test;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -120,7 +121,8 @@ public class RegexPipelineTest extends HttpTestCase {
c = ((HttpURLConnection) uri.resolve("/a").toURL() c = ((HttpURLConnection) uri.resolve("/a").toURL()
.openConnection()); .openConnection());
assertEquals(200, c.getResponseCode()); 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("test", r.readLine());
assertEquals("", r.readLine()); assertEquals("", r.readLine());
assertEquals("/a", r.readLine()); assertEquals("/a", r.readLine());
@ -129,7 +131,8 @@ public class RegexPipelineTest extends HttpTestCase {
c = ((HttpURLConnection) uri.resolve("/b").toURL() c = ((HttpURLConnection) uri.resolve("/b").toURL()
.openConnection()); .openConnection());
assertEquals(200, c.getResponseCode()); 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("test", r.readLine());
assertEquals("", r.readLine()); assertEquals("", r.readLine());
assertEquals("/b", r.readLine()); assertEquals("/b", r.readLine());
@ -155,7 +158,8 @@ public class RegexPipelineTest extends HttpTestCase {
c = ((HttpURLConnection) uri.resolve("/a").toURL() c = ((HttpURLConnection) uri.resolve("/a").toURL()
.openConnection()); .openConnection());
assertEquals(200, c.getResponseCode()); 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("test1", r.readLine());
assertEquals("", r.readLine()); assertEquals("", r.readLine());
assertEquals("/a", r.readLine()); assertEquals("/a", r.readLine());
@ -183,7 +187,8 @@ public class RegexPipelineTest extends HttpTestCase {
c = ((HttpURLConnection) uri.resolve("/a/b").toURL() c = ((HttpURLConnection) uri.resolve("/a/b").toURL()
.openConnection()); .openConnection());
assertEquals(200, c.getResponseCode()); 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("test1", r.readLine());
assertEquals("", r.readLine()); assertEquals("", r.readLine());
// No RegexGroupFilter defaults to first group. // No RegexGroupFilter defaults to first group.
@ -193,7 +198,8 @@ public class RegexPipelineTest extends HttpTestCase {
c = ((HttpURLConnection) uri.resolve("/c/d").toURL() c = ((HttpURLConnection) uri.resolve("/c/d").toURL()
.openConnection()); .openConnection());
assertEquals(200, c.getResponseCode()); 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("test2", r.readLine());
assertEquals("", r.readLine()); assertEquals("", r.readLine());
assertEquals("/c", r.readLine()); assertEquals("/c", r.readLine());
@ -202,7 +208,8 @@ public class RegexPipelineTest extends HttpTestCase {
c = ((HttpURLConnection) uri.resolve("/e/f/g").toURL() c = ((HttpURLConnection) uri.resolve("/e/f/g").toURL()
.openConnection()); .openConnection());
assertEquals(200, c.getResponseCode()); 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("test3", r.readLine());
assertEquals("/e/f", r.readLine()); assertEquals("/e/f", r.readLine());
assertEquals("/g", r.readLine()); assertEquals("/g", r.readLine());

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java

@ -42,6 +42,7 @@
package org.eclipse.jgit.transport; package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
@ -334,7 +335,7 @@ public class PushCertificateParserTest {
assertFalse(input.contains(PushCertificateParser.END_CERT)); assertFalse(input.contains(PushCertificateParser.END_CERT));
input += input; input += input;
Reader reader = new InputStreamReader( Reader reader = new InputStreamReader(
new ByteArrayInputStream(Constants.encode(input))); new ByteArrayInputStream(Constants.encode(input)), UTF_8);
assertNotNull(PushCertificateParser.fromReader(reader)); assertNotNull(PushCertificateParser.fromReader(reader));
assertNotNull(PushCertificateParser.fromReader(reader)); assertNotNull(PushCertificateParser.fromReader(reader));

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java

@ -43,6 +43,7 @@
package org.eclipse.jgit.transport; 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.ObjectId.zeroId;
import static org.eclipse.jgit.lib.RefUpdate.Result.FAST_FORWARD; import static org.eclipse.jgit.lib.RefUpdate.Result.FAST_FORWARD;
import static org.eclipse.jgit.lib.RefUpdate.Result.LOCK_FAILURE; import static org.eclipse.jgit.lib.RefUpdate.Result.LOCK_FAILURE;
@ -96,7 +97,9 @@ public class PushCertificateStoreTest {
+ "-----END PGP SIGNATURE-----\n"); + "-----END PGP SIGNATURE-----\n");
try { try {
return PushCertificateParser.fromReader(new InputStreamReader( return PushCertificateParser.fromReader(new InputStreamReader(
new ByteArrayInputStream(Constants.encode(cert.toString())))); new ByteArrayInputStream(
Constants.encode(cert.toString())),
UTF_8));
} catch (IOException e) { } catch (IOException e) {
throw new IllegalArgumentException(e); throw new IllegalArgumentException(e);
} }

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java

@ -43,6 +43,7 @@
package org.eclipse.jgit.util; package org.eclipse.jgit.util;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -105,7 +106,7 @@ public class IOReadLineTest {
private Reader newReader(String in) { private Reader newReader(String in) {
Reader r = new InputStreamReader( Reader r = new InputStreamReader(
new ByteArrayInputStream(Constants.encode(in))); new ByteArrayInputStream(Constants.encode(in)), UTF_8);
if (buffered) { if (buffered) {
r = new BufferedReader(r); r = new BufferedReader(r);
} }

5
org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java

@ -43,6 +43,8 @@
package org.eclipse.jgit.transport; package org.eclipse.jgit.transport;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -241,7 +243,8 @@ public class OpenSshConfig implements ConfigRepository {
private Map<String, HostEntry> parse(InputStream in) private Map<String, HostEntry> parse(InputStream in)
throws IOException { throws IOException {
final Map<String, HostEntry> m = new LinkedHashMap<>(); final Map<String, HostEntry> m = new LinkedHashMap<>();
final BufferedReader br = new BufferedReader(new InputStreamReader(in)); final BufferedReader br = new BufferedReader(
new InputStreamReader(in, UTF_8));
final List<HostEntry> current = new ArrayList<>(4); final List<HostEntry> current = new ArrayList<>(4);
String line; String line;

Loading…
Cancel
Save