Skip to content

Commit 29f7c79

Browse files
committed
fix empty node response
1 parent d7a6763 commit 29f7c79

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/com/actiontech/dble/backend/datasource/PhysicalDBPool.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,12 @@ public Collection<PhysicalDatasource> getAllDataSources() {
506506
void getRWBalanceCon(String schema, boolean autocommit, ResponseHandler handler, Object attachment) throws Exception {
507507
PhysicalDatasource theNode = getRWBalanceNode();
508508
if (theNode.getConfig().isFake()) {
509-
theNode = this.getReadSources().values().iterator().next()[0];
509+
if (this.getReadSources().values().size() > 0) {
510+
theNode = this.getReadSources().values().iterator().next()[0];
511+
} else {
512+
String errorMsg = "the dataHost[" + theNode.getHostConfig().getName() + "] is empty, please check it";
513+
throw new IOException(errorMsg);
514+
}
510515
}
511516
if (!theNode.isAlive()) {
512517
String heartbeatError = "the data source[" + theNode.getConfig().getUrl() + "] can't reached, please check the dataHost";

src/main/java/com/actiontech/dble/server/NonBlockingSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public void execute(RouteResultset rrs) {
297297
} catch (Exception e) {
298298
handleSpecial(rrs, source.getSchema(), false);
299299
LOGGER.info(String.valueOf(source) + rrs, e);
300-
source.writeErrMessage(ErrorCode.ERR_HANDLE_DATA, e.toString());
300+
source.writeErrMessage(ErrorCode.ERR_HANDLE_DATA, e.getMessage() == null ? e.toString() : e.getMessage());
301301
}
302302
if (this.isPrepared()) {
303303
this.setPrepared(false);

0 commit comments

Comments
 (0)