[
https://issues.apache.org/jira/browse/BEAM-3876?focusedWorklogId=81911&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-81911
]
ASF GitHub Bot logged work on BEAM-3876:
----------------------------------------
Author: ASF GitHub Bot
Created on: 19/Mar/18 16:30
Start Date: 19/Mar/18 16:30
Worklog Time Spent: 10m
Work Description: lukecwik commented on a change in pull request #4894:
[BEAM-3876] avoid NPE if checkpoint is null in an unbounded source
URL: https://github.com/apache/beam/pull/4894#discussion_r175498833
##########
File path:
runners/direct-java/src/main/java/org/apache/beam/runners/direct/UnboundedReadEvaluatorFactory.java
##########
@@ -171,10 +171,28 @@ public void processElement(
watermark)));
} else {
// End of input. Close the reader after finalizing old checkpoint.
- shard.getCheckpoint().finalizeCheckpoint();
- UnboundedReader<?> toClose = reader;
- reader = null; // Avoid double close below in case of an exception.
- toClose.close();
+ // note: can be null for empty datasets so ensure to null check
the checkpoint
+ final CheckpointMarkT checkpoint = shard.getCheckpoint();
+ IOException ioe = null;
+ try {
+ if (checkpoint != null) {
+ checkpoint.finalizeCheckpoint();
+ }
+ } catch (final IOException finalizeCheckpointException) {
+ ioe = finalizeCheckpointException;
+ } finally {
+ try {
+ UnboundedReader<?> toClose = reader;
+ reader = null; // Avoid double close below in case of an
exception.
+ toClose.close();
+ } catch (final IOException closeEx) {
+ if (ioe != null) {
+ ioe.addSuppressed(closeEx);
+ } else {
+ throw closeEx;
+ }
+ }
Review comment:
Your forgetting to throw `ioe` if close doesn't throw.
Please add a test to cover these cases.
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 81911)
Time Spent: 0.5h (was: 20m)
> unbounded source can not have any checkpoint when they end (no data case)
> -------------------------------------------------------------------------
>
> Key: BEAM-3876
> URL: https://issues.apache.org/jira/browse/BEAM-3876
> Project: Beam
> Issue Type: Bug
> Components: runner-direct
> Affects Versions: 2.4.0
> Reporter: Romain Manni-Bucau
> Assignee: Romain Manni-Bucau
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)