Use ByteArrayOutputStream.toString where possible
See gh-32534
This commit is contained in:
parent
a036b30822
commit
65ef8fc51a
|
@ -316,7 +316,7 @@ class HttpClientTransportTests {
|
||||||
private String writeToString(HttpEntity entity) throws IOException {
|
private String writeToString(HttpEntity entity) throws IOException {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
entity.writeTo(out);
|
entity.writeTo(out);
|
||||||
return new String(out.toByteArray(), StandardCharsets.UTF_8);
|
return out.toString(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void givenClientWillReturnResponse() throws IOException {
|
private void givenClientWillReturnResponse() throws IOException {
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ContainerConfigTests extends AbstractJsonTests {
|
||||||
});
|
});
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
containerConfig.writeTo(outputStream);
|
containerConfig.writeTo(outputStream);
|
||||||
String actualJson = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
|
String actualJson = outputStream.toString(StandardCharsets.UTF_8);
|
||||||
String expectedJson = StreamUtils.copyToString(getContent("container-config.json"), StandardCharsets.UTF_8);
|
String expectedJson = StreamUtils.copyToString(getContent("container-config.json"), StandardCharsets.UTF_8);
|
||||||
JSONAssert.assertEquals(expectedJson, actualJson, true);
|
JSONAssert.assertEquals(expectedJson, actualJson, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class DefaultLaunchScript implements LaunchScript {
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
copy(inputStream, outputStream);
|
copy(inputStream, outputStream);
|
||||||
return new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
|
return outputStream.toString(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -144,7 +144,7 @@ class LayersIndexTests {
|
||||||
private String getContent() throws IOException {
|
private String getContent() throws IOException {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
this.actual.writeTo(out);
|
this.actual.writeTo(out);
|
||||||
return new String(out.toByteArray(), StandardCharsets.UTF_8);
|
return out.toString(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue