class FaultTolerantChunkProvider<I> extends SimpleChunkProvider<I> {

	/**
	 * Hard limit for number of read skips in the same chunk. Should be sufficiently high
	 * that it is only encountered in a runaway step where all items are skipped before
	 * the chunk can complete (leading to a potential heap memory problem).
	 */
	public static final int DEFAULT_MAX_SKIPS_ON_READ = 100;

	private SkipPolicy skipPolicy = new LimitCheckingItemSkipPolicy();

	private Classifier<Throwable, Boolean> rollbackClassifier = new BinaryExceptionClassifier(true);

	private int maxSkipsOnRead = DEFAULT_MAX_SKIPS_ON_READ;

	public FaultTolerantChunkProvider(ItemReader<? extends I> itemReader, RepeatOperations repeatOperations) {
		super(itemReader, repeatOperations);
	}

	/**
	 * @param maxSkipsOnRead the maximum number of skips on read
	 */
	public void setMaxSkipsOnRead(int maxSkipsOnRead) {
		this.maxSkipsOnRead = maxSkipsOnRead;
	}

	/**
	 * The policy that determines whether exceptions can be skipped on read.
	 * @param skipPolicy instance of {@link SkipPolicy} to be used by
	 * FaultTolerantChunkProvider.
	 */
	public void setSkipPolicy(SkipPolicy skipPolicy) {
		this.skipPolicy = skipPolicy;
	}

	/**
	 * Classifier to determine whether exceptions have been marked as no-rollback (as
	 * opposed to skippable). If encountered they are simply ignored, unless also
	 * skippable.
	 * @param rollbackClassifier the rollback classifier to set
	 */
	public void setRollbackClassifier(Classifier<Throwable, Boolean> rollbackClassifier) {
		this.rollbackClassifier = rollbackClassifier;
	}

	@Override
	protected I read(StepContribution contribution, Chunk<I> chunk) throws Exception {
		while (true) {
			try {
				return doRead();
			}
			catch (Exception e) {

				if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) {

					// increment skip count and try again
					contribution.incrementReadSkipCount();
					chunk.skip(e);

					if (chunk.getErrors().size() >= maxSkipsOnRead) {
						throw new SkipOverflowException("Too many skips on read");
					}

					logger.debug("Skipping failed input", e);
				}
				else {
					if (rollbackClassifier.classify(e)) {
						throw new NonSkippableReadException("Non-skippable exception during read", e);
					}
					logger.debug("No-rollback for non-skippable exception (ignored)", e);
				}

			}
		}
	}

	@Override
	public void postProcess(StepContribution contribution, Chunk<I> chunk) {
		for (Exception e : chunk.getErrors()) {
			try {
				getListener().onSkipInRead(e);
			}
			catch (RuntimeException ex) {
				throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e);
			}
		}
	}

	/**
	 * Convenience method for calling process skip policy.
	 * @param policy the skip policy
	 * @param e the cause of the skip
	 * @param skipCount the current skip count
	 */
	private boolean shouldSkip(SkipPolicy policy, Throwable e, long skipCount) {<FILL_FUNCTION_BODY>}

}

		try {
			return policy.shouldSkip(e, skipCount);
		}
		catch (SkipException ex) {
			throw ex;
		}
		catch (RuntimeException ex) {
			throw new SkipPolicyFailedException("Fatal exception in SkipPolicy.", ex, e);
		}
	
<methods>public void <init>(ItemReader<? extends I>, org.springframework.batch.repeat.RepeatOperations) ,public void postProcess(org.springframework.batch.core.StepContribution, Chunk<I>) ,public Chunk<I> provide(org.springframework.batch.core.StepContribution) throws java.lang.Exception,public void registerListener(org.springframework.batch.core.StepListener) ,public void setListeners(List<? extends org.springframework.batch.core.StepListener>) ,public void setMeterRegistry(io.micrometer.core.instrument.MeterRegistry) <variables>protected final non-sealed ItemReader<? extends I> itemReader,private final MulticasterBatchListener<I,?> listener,protected final org.apache.commons.logging.Log logger,private io.micrometer.core.instrument.MeterRegistry meterRegistry,private final non-sealed org.springframework.batch.repeat.RepeatOperations repeatOperations