|
31 | 31 |
|
32 | 32 | package io.grpc.testing; |
33 | 33 |
|
34 | | -import static com.google.common.base.Charsets.UTF_8; |
35 | | - |
36 | 34 | import io.grpc.ExperimentalApi; |
37 | 35 | import io.grpc.ForwardingServerCall.SimpleForwardingServerCall; |
38 | 36 | import io.grpc.Metadata; |
|
42 | 40 | import io.grpc.Status; |
43 | 41 |
|
44 | 42 | import java.io.BufferedInputStream; |
45 | | -import java.io.BufferedWriter; |
| 43 | +import java.io.BufferedOutputStream; |
46 | 44 | import java.io.File; |
47 | 45 | import java.io.FileInputStream; |
48 | 46 | import java.io.FileOutputStream; |
49 | 47 | import java.io.IOException; |
50 | 48 | import java.io.InputStream; |
51 | | -import java.io.OutputStreamWriter; |
| 49 | +import java.io.OutputStream; |
52 | 50 | import java.net.InetAddress; |
53 | 51 | import java.net.InetSocketAddress; |
54 | 52 | import java.net.UnknownHostException; |
@@ -255,19 +253,20 @@ public static List<String> preferredTestCiphers() { |
255 | 253 | * @param name name of a file in src/main/resources/certs. |
256 | 254 | */ |
257 | 255 | public static File loadCert(String name) throws IOException { |
258 | | - InputStream in = TestUtils.class.getResourceAsStream("/certs/" + name); |
| 256 | + InputStream in = new BufferedInputStream(TestUtils.class.getResourceAsStream("/certs/" + name)); |
259 | 257 | File tmpFile = File.createTempFile(name, ""); |
260 | 258 | tmpFile.deleteOnExit(); |
261 | 259 |
|
262 | | - BufferedWriter writer = |
263 | | - new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tmpFile), UTF_8)); |
| 260 | + OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile)); |
264 | 261 | try { |
265 | 262 | int b; |
266 | 263 | while ((b = in.read()) != -1) { |
267 | | - writer.write(b); |
| 264 | + os.write(b); |
268 | 265 | } |
| 266 | + os.flush(); |
269 | 267 | } finally { |
270 | | - writer.close(); |
| 268 | + in.close(); |
| 269 | + os.close(); |
271 | 270 | } |
272 | 271 |
|
273 | 272 | return tmpFile; |
|
0 commit comments