This is an automated email from the ASF dual-hosted git repository.
zstan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new c4b8225a20a IGNITE-28654 Fix NPE during
AuthenticationConfigurationClusterTest#testServerNodeJoinDisabled (#13118)
c4b8225a20a is described below
commit c4b8225a20a6b428b9241a8091cc49165b096549
Author: Evgeniy Stanilovskiy <[email protected]>
AuthorDate: Wed May 13 15:53:47 2026 +0300
IGNITE-28654 Fix NPE during
AuthenticationConfigurationClusterTest#testServerNodeJoinDisabled (#13118)
---
.../managers/discovery/GridDiscoveryManager.java | 28 +++++++++++++---------
.../IgniteAuthenticationProcessor.java | 8 ++++++-
.../AuthenticationConfigurationClusterTest.java | 5 ++--
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 1e06d65b538..dbed8016c28 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -1913,7 +1913,7 @@ public class GridDiscoveryManager extends
GridManagerAdapter<DiscoverySpi> {
*
* @return Discovery collection cache.
*/
- public DiscoCache discoCache() {
+ @Nullable public DiscoCache discoCache() {
Snapshot cur = topSnap.get();
assert cur != null;
@@ -1930,24 +1930,30 @@ public class GridDiscoveryManager extends
GridManagerAdapter<DiscoverySpi> {
return discoCacheHist.get(topVer);
}
- /** @return All remote nodes in topology. */
+ /** @return All remote nodes in topology or empty collection if topology
is not initialized. */
public Collection<ClusterNode> remoteNodes() {
- return discoCache().remoteNodes();
+ @Nullable DiscoCache cached = discoCache();
+
+ return cached == null ? List.of() : cached.remoteNodes();
}
- /** @return All nodes in topology. */
+ /** @return All nodes in topology or empty collection if topology is not
initialized. */
public Collection<ClusterNode> allNodes() {
- return discoCache().allNodes();
+ @Nullable DiscoCache cached = discoCache();
+
+ return cached == null ? List.of() : discoCache().allNodes();
}
- /** @return all alive server nodes in topology */
+ /** @return Alive server nodes in topology or empty collection if topology
is not initialized. */
public Collection<ClusterNode> aliveServerNodes() {
- return discoCache().aliveServerNodes();
+ @Nullable DiscoCache cached = discoCache();
+
+ return cached == null ? List.of() : cached.aliveServerNodes();
}
- /** @return Full topology size. */
+ /** @return Full topology size, {@code 0} if topology is not initialized.
*/
public int size() {
- return discoCache().allNodes().size();
+ return allNodes().size();
}
/**
@@ -3368,13 +3374,13 @@ public class GridDiscoveryManager extends
GridManagerAdapter<DiscoverySpi> {
/** */
@GridToStringExclude
- private final DiscoCache discoCache;
+ @Nullable private final DiscoCache discoCache;
/**
* @param topVer Topology version.
* @param discoCache Disco cache.
*/
- private Snapshot(AffinityTopologyVersion topVer, DiscoCache
discoCache) {
+ private Snapshot(AffinityTopologyVersion topVer, @Nullable DiscoCache
discoCache) {
this.topVer = topVer;
this.discoCache = discoCache;
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java
index 73b8ee9ed81..af9baf67bf3 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java
@@ -182,7 +182,10 @@ public class IgniteAuthenticationProcessor extends
GridProcessorAdapter implemen
discoMgr.setCustomEventListener(UserAcceptedMessage.class, new
UserAcceptedListener());
- discoMgr.localJoinFuture().listen(this::onLocalJoin);
+ discoMgr.localJoinFuture().listen(f -> {
+ if (f.error() == null)
+ onLocalJoin();
+ });
discoLsnr = (evt, discoCache) -> {
if (ctx.isStopping())
@@ -623,6 +626,9 @@ public class IgniteAuthenticationProcessor extends
GridProcessorAdapter implemen
else {
ClusterNode res = null;
+ if (ctx.discovery().aliveServerNodes().isEmpty())
+ throw new IgniteException("Failed to get the coordinator
node. Topology is empty.");
+
for (ClusterNode node : ctx.discovery().aliveServerNodes()) {
if (res == null || res.order() > node.order())
res = node;
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java
index bdeb69be3ad..cf5494eee73 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java
@@ -28,6 +28,7 @@ import
org.apache.ignite.internal.processors.security.impl.TestSecurityPluginPro
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
import org.junit.Test;
import static org.apache.ignite.cluster.ClusterState.ACTIVE;
@@ -131,8 +132,8 @@ public class AuthenticationConfigurationClusterTest extends
GridCommonAbstractTe
private void checkNodeJoinFailed(boolean client, boolean authEnabled)
throws Exception {
startGrid(configuration(0, authEnabled, false));
- GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() {
- @Override public Object call() throws Exception {
+ GridTestUtils.assertThrowsAnyCause(log, new Callable<>() {
+ @Override public @Nullable Object call() throws Exception {
startGrid(configuration(1, !authEnabled, client));
return null;