Polber commented on code in PR #29261:
URL: https://github.com/apache/beam/pull/29261#discussion_r1379485802
##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaReadSchemaTransformProvider.java:
##########
@@ -262,17 +270,22 @@ public static class ErrorFn extends DoFn<byte[], Row> {
private SerializableFunction<byte[], Row> valueMapper;
private Counter errorCounter;
private Long errorsInBundle = 0L;
+ private final boolean failOnError;
- public ErrorFn(String name, SerializableFunction<byte[], Row> valueMapper)
{
+ public ErrorFn(String name, SerializableFunction<byte[], Row> valueMapper,
boolean failOnError) {
this.errorCounter =
Metrics.counter(KafkaReadSchemaTransformProvider.class, name);
this.valueMapper = valueMapper;
+ this.failOnError = failOnError;
}
@ProcessElement
public void process(@DoFn.Element byte[] msg, MultiOutputReceiver
receiver) {
try {
receiver.get(OUTPUT_TAG).output(valueMapper.apply(msg));
Review Comment:
Done.
##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaReadSchemaTransformProvider.java:
##########
@@ -262,17 +270,22 @@ public static class ErrorFn extends DoFn<byte[], Row> {
private SerializableFunction<byte[], Row> valueMapper;
private Counter errorCounter;
private Long errorsInBundle = 0L;
+ private final boolean failOnError;
- public ErrorFn(String name, SerializableFunction<byte[], Row> valueMapper)
{
+ public ErrorFn(String name, SerializableFunction<byte[], Row> valueMapper,
boolean failOnError) {
this.errorCounter =
Metrics.counter(KafkaReadSchemaTransformProvider.class, name);
this.valueMapper = valueMapper;
+ this.failOnError = failOnError;
}
@ProcessElement
public void process(@DoFn.Element byte[] msg, MultiOutputReceiver
receiver) {
try {
receiver.get(OUTPUT_TAG).output(valueMapper.apply(msg));
} catch (Exception e) {
+ if (failOnError) {
+ throw new RuntimeException(e.getMessage());
Review Comment:
Done.
--
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]