Specify UTF-8 encoding for all Java agent commands
[lttng-ust.git] / liblttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / client / SessiondCommand.java
index fd5bb1de89030579734d158b7e577acb028c6aa7..7cde4a3598a516c5cbcd1beb4562e03ce4ea9475 100644 (file)
@@ -19,6 +19,7 @@
 package org.lttng.ust.agent.client;
 
 import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
 
 /**
  * Base class to represent all commands sent from the session daemon to the Java
@@ -29,6 +30,12 @@ import java.nio.ByteBuffer;
  */
 abstract class SessiondCommand {
 
+       /**
+        * Encoding that should be used for the strings in the sessiond agent
+        * protocol on the socket.
+        */
+       protected static final Charset SESSIOND_PROTOCOL_CHARSET = Charset.forName("UTF-8");
+
        enum CommandType {
                /** List logger(s). */
                CMD_LIST(1),
@@ -87,6 +94,6 @@ abstract class SessiondCommand {
 
                byte[] stringBytes = new byte[length];
                buffer.get(stringBytes);
-               return new String(stringBytes).trim();
+               return new String(stringBytes, SESSIOND_PROTOCOL_CHARSET).trim();
        }
 }
This page took 0.023125 seconds and 4 git commands to generate.