-
Notifications
You must be signed in to change notification settings - Fork 296
Make ZpeUpdPolLoader ScheduledExecutorService thread daemon #3086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @thonra, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a critical improvement to the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a JVM shutdown hook to ZpeUpdPolLoader to ensure the ScheduledExecutorService is properly shut down, preventing issues with graceful application shutdown. The implementation is solid, using an AtomicBoolean for idempotency and correctly handling the lifecycle of the shutdown hook to prevent memory leaks. The accompanying tests are comprehensive and cover the new logic well. I have one suggestion to improve the robustness of the close() method in an edge case.
clients/java/zpe/src/main/java/com/yahoo/athenz/zpe/ZpeUpdPolLoader.java
Outdated
Show resolved
Hide resolved
4c52357 to
4a7ccae
Compare
| // find the java7 api for monitoring files | ||
| // see http://docs.oracle.com/javase/tutorial/essential/io/notification.html | ||
|
|
||
| private final ScheduledExecutorService scheduledExecutorSvc = Executors.newScheduledThreadPool(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion : make threads daemon, and prefix the thread names with a known substring
… as daemon Signed-off-by: thonra <[email protected]>
4a7ccae to
c782071
Compare
|
/gemini summary |
Summary of ChangesThis pull request addresses a resource management issue where the Highlights
Changelog
Activity
|
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses an issue where a ScheduledExecutorService in ZpeUpdPolLoader was preventing graceful shutdown of services like Tomcat. The change correctly configures the executor's threads as daemon threads using a ThreadFactory. This ensures they no longer block process exit. The change also assigns an explicit name to the thread, which is helpful for debugging. My review includes a suggestion to simplify the thread naming for better readability.
clients/java/zpe/src/main/java/com/yahoo/athenz/zpe/ZpeUpdPolLoader.java
Show resolved
Hide resolved
|
@TakuyaMatsu san, |
Description
Background
In our services, we frequently call the static method
AuthZpeClient.allowAccessto determine whether access is allowed. The underlyingZpeClientwhich it relies on is initialized inAuthZpeClient's static block, so callers typically don’t pay attention to its initialization lifecycle.ZpeClient(implemented by ZpeUpdater) depends on theZpeUpdPolLoaderinstance.ZpeUpdPolLoaderautomatically creates aScheduledExecutorService, which currently does not shut down automatically on process exit; it requires an explicitclose()call from the caller. Recently, we observed that this executor remained alive during shutdown, which blocked Tomcat’s graceful exit.Pain point
The pain point is that when using the static allowAccess API, client code performs no initialization and is therefore unlikely to realize it must invoke close() to cascade the shutdown and release the underlying
ScheduledExecutorService. This leads to negative impact on the service shutdown path.Proposal
To prevent threads created by
ZpeUpdPolLoaderfrom blocking Tomcat’s graceful shutdown, set them as daemon threads and give them explicit names to make troubleshooting easier.Contribution Checklist:
#3085