diff --git a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java index d2b10f91c064..0d9328fe136d 100644 --- a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java +++ b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java @@ -1339,9 +1339,9 @@ public DataflowPipelineJob run(Pipeline pipeline) { int jobGraphByteSize = jobGraphBytes.length; if (jobGraphByteSize >= CREATE_JOB_REQUEST_LIMIT_BYTES && !hasExperiment(options, "upload_graph")) { - List experiments = firstNonNull(options.getExperiments(), new ArrayList<>()); - experiments.add("upload_graph"); - options.setExperiments(ImmutableList.copyOf(experiments)); + List experiments = firstNonNull(options.getExperiments(), Collections.emptyList()); + options.setExperiments( + ImmutableList.builder().addAll(experiments).add("upload_graph").build()); LOG.info( "The job graph size ({} in bytes) is larger than {}. Automatically add " + "the upload_graph option to experiments.",