This is an automated email from the ASF dual-hosted git repository. rong pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push: new 0f797e28cf9 Subscription: fix the issue with nodeUrls parameter being ineffective & missing return for create topic (#12974) 0f797e28cf9 is described below commit 0f797e28cf94a9be058e6ad0c83b2caed1491e17 Author: V_Galaxy <vgalax...@apache.org> AuthorDate: Sat Jul 20 02:28:25 2024 +0800 Subscription: fix the issue with nodeUrls parameter being ineffective & missing return for create topic (#12974) --- .../session/subscription/SubscriptionSession.java | 1 + .../subscription/consumer/SubscriptionConsumer.java | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/SubscriptionSession.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/SubscriptionSession.java index ea51667a1da..d70de467db0 100644 --- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/SubscriptionSession.java +++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/SubscriptionSession.java @@ -90,6 +90,7 @@ public class SubscriptionSession extends Session { throws IoTDBConnectionException, StatementExecutionException { if (properties.isEmpty()) { createTopic(topicName); + return; } final StringBuilder sb = new StringBuilder(); sb.append('('); diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java index ddf8abee931..9a6b0fccf7a 100644 --- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java +++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java @@ -126,7 +126,17 @@ abstract class SubscriptionConsumer implements AutoCloseable { final Set<TEndPoint> initialEndpoints = new HashSet<>(); // From org.apache.iotdb.session.Session.getNodeUrls // Priority is given to `host:port` over `nodeUrls`. - if (Objects.nonNull(builder.host)) { + if (Objects.nonNull(builder.host) || Objects.nonNull(builder.port)) { + if (Objects.isNull(builder.host)) { + builder.host = SessionConfig.DEFAULT_HOST; + } + if (Objects.isNull(builder.port)) { + builder.port = SessionConfig.DEFAULT_PORT; + } + initialEndpoints.add(new TEndPoint(builder.host, builder.port)); + } else if (Objects.isNull(builder.nodeUrls)) { + builder.host = SessionConfig.DEFAULT_HOST; + builder.port = SessionConfig.DEFAULT_PORT; initialEndpoints.add(new TEndPoint(builder.host, builder.port)); } else { initialEndpoints.addAll(SessionUtils.parseSeedNodeUrls(builder.nodeUrls)); @@ -975,9 +985,9 @@ abstract class SubscriptionConsumer implements AutoCloseable { public abstract static class Builder { - protected String host = SessionConfig.DEFAULT_HOST; - protected int port = SessionConfig.DEFAULT_PORT; - protected List<String> nodeUrls = null; + protected String host; + protected Integer port; + protected List<String> nodeUrls; protected String username = SessionConfig.DEFAULT_USER; protected String password = SessionConfig.DEFAULT_PASSWORD;