jt2594838 opened a new pull request, #18950: URL: https://github.com/apache/iotdb/pull/18950
## Description Concurrent JVM thread-state gauge reads can overlap with clearing and rebuilding the shared `EnumMap`. Its non-atomic `getOrDefault` checks can return `null` during repopulation, causing an NPE when the count is unboxed. Synchronize the complete refresh-and-read operation with a class-level lock, matching the static cache's scope. Missing states continue to return zero, and the sampling interval remains unchanged. Add regression coverage for missing states, null thread information, cached sampling, and a concurrent read while a refresh is paused after clearing the cache. ## Validation - `mvn spotless:apply -pl iotdb-core/metrics/interface -am -Drat.skip=true` - `mvn test -pl iotdb-core/metrics/interface -am -Dtest=JvmThreadMetricsTest -Dsurefire.failIfNoSpecifiedTests=false -Drat.skip=true`: 2 tests passed; reactor build succeeded, including Checkstyle and Spotless checks. - Running the regression tests against the original implementation fails the concurrent-refresh case with an expected count of 1 and an actual count of 0. The test deterministically covers intermediate cache visibility rather than directly reproducing the narrower NPE interleaving. --- This PR has: - [x] been self-reviewed for concurrent reads and writes. - [x] added comments explaining the synchronization requirement and test scenarios. - [x] added unit tests covering the changed behavior. ##### Key changed/added classes - `JvmThreadMetrics` - `JvmThreadMetricsTest` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
