RESOLVED - issue BATCH-461: skip counting
http://jira.springframework.org/browse/BATCH-461 ItemOrientedStep now increments StepExecution's skipCount from StepContribution on rollback. Simple assert checking the correct value of StepExecution#skipCount added to SkipLimitStepFactoryBeanTests. Btw. renamed StepContribution#taskCount to itemCount
This commit is contained in:
@@ -25,7 +25,7 @@ package org.springframework.batch.core;
|
||||
*/
|
||||
public class StepContribution {
|
||||
|
||||
private int taskCount = 0;
|
||||
private int itemCount = 0;
|
||||
|
||||
private int parentSkipCount;
|
||||
|
||||
@@ -43,8 +43,8 @@ public class StepContribution {
|
||||
/**
|
||||
* Increment the counter for the number of tasks executed.
|
||||
*/
|
||||
public void incrementTaskCount() {
|
||||
taskCount++;
|
||||
public void incrementItemCount() {
|
||||
itemCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,8 +52,8 @@ public class StepContribution {
|
||||
*
|
||||
* @return the task execution counter.
|
||||
*/
|
||||
public int getTaskCount() {
|
||||
return taskCount;
|
||||
public int getItemCount() {
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -303,7 +303,7 @@ public class StepExecution extends Entity {
|
||||
* @param contribution
|
||||
*/
|
||||
public synchronized void apply(StepContribution contribution) {
|
||||
itemCount += contribution.getTaskCount();
|
||||
itemCount += contribution.getItemCount();
|
||||
// TODO: this should not be necessary - the step decides
|
||||
// executionContext = contribution.getExecutionContext();
|
||||
commitCount += contribution.getCommitCount();
|
||||
@@ -336,6 +336,10 @@ public class StepExecution extends Entity {
|
||||
public int getSkipCount() {
|
||||
return skipCount;
|
||||
}
|
||||
|
||||
public void incrementSkipCountBy(int count) {
|
||||
skipCount += count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to get the current job parameters.
|
||||
|
||||
@@ -333,10 +333,12 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
|
||||
}
|
||||
catch (Error e) {
|
||||
stepExecution.incrementSkipCountBy(contribution.getContributionSkipCount());
|
||||
processRollback(stepExecution, fatalException, transaction);
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
stepExecution.incrementSkipCountBy(contribution.getContributionSkipCount());
|
||||
processRollback(stepExecution, fatalException, transaction);
|
||||
throw e;
|
||||
}
|
||||
@@ -467,7 +469,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
// check for interruption before each item as well
|
||||
interruptionPolicy.checkInterrupted(execution);
|
||||
ExitStatus exitStatus = itemHandler.handle(contribution);
|
||||
contribution.incrementTaskCount();
|
||||
contribution.incrementItemCount();
|
||||
// check for interruption after each item as well
|
||||
interruptionPolicy.checkInterrupted(execution);
|
||||
return exitStatus;
|
||||
|
||||
Reference in New Issue
Block a user