(Re-)Add coalesceToEmpty method to o.o.common.Strings util class #5664
Labels
Build Libraries & Interfaces
enhancement
Enhancement or improvement to existing feature or request
Plugins
Is your feature request related to a problem? Please describe.
A relatively common use case during REST handling is to replace a null String with an empty String:
Such a method exists in ml-commons and anomaly-detection plugins and is being added to job-scheduler.
This exists in the current release (2.4.1) of the
Strings
class here and is referenced by the alerting plugin but was removed in #5288 as "unused". (This broke the AD plugin which prompted re-adding its own method.)Describe the solution you'd like
Don't repeat code. Add this method back to the
Strings
class.Additionally, I'm curious why this util class is marked "internal" as it's useful for dependent classes to use (which at least the alerting plugin does). The removal was not marked deprecated nor mentioned in the change log (likely because of its "internal" usage) but there is a lot of use of other methods in this class.
Describe alternatives you've considered
It may be a better idea to create a util class with all the
RestHandlerUtils
in the above-linked plugin packages.Additional context
The method appears to have originated in
com.google.common.base.Strings
and was moved to theStrings
class (in open-source ES pre-fork) to remove that external dependency.If we want to remove "internal" util classes/methods like this, we should consider either using external dependencies or creating a separate supported (API) project with util classes to provide the same functionality without duplicating code.
The text was updated successfully, but these errors were encountered: