Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ protected SessionDataSet executeQueryStatement(String sql, long timeout)
},
TSExecuteStatementResp::getStatus);
TSExecuteStatementResp execResp = result.getResult();
if (execResp == null) {
throw new IoTDBConnectionException(
"Cannot get statement response from server, response is null");
}
if (result.getRetryAttempts() == 0) {
RpcUtils.verifySuccessWithRedirection(execResp.getStatus());
} else {
Expand Down Expand Up @@ -536,6 +540,10 @@ protected SessionDataSet executeRawDataQuery(
TSExecuteStatementResp::getStatus);

TSExecuteStatementResp execResp = result.getResult();
if (execResp == null) {
throw new IoTDBConnectionException(
"Cannot get statement response from server, response is null");
}
if (result.getRetryAttempts() == 0) {
RpcUtils.verifySuccessWithRedirection(execResp.getStatus());
} else {
Expand Down Expand Up @@ -575,7 +583,10 @@ protected SessionDataSet executeLastDataQueryForOnePrefixPath(final List<String>
return client.executeFastLastDataQueryForOnePrefixPath(req);
});
final TSExecuteStatementResp tsExecuteStatementResp = result.getResult();

if (tsExecuteStatementResp == null) {
throw new IoTDBConnectionException(
"Cannot get statement response from server, response is null");
}
if (result.getRetryAttempts() == 0) {
RpcUtils.verifySuccessWithRedirection(tsExecuteStatementResp.getStatus());
} else {
Expand Down Expand Up @@ -621,6 +632,10 @@ protected Pair<SessionDataSet, TEndPoint> executeLastDataQueryForOneDevice(
TSExecuteStatementResp::getStatus);

TSExecuteStatementResp tsExecuteStatementResp = result.getResult();
if (tsExecuteStatementResp == null) {
throw new IoTDBConnectionException(
"Cannot get statement response from server, response is null");
}
if (result.getRetryAttempts() == 0) {
try {
RpcUtils.verifySuccessWithRedirection(tsExecuteStatementResp.getStatus());
Expand Down Expand Up @@ -668,7 +683,10 @@ protected SessionDataSet executeLastDataQuery(List<String> paths, long time, lon
},
TSExecuteStatementResp::getStatus);
final TSExecuteStatementResp tsExecuteStatementResp = result.getResult();

if (tsExecuteStatementResp == null) {
throw new IoTDBConnectionException(
"Cannot get statement response from server, response is null");
}
if (result.getRetryAttempts() == 0) {
RpcUtils.verifySuccessWithRedirection(tsExecuteStatementResp.getStatus());
} else {
Expand Down Expand Up @@ -751,6 +769,10 @@ private SessionDataSet executeAggregationQuery(TSAggregationQueryReq tsAggregati
TSExecuteStatementResp::getStatus);

TSExecuteStatementResp tsExecuteStatementResp = result.getResult();
if (tsExecuteStatementResp == null) {
throw new IoTDBConnectionException(
"Cannot get statement response from server, response is null");
}
if (result.getRetryAttempts() == 0) {
RpcUtils.verifySuccessWithRedirection(tsExecuteStatementResp.getStatus());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@
import org.powermock.reflect.Whitebox;

import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
Expand Down Expand Up @@ -450,4 +453,17 @@ public void testToString() {
Assert.assertEquals("localhost", sessionConnection.getEndPoint().getIp());
sessionConnection.toString();
}

@Test(expected = IoTDBConnectionException.class)
public void testExecuteQueryStatementNullResponse()
throws IoTDBConnectionException, StatementExecutionException, RedirectException, TException {
List<TEndPoint> mockNodes = Collections.singletonList(new TEndPoint("127.0.0.1", 6667));
Whitebox.setInternalState(sessionConnection, "endPointList", new ArrayList<>(mockNodes));
Whitebox.setInternalState(
sessionConnection, "availableNodes", (Supplier<List<TEndPoint>>) () -> mockNodes);

Mockito.when(client.executeQueryStatementV2(any())).thenReturn(null);

sessionConnection.executeQueryStatement("show version", 500l);
}
}