Phixsura opened a new pull request, #22333:
URL: https://github.com/apache/kafka/pull/22333

   ## Background
   [KAFKA-20404](https://issues.apache.org/jira/browse/KAFKA-20404) tracks 
replacing the bulk SpotBugs atomicity excludes (introduced when SpotBugs was 
upgraded from 4.8.6 to 4.9.4) with per-field investigations. This PR handles 
`DefaultStateUpdater$StateUpdaterThread`, the second class in the series after 
`StreamThread` (#22320).
   
   ## Investigation
   After removing `DefaultStateUpdater$StateUpdaterThread` from the two bulk 
excludes it appeared in (`AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE` at line 
505 and `AT_NONATOMIC_64BIT_PRIMITIVE` at line 544 on trunk), SpotBugs reports 
exactly one field with warnings:
   
   - `totalCheckpointLatency` at `DefaultStateUpdater.java:100`, flagged at 
line 732 (`measureCheckpointLatency`) and line 750 (`recordMetrics`).
   
   Walking the call sites:
   - `measureCheckpointLatency` is `private` and only called from within 
`StateUpdaterThread`: `restoreTasks`, `pauseTasks`, `resumeTasks`, 
`removeUpdatingTask`, `maybeCheckpointTasks`.
   - `recordMetrics` is `private` and only called from 
`StateUpdaterThread.runOnce` (line 213).
   - All callers run on the `StateUpdaterThread` itself (the inner class 
extends `Thread`).
   
   So `totalCheckpointLatency` is thread-confined and the SpotBugs warnings are 
false positives.
   
   ## Changes
   - Remove `DefaultStateUpdater$StateUpdaterThread` from the two bulk `<Or>` 
blocks.
   - Add two targeted `<Match>` blocks scoped to the class plus the 
`totalCheckpointLatency` field, each with a rationale comment explaining the 
thread-confinement, one per bug pattern.
   
   ## Verification
   - `:streams:spotbugsMain --rerun-tasks` clean.
   - `:streams:checkstyleMain` / `:streams:checkstyleTest` / 
`:streams:spotbugsTest` clean.
   - `:streams:test --tests "*DefaultStateUpdater*"` all green.


-- 
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]

Reply via email to