Skip to content

Commit

Permalink
specific the Charset for thrift interface (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole00 authored Dec 14, 2023
1 parent 4126e97 commit 86d4a76
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.Map;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import okhttp3.internal.http2.Http2Connection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -113,7 +112,7 @@ public void open(HostAddress address, int timeout) throws IOErrorException,

@Override
public void open(HostAddress address, int timeout,
boolean isUseHttp2, Map<String,String> headers)
boolean isUseHttp2, Map<String, String> headers)
throws IOErrorException, ClientServerIncompatibleException {
try {
this.serverAddr = address;
Expand Down Expand Up @@ -217,7 +216,8 @@ public void reopen() throws IOErrorException, ClientServerIncompatibleException
public AuthResult authenticate(String user, String password)
throws AuthFailedException, IOErrorException, ClientServerIncompatibleException {
try {
AuthResponse resp = client.authenticate(user.getBytes(), password.getBytes());
AuthResponse resp = client.authenticate(user.getBytes(Charsets.UTF_8),
password.getBytes(Charsets.UTF_8));
if (resp.error_code != ErrorCode.SUCCEEDED) {
if (resp.error_msg != null) {
throw new AuthFailedException(new String(resp.error_msg));
Expand Down Expand Up @@ -255,7 +255,10 @@ public ExecutionResponse executeWithParameter(long sessionID, String stmt,
Map<byte[], com.vesoft.nebula.Value> parameterMap)
throws IOErrorException {
try {
return client.executeWithParameter(sessionID, stmt.getBytes(), parameterMap);
return client.executeWithParameter(
sessionID,
stmt.getBytes(Charsets.UTF_8),
parameterMap);
} catch (TException e) {
if (e instanceof TTransportException) {
TTransportException te = (TTransportException) e;
Expand Down Expand Up @@ -288,7 +291,10 @@ public String executeJsonWithParameter(long sessionID, String stmt,
throws IOErrorException {
try {
byte[] result =
client.executeJsonWithParameter(sessionID, stmt.getBytes(), parameterMap);
client.executeJsonWithParameter(
sessionID,
stmt.getBytes(Charsets.UTF_8),
parameterMap);
return new String(result, StandardCharsets.UTF_8);
} catch (TException e) {
if (e instanceof TTransportException) {
Expand Down

0 comments on commit 86d4a76

Please sign in to comment.