Skip to content

Commit

Permalink
Default implementation for deprecated method (#99554)
Browse files Browse the repository at this point in the history
This is a followup to #99396.

Downstream projects have switched to using the new method, but still
override the deprecated method. Here, we give the deprecated method a
default implementation so we can remove it, and remove the default
implementation from the new method.

Once this is merged, downstream projects will be able to remove their
implementations of the deprecated method.
  • Loading branch information
williamrandolph authored Sep 13, 2023
1 parent baf11a9 commit c84f20b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ CoordinationState.PersistedState createPersistedState(
interface PersistedClusterStateServiceFactory {

@Deprecated(forRemoval = true)
PersistedClusterStateService newPersistedClusterStateService(
default PersistedClusterStateService newPersistedClusterStateService(
NodeEnvironment nodeEnvironment,
NamedXContentRegistry xContentRegistry,
ClusterSettings clusterSettings,
ThreadPool threadPool
);
) {
throw new AssertionError("Should not be called!");
}

default PersistedClusterStateService newPersistedClusterStateService(
PersistedClusterStateService newPersistedClusterStateService(
NodeEnvironment nodeEnvironment,
NamedXContentRegistry xContentRegistry,
ClusterSettings clusterSettings,
ThreadPool threadPool,
CompatibilityVersions compatibilityVersions
) {
return newPersistedClusterStateService(nodeEnvironment, xContentRegistry, clusterSettings, threadPool);
}
);
}

interface ReconfiguratorFactory {
Expand Down
34 changes: 9 additions & 25 deletions server/src/test/java/org/elasticsearch/node/NodeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.cluster.version.CompatibilityVersions;
import org.elasticsearch.common.breaker.CircuitBreaker;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.BoundTransportAddress;
import org.elasticsearch.core.RestApiVersion;
Expand Down Expand Up @@ -635,33 +633,19 @@ private static class BaseTestClusterCoordinationPlugin extends Plugin implements

@Override
public Optional<PersistedClusterStateServiceFactory> getPersistedClusterStateServiceFactory() {
return Optional.of(new PersistedClusterStateServiceFactory() {
@Override
public PersistedClusterStateService newPersistedClusterStateService(
NodeEnvironment nodeEnvironment,
NamedXContentRegistry xContentRegistry,
ClusterSettings clusterSettings,
ThreadPool threadPool
) {
throw new AssertionError("not called");
}

@Override
public PersistedClusterStateService newPersistedClusterStateService(
NodeEnvironment nodeEnvironment,
NamedXContentRegistry namedXContentRegistry,
ClusterSettings clusterSettings,
ThreadPool threadPool,
CompatibilityVersions compatibilityVersions
) {
return persistedClusterStateService = new PersistedClusterStateService(
return Optional.of(
(
nodeEnvironment,
namedXContentRegistry,
clusterSettings,
threadPool,
compatibilityVersions) -> persistedClusterStateService = new PersistedClusterStateService(
nodeEnvironment,
namedXContentRegistry,
clusterSettings,
threadPool::relativeTimeInMillis
);
}
});
)
);
}
}

Expand Down

0 comments on commit c84f20b

Please sign in to comment.