Daniel Halperin created BEAM-381:
------------------------------------
Summary: OffsetBasedReader should construct sources before
updating the range tracker
Key: BEAM-381
URL: https://issues.apache.org/jira/browse/BEAM-381
Project: Beam
Issue Type: Bug
Components: sdk-java-core
Affects Versions: 0.1.0-incubating, 0.2.0-incubating
Reporter: Daniel Halperin
Assignee: Daniel Halperin
OffsetBasedReader has the following code:
{code}
if (!rangeTracker.trySplitAtPosition(splitOffset)) {
return null;
}
long start = source.getStartOffset();
long end = source.getEndOffset();
OffsetBasedSource<T> primary = source.createSourceForSubrange(start,
splitOffset);
OffsetBasedSource<T> residual =
source.createSourceForSubrange(splitOffset, end);
this.source = primary;
return residual;
{code}
The first line is the line that updates the range of this source. However,
subsequent lines might throw (specifically, in source.createSourceForSubrange).
We should construct the sources first, and then catch exceptions and return
null if they fail. This way, the splitAtFraction call will not throw (so work
is not wasted) and the range tracker will not be updated if either the primary
or (more likely) the residual could not be created.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)