From: Robert Varga Date: Mon, 2 Dec 2019 00:46:22 +0000 (+0100) Subject: Use String.getBytes(CharSet) X-Git-Tag: release/magnesium~66 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=cc9c8d811bc0906818bb3509289ecea82f3e238e;p=ovsdb.git Use String.getBytes(CharSet) Modernizer is point out this improved method, use it instead of String-specified charset. Change-Id: I852152d52566e41b8363c06d8c007a7d1448c305 Signed-off-by: Robert Varga --- diff --git a/library/impl/src/test/java/org/opendaylight/ovsdb/lib/jsonrpc/TestClient.java b/library/impl/src/test/java/org/opendaylight/ovsdb/lib/jsonrpc/TestClient.java index 643df7197..1eef7b443 100644 --- a/library/impl/src/test/java/org/opendaylight/ovsdb/lib/jsonrpc/TestClient.java +++ b/library/impl/src/test/java/org/opendaylight/ovsdb/lib/jsonrpc/TestClient.java @@ -12,6 +12,7 @@ import io.netty.handler.logging.LoggingHandler; import java.io.IOException; import java.io.OutputStream; import java.net.Socket; +import java.nio.charset.StandardCharsets; import junit.framework.TestCase; import org.junit.Test; @@ -59,33 +60,33 @@ public class TestClient extends TestCase { /** * Create and write a json string for specified number of times. */ - private void writeJson(OutputStream outputStream, int times) throws IOException { - outputStream.write("{".getBytes("UTF-8")); + private static void writeJson(final OutputStream outputStream, final int times) throws IOException { + outputStream.write("{".getBytes(StandardCharsets.UTF_8)); for (int i = 0; i < times; i++) { counter++; String string = ",\"key1" + counter + "\":\"planet of apes" + counter + "\", \"key2" + counter + "\":{\"k1\":\"ovs-db rocks the world\"}"; - outputStream.write(string.substring(i == 0 ? 1 : 0).getBytes("UTF-8")); + outputStream.write(string.substring(i == 0 ? 1 : 0).getBytes(StandardCharsets.UTF_8)); } - outputStream.write("}".getBytes("UTF-8")); + outputStream.write("}".getBytes(StandardCharsets.UTF_8)); } /** * Writes a partial JSON and flush to simulate the case where netty gets half the message and has to frame it * accordingly. */ - private void writePartialFirst(OutputStream outputStream) throws IOException { + private static void writePartialFirst(final OutputStream outputStream) throws IOException { counter++; String string = " {\"part" + counter + "\":"; - outputStream.write(string.getBytes("UTF-8")); + outputStream.write(string.getBytes(StandardCharsets.UTF_8)); } /** * Finishes the JSON started by writePartialFirst. */ - private void writePartialLast(OutputStream outputStream) throws IOException { + private static void writePartialLast(final OutputStream outputStream) throws IOException { String string = "\"val" + counter + "\"}"; - outputStream.write(string.getBytes("UTF-8")); + outputStream.write(string.getBytes(StandardCharsets.UTF_8)); } }