From 42233d80de627f5d2bce32e8a6595dc4fc205e57 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Tue, 9 Dec 2025 23:36:21 +0000 Subject: [PATCH] Fixes JAVA-6023, align log level to warning from error when removing the server from the cluster --- .../connection/AbstractMultiServerCluster.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/driver-core/src/main/com/mongodb/internal/connection/AbstractMultiServerCluster.java b/driver-core/src/main/com/mongodb/internal/connection/AbstractMultiServerCluster.java index acaf1a40e14..11abddbb97a 100644 --- a/driver-core/src/main/com/mongodb/internal/connection/AbstractMultiServerCluster.java +++ b/driver-core/src/main/com/mongodb/internal/connection/AbstractMultiServerCluster.java @@ -231,7 +231,7 @@ public void onChange(final ServerDescriptionChangedEvent event) { private boolean handleReplicaSetMemberChanged(final ServerDescription newDescription) { if (!newDescription.isReplicaSetMember()) { - LOGGER.error(format("Expecting replica set member, but found a %s. Removing %s from client view of cluster.", + LOGGER.warn(format("Expecting replica set member, but found a %s. Removing %s from client view of cluster.", newDescription.getType(), newDescription.getAddress())); removeServer(newDescription.getAddress()); return true; @@ -247,7 +247,7 @@ private boolean handleReplicaSetMemberChanged(final ServerDescription newDescrip } if (!replicaSetName.equals(newDescription.getSetName())) { - LOGGER.error(format("Expecting replica set member from set '%s', but found one from set '%s'. " + LOGGER.warn(format("Expecting replica set member from set '%s', but found one from set '%s'. " + "Removing %s from client view of cluster.", replicaSetName, newDescription.getSetName(), newDescription.getAddress())); removeServer(newDescription.getAddress()); @@ -259,7 +259,7 @@ private boolean handleReplicaSetMemberChanged(final ServerDescription newDescrip if (newDescription.getCanonicalAddress() != null && !newDescription.getAddress().equals(new ServerAddress(newDescription.getCanonicalAddress())) && !newDescription.isPrimary()) { - LOGGER.info(format("Canonical address %s does not match server address. Removing %s from client view of cluster", + LOGGER.warn(format("Canonical address %s does not match server address. Removing %s from client view of cluster", newDescription.getCanonicalAddress(), newDescription.getAddress())); removeServer(newDescription.getAddress()); return true; @@ -342,7 +342,7 @@ private boolean isNotAlreadyPrimary(final ServerAddress address) { private boolean handleShardRouterChanged(final ServerDescription newDescription) { if (!newDescription.isShardRouter()) { - LOGGER.error(format("Expecting a %s, but found a %s. Removing %s from client view of cluster.", + LOGGER.warn(format("Expecting a %s, but found a %s. Removing %s from client view of cluster.", SHARD_ROUTER, newDescription.getType(), newDescription.getAddress())); removeServer(newDescription.getAddress()); } @@ -351,7 +351,7 @@ private boolean handleShardRouterChanged(final ServerDescription newDescription) private boolean handleStandAloneChanged(final ServerDescription newDescription) { if (getSettings().getHosts().size() > 1) { - LOGGER.error(format("Expecting a single %s, but found more than one. Removing %s from client view of cluster.", + LOGGER.warn(format("Expecting a single %s, but found more than one. Removing %s from client view of cluster.", STANDALONE, newDescription.getAddress())); clusterType = UNKNOWN; removeServer(newDescription.getAddress());