sijie closed pull request #1767: check record returned by source is not null URL: https://github.com/apache/incubator-pulsar/pull/1767
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java b/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java index 3ef7bacdcd..084ddc8215 100644 --- a/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java +++ b/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java @@ -321,12 +321,21 @@ private void sendOutputMessage(Record srcRecord, Object output) { } private Record readInput() { + Record record; try { - return this.source.read(); + record = this.source.read(); } catch (Exception e) { - log.info("Encountered exception in source write: ", e); + log.info("Encountered exception in source read: ", e); throw new RuntimeException(e); } + + // check record is valid + if (record == null) { + throw new IllegalArgumentException("The record returned by the source cannot be null"); + } else if (record.getValue() == null) { + throw new IllegalArgumentException("The value in the record returned by the source cannot be null"); + } + return record; } @Override ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services