Skip to content

Commit 0bad579

Browse files
committed
Address review: use MapElements in JsonToRow regression test.
Avoid anonymous DoFn capturing the non-serializable test instance so the test is safe on runners that enforce DoFn serialization.
1 parent 87dc61f commit 0bad579

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/JsonToRowTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.beam.sdk.util.RowJson.RowJsonDeserializer.NullBehavior;
3434
import org.apache.beam.sdk.values.PCollection;
3535
import org.apache.beam.sdk.values.Row;
36+
import org.apache.beam.sdk.values.TypeDescriptors;
3637
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
3738
import org.junit.Rule;
3839
import org.junit.Test;
@@ -285,13 +286,11 @@ public void testDownstreamExceptionIsNotReportedAsParseError() {
285286
.getResults()
286287
.apply(
287288
"throwingDownstream",
288-
ParDo.of(
289-
new DoFn<Row, Row>() {
290-
@ProcessElement
291-
public void processElement(ProcessContext context) {
292-
throw new RuntimeException("downstream failure");
293-
}
294-
}));
289+
MapElements.into(TypeDescriptors.rows())
290+
.via(
291+
(Row row) -> {
292+
throw new RuntimeException("downstream failure");
293+
}));
295294

296295
thrown.expect(RuntimeException.class);
297296
thrown.expectMessage("downstream failure");

0 commit comments

Comments
 (0)