scwhittle commented on code in PR #30270:
URL: https://github.com/apache/beam/pull/30270#discussion_r1484140438


##########
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:
   this is still exposing the IntSummaryStatistics which is not an immutable 
object.
   https://docs.oracle.com/javase/8/docs/api/java/util/IntSummaryStatistics.html
   
   So I think you need to do a deep copy of the values as well.
   Map<String, IntSummaryStatistics> processingTimesCopy = 
processingTimesByStep.entrySet().stream()
       .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().clone())
   
   you might need to cast the clone result, not sure.
   
   



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