Skip to content

Commit f93c07c

Browse files
committed
Fix locator initialization
1 parent 5d1ecf2 commit f93c07c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/com/rabbitmq/stream/impl/StreamEnvironment.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ class StreamEnvironment implements Environment {
245245
Runnable locatorInitSequence =
246246
() -> {
247247
RuntimeException lastException = null;
248-
for (int i = 0; i < addresses.size(); i++) {
249-
Address address = addresses.get(i);
248+
for (int i = 0; i < locators.size(); i++) {
249+
Address address = addresses.get(i % addresses.size());
250250
Locator locator = locator(i);
251251
address = addressResolver.resolve(address);
252252
String connectionName = connectionNamingStrategy.apply(ClientConnectionType.LOCATOR);
@@ -305,10 +305,10 @@ private ShutdownListener shutdownListener(
305305
Client.ShutdownListener shutdownListener =
306306
shutdownContext -> {
307307
if (shutdownContext.isShutdownUnexpected()) {
308+
String label = locator.label();
308309
locator.client(null);
309310
LOGGER.debug(
310-
"Unexpected locator disconnection for locator on '{}', trying to reconnect",
311-
locator.label());
311+
"Unexpected locator disconnection for locator on '{}', trying to reconnect", label);
312312
try {
313313
Client.ClientParameters newLocatorParameters =
314314
this.locatorParametersCopy().shutdownListener(shutdownListenerReference.get());
@@ -1006,7 +1006,9 @@ private String label() {
10061006
if (c == null) {
10071007
return address.host() + ":" + address.port();
10081008
} else {
1009-
return c.getHost() + ":" + c.getPort();
1009+
return String.format(
1010+
"%s:%d [advertised %s:%d]",
1011+
c.getHost(), c.getPort(), c.serverAdvertisedHost(), c.serverAdvertisedPort());
10101012
}
10111013
}
10121014

0 commit comments

Comments
 (0)