Port Netflix/Hystrix#1976 remove canceled timer tasks#4
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d9bfe87e5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| executor = new ScheduledThreadPoolExecutor(coreSize, threadFactory); | ||
| executor.setRemoveOnCancelPolicy(true); |
There was a problem hiding this comment.
Preserve Java 6 timer compatibility
This call uses ScheduledThreadPoolExecutor.setRemoveOnCancelPolicy, which is only available starting in Java 7, but the project still documents support for “Java 6 or later” in README.md:140. On a Java 6 runtime, initializing HystrixTimer now throws NoSuchMethodError here before initialized is set, leaving the singleton executor non-null but uninitialized; later timer use can then spin in startThreadIfNeeded() instead of recovering. Please either avoid this API on Java 6 (for example by reflective/version-gated use) or explicitly drop Java 6 support.
Useful? React with 👍 / 👎.
Ports Netflix#1976 into this fork.\n\nThe upstream change enables ScheduledThreadPoolExecutor#setRemoveOnCancelPolicy(true) for HystrixTimer so canceled timeout tasks are removed from the scheduler queue instead of remaining until their delay elapses.\n\nUpstream reference: https://github.com/Netflix/Hystrix/pull/1976\nOriginal commit: 2f4520d\n\nVerification:\n- PASS: JAVA_HOME=/Users/amrith/.sdkman/candidates/java/17.0.6-tem ./gradlew :hystrix-core:test --tests com.netflix.hystrix.util.HystrixTimerTest --no-daemon\n- NOTE: ./gradlew :hystrix-core:test --no-daemon failed under Java 21 before compilation because Gradle/Groovy cannot parse class file major version 65. Re-run under Java 17 progressed into tests but hung in the broader test task, so it was stopped and replaced with the focused HystrixTimer test above.\n