Skip to content

BATCH-2651: Obvious Fix: ChunkMessageChannelWriter.waitForResults aborts to early #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,23 @@ public Collection<StepContribution> getStepContributions() {
/**
* Wait until all the results that are in the pipeline come back to the reply channel.
*
* @return true if successfully received a result, false if timed out
* @return true if successfully received all pending results, false if timed out
*/
private boolean waitForResults() throws AsynchronousFailureException {
int count = 0;
int maxCount = maxWaitTimeouts;
Throwable failure = null;
logger.info("Waiting for " + localState.getExpecting() + " results");

// Read replies until we had maxCount successive timeouts.
while (localState.getExpecting() > 0 && count++ < maxCount) {
try {
int expecting = localState.getExpecting();
getNextResult();
if( localState.getExpecting() < expecting ) {
// We read a reply, so reset the timeout counter
count = 0;
}
}
catch (Throwable t) {
logger.error("Detected error in remote result. Trying to recover " + localState.getExpecting()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ public void testVanillaIteration() throws Exception {

}

@Test
public void testMaxtimeoutsLessThanThrottleLimit() throws Exception {

// Make certain throttle limit is larger than max wait
// timeouts, this is not the default
writer.setMaxWaitTimeouts(2);
writer.setThrottleLimit(10);

factory.setItemReader(new ListItemReader<String>(Arrays.asList(StringUtils
.commaDelimitedListToStringArray("1,2,3,4,5,6,7,8,9,10"))));


Step step = factory.getObject();

StepExecution stepExecution = getStepExecution(step);
step.execute(stepExecution);

waitForResults(10, 10);

assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
assertEquals(10, TestItemWriter.count);
assertEquals(10, stepExecution.getReadCount());
}

@Test
public void testSimulatedRestart() throws Exception {

Expand Down