Hi, devs, Recently, in the PR of FLINK-19179[1], we have a discussion about how to implement singleton pattern in Flink.
Currently, most of the utility classes implement singleton pattern through the private constructor. Seldom utility classes leverage the enum mechanism. From my perspective, leveraging enum mechanism is more simple and it can also overcome reflection. Whether using enum classes or private constructors, it will be good to align the approach to achieve singleton in the whole Flink project. I would propose to leverage the enum mechanism in the Flink to implement singleton pattern and append it to the code-style guidelines. We may also have a JIRA ticket to refactor the existing code. What do you think? [1] https://github.com/apache/flink/pull/13416 Best, Yangze Guo