Skip to content

Commit c801b89

Browse files
author
Christoph Büscher
authored
Fix Eclipse specific compilation issue (#37419)
Without pulling out the supplier function to the enclosing class, Eclipse 4.8 complains with the following error "No enclosing instance of type CoordinatorTests.Cluster is available due to some intermediate constructor invocation"
1 parent 92c6c98 commit c801b89

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.elasticsearch.cluster.coordination;
2020

2121
import com.carrotsearch.randomizedtesting.RandomizedContext;
22+
2223
import org.apache.logging.log4j.CloseableThreadContext;
2324
import org.apache.logging.log4j.LogManager;
2425
import org.apache.logging.log4j.Logger;
@@ -90,10 +91,10 @@
9091
import static org.elasticsearch.cluster.coordination.CoordinationStateTests.clusterState;
9192
import static org.elasticsearch.cluster.coordination.CoordinationStateTests.setValue;
9293
import static org.elasticsearch.cluster.coordination.CoordinationStateTests.value;
94+
import static org.elasticsearch.cluster.coordination.Coordinator.PUBLISH_TIMEOUT_SETTING;
9395
import static org.elasticsearch.cluster.coordination.Coordinator.Mode.CANDIDATE;
9496
import static org.elasticsearch.cluster.coordination.Coordinator.Mode.FOLLOWER;
9597
import static org.elasticsearch.cluster.coordination.Coordinator.Mode.LEADER;
96-
import static org.elasticsearch.cluster.coordination.Coordinator.PUBLISH_TIMEOUT_SETTING;
9798
import static org.elasticsearch.cluster.coordination.CoordinatorTests.Cluster.DEFAULT_DELAY_VARIABILITY;
9899
import static org.elasticsearch.cluster.coordination.ElectionSchedulerFactory.ELECTION_BACK_OFF_TIME_SETTING;
99100
import static org.elasticsearch.cluster.coordination.ElectionSchedulerFactory.ELECTION_DURATION_SETTING;
@@ -1101,6 +1102,9 @@ class Cluster {
11011102
private final Set<String> blackholedNodes = new HashSet<>();
11021103
private final Map<Long, ClusterState> committedStatesByVersion = new HashMap<>();
11031104

1105+
private final Function<DiscoveryNode, PersistedState> defaultPersistedStateSupplier = localNode -> new MockPersistedState(0L,
1106+
clusterState(0L, 0L, localNode, VotingConfiguration.EMPTY_CONFIG, VotingConfiguration.EMPTY_CONFIG, 0L));
1107+
11041108
Cluster(int initialNodeCount) {
11051109
this(initialNodeCount, true);
11061110
}
@@ -1533,9 +1537,7 @@ class ClusterNode {
15331537
private ClusterStateApplyResponse clusterStateApplyResponse = ClusterStateApplyResponse.SUCCEED;
15341538

15351539
ClusterNode(int nodeIndex, boolean masterEligible) {
1536-
this(nodeIndex, createDiscoveryNode(nodeIndex, masterEligible),
1537-
localNode -> new MockPersistedState(0L,
1538-
clusterState(0L, 0L, localNode, VotingConfiguration.EMPTY_CONFIG, VotingConfiguration.EMPTY_CONFIG, 0L)));
1540+
this(nodeIndex, createDiscoveryNode(nodeIndex, masterEligible), defaultPersistedStateSupplier);
15391541
}
15401542

15411543
ClusterNode(int nodeIndex, DiscoveryNode localNode, Function<DiscoveryNode, PersistedState> persistedStateSupplier) {

0 commit comments

Comments
 (0)