The goal is to find usages of ClusterStateListener and make sure it is not publishing its this reference during construction. There might be multiple possible ways to fix that.
The easiest fix is to just extract a factory method. However when there is multiple overloaded constructors, it might be tempted to remove the ClusterService parameter and register in a place where the instance is created.
In some cases where constructor parameters are provided with @Inject the registration could be done in AbstractLifecycleComponent.start/doStart.
Or refactored to factory method with @Inject (that annotation might work with methods, although couldn't find usages.
[x] RestoreClusterStateListener (org.elasticsearch.action.admin.cluster.snapshots.restore) registered in a separate method (not a static factory method) - another way of approaching this
This is a follow up from https://github.com/elastic/elasticsearch/issues/37861 discussed on core-infra sync meeting on 6th of Feb19 . See the original issue for reasoning behind this.
The goal is to find usages of
ClusterStateListener
and make sure it is not publishing itsthis
reference during construction. There might be multiple possible ways to fix that. The easiest fix is to just extract a factory method. However when there is multiple overloaded constructors, it might be tempted to remove the ClusterService parameter and register in a place where the instance is created. In some cases where constructor parameters are provided with@Inject
the registration could be done inAbstractLifecycleComponent.start/doStart
. Or refactored to factory method with @Inject (that annotation might work with methods, although couldn't find usages.AbstractLifecycleComponent.doStart