Skip to content

Commit 8cd7e95

Browse files
committed
Handle null URI list in MulticastSet
Fixes #206 (cherry picked from commit 05c1275)
1 parent 04414ac commit 8cd7e95

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/com/rabbitmq/perf/MulticastSet.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public MulticastSet(Stats stats, ConnectionFactory factory,
7676
this.factory = factory;
7777
this.params = params;
7878
this.testID = testID;
79-
this.uris = new CopyOnWriteArrayList<>(uris);
79+
this.uris = uris == null || uris.isEmpty() ?
80+
null : new CopyOnWriteArrayList<>(uris);
8081
this.completionHandler = completionHandler;
8182
this.shutdownService = shutdownService;
8283
this.params.init();
@@ -126,7 +127,8 @@ public void run()
126127
public void run(boolean announceStartup)
127128
throws IOException, InterruptedException, TimeoutException, NoSuchAlgorithmException, KeyManagementException, URISyntaxException {
128129
if (waitUntilBrokerAvailableIfNecessary(params.getServersStartUpTimeout(),
129-
params.getServersUpLimit() == -1 ? uris.size() : params.getServersUpLimit(),
130+
params.getServersUpLimit() == -1 ? (uris == null ? 0 : uris.size())
131+
: params.getServersUpLimit(),
130132
uris, factory)) {
131133
ScheduledExecutorService heartbeatSenderExecutorService = this.threadingHandler.scheduledExecutorService(
132134
"perf-test-heartbeat-sender-",
@@ -221,7 +223,7 @@ public void run(boolean announceStartup)
221223
static boolean waitUntilBrokerAvailableIfNecessary(int startUpTimeoutInSeconds, int serversUpLimit,
222224
Collection<String> uris, ConnectionFactory factory)
223225
throws NoSuchAlgorithmException, KeyManagementException, URISyntaxException, InterruptedException {
224-
if (startUpTimeoutInSeconds <= 0) {
226+
if (startUpTimeoutInSeconds <= 0 || uris == null || uris.isEmpty()) {
225227
// we don't test the connection to the broker
226228
return true;
227229
} else {
@@ -458,7 +460,7 @@ private static void dispose(Connection connection) {
458460
}
459461

460462
private void setUri() throws URISyntaxException, NoSuchAlgorithmException, KeyManagementException {
461-
if (uris != null) {
463+
if (uris != null && !uris.isEmpty()) {
462464
factory.setUri(uri());
463465
}
464466
}

0 commit comments

Comments
 (0)