Transport request handlers should be registered safely #53178
Labels
:Core/Infra/Core
Core issues without another label
help wanted
adoptme
>refactoring
Team:Core/Infra
Meta label for core/infra team
Similar to #38560 and #51622, the HandledTransportAction registers a non-static inner class with the transport service as the handler for the requests of a given action as seen below.
elasticsearch/server/src/main/java/org/elasticsearch/action/support/HandledTransportAction.java
Lines 52 to 66 in 8980120
In the other issues, a reference to the instance being constructed,
this
, was explicitly passed to another service. In this case, the reference is implicit since the inner classTransportHandler
is not static and has a reference to the outer class. Since the inner class is published and calls methods within the outer class, there is a chance that this could happen before the outer class is fully constructed, which violates the JLS.For correctness, this code should be changed so that the handler registration no longer occurs within a constructor. However, given the use of guice to construct transport actions and eventual refactoring to remove guice it may be best to consider this as part of that effort.
The text was updated successfully, but these errors were encountered: