gemini-code-assist[bot] commented on code in PR #38784:
URL: https://github.com/apache/beam/pull/38784#discussion_r3348406220


##########
runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java:
##########
@@ -1321,6 +1322,21 @@ public DataflowPipelineJob run(Pipeline pipeline) {
     if (!ExperimentalOptions.hasExperiment(options, 
"disable_projection_pushdown")) {
       ProjectionPushdownOptimizer.optimize(pipeline);
     }
+    SdkHarnessOptions sdkHarnessOptions = options.as(SdkHarnessOptions.class);
+    if (ExperimentalOptions.hasExperiment(options, 
"enable_opentelemetry_tracing")) {
+      Map<String, String> openTelemetryProperties = 
sdkHarnessOptions.getOpenTelemetryProperties();
+      if (openTelemetryProperties == null) {
+        openTelemetryProperties = new HashMap<>();
+      }

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The map returned by `sdkHarnessOptions.getOpenTelemetryProperties()` may be 
immutable (e.g., if it is an empty map or parsed from an immutable 
configuration source). Modifying it directly with `.put()` can throw an 
`UnsupportedOperationException`. It is safer to copy the existing properties 
into a new mutable `HashMap`.
   
   ```suggestion
         Map<String, String> openTelemetryProperties = 
sdkHarnessOptions.getOpenTelemetryProperties();
         openTelemetryProperties =
             openTelemetryProperties == null
                 ? new HashMap<>()
                 : new HashMap<>(openTelemetryProperties);
   ```



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