scwhittle commented on code in PR #30270:
URL: https://github.com/apache/beam/pull/30270#discussion_r1484146997
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/DataflowExecutionContext.java:
##########
@@ -341,8 +342,8 @@ public Optional<ActiveMessageMetadata>
getActiveMessageMetadata() {
return Optional.ofNullable(activeMessageMetadata);
}
- public Map<String, IntSummaryStatistics> getProcessingTimesByStepCopy() {
- Map<String, IntSummaryStatistics> processingTimesCopy =
processingTimesByStep;
+ public synchronized Map<String, IntSummaryStatistics>
getProcessingTimesByStepCopy() {
+ Map<String, IntSummaryStatistics> processingTimesCopy = new
HashMap<>(processingTimesByStep);
Review Comment:
you will also need to synchronize access to processingTimesByStep below
I believe activeMessageMetadata itself is only accessed by the processing
thread, so you can just put a synchronized block around the map modification
synchronized (this) {
this.processingTimesByStep.compute(...);
}
--
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]