acrites opened a new pull request, #41800: URL: https://github.com/apache/beam/pull/41800
Fixes a guaranteed `NullPointerException` / dead code block in `WindmillMap.persistDirectly`. In the `localRemovals` loop, the code previously removed the key from `cachedValues` and immediately checked `if (cachedValue != null)` only to call `valueCoder.encode(cachedValues.get(key), ...)` — which passed `null` since the key had just been removed from `cachedValues`, and serialized into an unused `ByteStringOutputStream`. Note, this code doesn't run since calling `WindmillMap.remove()` already removes the key from `localRemovals`. My best guess for the intention of this code was in the TODO at the end of `Commit()`. The idea is to cache the size of the map state as changes are made to it to prevent needing to scan the entire map object to get its size. So when we get to adding that feature, we might add something like this back in (where we encode the non-null `cachedValue` instead of re-looking up in the map). ### Testing - Added `WindmillMapTest` covering `persistDirectly` with no changes, local additions, local removals, and `clear()` + additions. - Verified locally with `./gradlew :runners:google-cloud-dataflow-java:worker:spotlessJavaCheck :runners:google-cloud-dataflow-java:worker:test --tests "org.apache.beam.runners.dataflow.worker.windmill.state.WindmillMapTest" --tests "org.apache.beam.runners.dataflow.worker.windmill.state.WindmillStateInternalsTest"` (125 tests, 125 passed). -- 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]
