Phixsura opened a new pull request, #22341: URL: https://github.com/apache/kafka/pull/22341
## 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 `StreamsPartitionAssignor`, the fourth class in the series after `StreamThread` (#22320), `DefaultStateUpdater` (#22333), and `TaskManager` (#22340). ## Investigation After removing `StreamsPartitionAssignor` from the single bulk `AT_STALE_THREAD_WRITE_OF_PRIMITIVE` block it appeared in (trunk line 600), SpotBugs reports two fields with warnings: - `uniqueField` at `StreamsPartitionAssignor.java:232`, flagged at line 266 (`configure(Map)`) and line 288 (`subscriptionUserData(Set)`). - `usedSubscriptionMetadataVersion` at `StreamsPartitionAssignor.java:223`, flagged at line 1432 and line 1447 (both inside `maybeUpdateSubscriptionVersion(int, int)`). Walking the call sites: - `configure`, `subscriptionUserData`, and `onAssignment` are all `ConsumerPartitionAssignor` / `Configurable` interface methods. The Kafka consumer invokes them from inside `poll()` (e.g. `ConsumerCoordinator.java:311` calls `assignor.subscriptionUserData(...)`, line 370 calls `assignor.onAssignment(...)`). - `maybeUpdateSubscriptionVersion` is `protected` and only called from `maybeScheduleFollowupRebalance` (line 1544), which is itself reached from `onAssignment`. - The package-private `uniqueField()` getter is only invoked by `StreamsPartitionAssignorTest`. `KafkaConsumer.poll()` is driven by the `StreamThread`, so both fields are thread-confined and the SpotBugs warnings are false positives. ## Changes - Remove `StreamsPartitionAssignor` from the bulk `<Or>` block. - Add a single targeted `<Match>` block scoped to the class with an `<Or>` over both fields, with a rationale comment. ## Verification - `:streams:spotbugsMain --rerun-tasks` clean. - `:streams:spotbugsTest` / `:streams:checkstyleMain` / `:streams:checkstyleTest` clean. - `:streams:test --tests "*StreamsPartitionAssignor*"` 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]
