Skip to content

Commit

Permalink
fix: log level in ReconnectWaitBarrier.java. Use 'getAndSet' and 'com…
Browse files Browse the repository at this point in the history
…pareAndSet' for the AtomicReference in TestClientImpl.java

Signed-off-by: Malte Grebe-Lüth <[email protected]>
  • Loading branch information
belagertem committed Feb 27, 2025
1 parent 5ca5626 commit dd82a5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ public Injector getInjector() {
@Subscribe
void onConnectionLoss(final WatchdogMessage watchdogMessage) {
LOG.info("Watchdog detected disconnect from provider.");
if (shouldBeConnected.get() && reconnectState.get() == InternalReconnectState.ENABLED) {
reconnectState.set(InternalReconnectState.RECONNECTING);
if (shouldBeConnected.get() && reconnectState.compareAndSet(InternalReconnectState.ENABLED, InternalReconnectState.RECONNECTING)) {
LOG.info("The disconnect from provider was expected, trying to reconnect.");
if (reconnectExecutor.isRunning()) {
reconnectExecutor.get().submit(() -> {
Expand Down Expand Up @@ -600,14 +599,13 @@ void onConnectionLoss(final WatchdogMessage watchdogMessage) {
private void completeReconnectFuture(final boolean result) {
reconnectLock.lock();
try {
if (reconnectState.get() != InternalReconnectState.COMPLETED) {
if (reconnectState.getAndSet(InternalReconnectState.COMPLETED) != InternalReconnectState.COMPLETED) {
if (!isConnected.get()) {
LOG.debug("No connection established during reconnect process, invalidating the test run.");
testRunObserver.invalidateTestRun(COULDN_T_RECONNECT);
}
reconnectFuture.complete(result);
}
reconnectState.set(InternalReconnectState.COMPLETED);
reconnectLockCondition.signalAll();
} finally {
reconnectLock.unlock();
Expand All @@ -617,12 +615,11 @@ private void completeReconnectFuture(final boolean result) {
private void completeReconnectFutureExceptionally(final Exception exception) {
reconnectLock.lock();
try {
if (reconnectState.get() != InternalReconnectState.COMPLETED) {
if (reconnectState.getAndSet(InternalReconnectState.COMPLETED) != InternalReconnectState.COMPLETED) {
LOG.error("Something went wrong during reconnect.", exception);
testRunObserver.invalidateTestRun(exception.getMessage());
reconnectFuture.completeExceptionally(exception);
}
reconnectState.set(InternalReconnectState.COMPLETED);
reconnectLockCondition.signalAll();
} finally {
reconnectLock.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ReconnectWaitBarrier(parties: Int = 2) {
try {
barrier.await(timeout, TimeUnit.SECONDS)
} catch (e: TimeoutException) {
logger.info { "Timeout reached while waiting for the provider to be ready" }
logger.debug { "Timeout reached while waiting for the provider to be ready" }
}
}

Expand Down

0 comments on commit dd82a5e

Please sign in to comment.