elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
68.65k stars 24.37k forks source link

Safely register ClusterStateListener #38560

Open pgomulka opened 5 years ago

pgomulka commented 5 years ago

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 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.

elasticmachine commented 5 years ago

Pinging @elastic/es-core-infra

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-core-infra (Team:Core/Infra)