groupBy v2: Fix dangling references. (#3500)

Acquiring references in the processing task prevents dangling references
caused by canceled processing tasks.
This commit is contained in:
Gian Merlino 2016-09-23 13:29:11 -07:00 committed by Nishant
parent 9226d4af3c
commit 7195be32d8
1 changed files with 24 additions and 41 deletions

View File

@ -205,49 +205,32 @@ public class GroupByMergingQueryRunnerV2 implements QueryRunner
); );
} }
final Releaser bufferReleaser = mergeBufferHolder.increment(); return exec.submit(
try { new AbstractPrioritizedCallable<Boolean>(priority)
final Releaser grouperReleaser = grouperHolder.increment(); {
try { @Override
return exec.submit( public Boolean call() throws Exception
new AbstractPrioritizedCallable<Boolean>(priority) {
{ try (
@Override Releaser bufferReleaser = mergeBufferHolder.increment();
public Boolean call() throws Exception Releaser grouperReleaser = grouperHolder.increment()
{ ) {
try { final Object retVal = input.run(queryForRunners, responseContext)
final Object retVal = input.run(queryForRunners, responseContext) .accumulate(grouper, accumulator);
.accumulate(grouper, accumulator);
// Return true if OK, false if resources were exhausted. // Return true if OK, false if resources were exhausted.
return retVal == grouper; return retVal == grouper;
}
catch (QueryInterruptedException e) {
throw e;
}
catch (Exception e) {
log.error(e, "Exception with one of the sequences!");
throw Throwables.propagate(e);
}
finally {
grouperReleaser.close();
bufferReleaser.close();
}
}
} }
); catch (QueryInterruptedException e) {
} throw e;
catch (Exception e) { }
// Exception caught while submitting the task; release resources. catch (Exception e) {
grouperReleaser.close(); log.error(e, "Exception with one of the sequences!");
throw e; throw Throwables.propagate(e);
} }
} }
catch (Exception e) { }
// Exception caught while submitting the task; release resources. );
bufferReleaser.close();
throw e;
}
} }
} }
) )