-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix test memory leak #88362
Fix test memory leak #88362
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,23 +10,24 @@ | |
import org.elasticsearch.immutablestate.ImmutableClusterStateHandler; | ||
import org.elasticsearch.immutablestate.ImmutableClusterStateHandlerProvider; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* ILM Provider implementation for the {@link ImmutableClusterStateHandlerProvider} service interface | ||
*/ | ||
public class ILMImmutableStateHandlerProvider implements ImmutableClusterStateHandlerProvider { | ||
private static final Set<ImmutableClusterStateHandler<?>> handlers = ConcurrentHashMap.newKeySet(); | ||
private final IndexLifecycle plugin; | ||
|
||
@Override | ||
public Collection<ImmutableClusterStateHandler<?>> handlers() { | ||
return handlers; | ||
public ILMImmutableStateHandlerProvider() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Declaring this constructor to make sure module-info compiles properly, since SPI requires that we use a no-arg constructor. If we switch to using the META-INF/services file, this problem goes away, however our build 'validateModule' task fails, requiring that we also expose this service provider in our module provides section. |
||
throw new IllegalStateException("Provider must be constructed using PluginsService"); | ||
} | ||
|
||
public ILMImmutableStateHandlerProvider(IndexLifecycle plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public static void registerHandlers(ImmutableClusterStateHandler<?>... stateHandlers) { | ||
handlers.addAll(Arrays.asList(stateHandlers)); | ||
@Override | ||
public Collection<ImmutableClusterStateHandler<?>> handlers() { | ||
return plugin.immutableClusterStateHandlers(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I added a constructor to make the test check that we disallow a service provider with more than 2 constructors. Previously this class was testing for existence of more than 1.