Tabnine Logo
org.springframework.batch.core.step.skip
Code IndexAdd Tabnine to your IDE (free)

How to use org.springframework.batch.core.step.skip

Best Java code snippets using org.springframework.batch.core.step.skip (Showing top 20 results out of 315)

origin: spring-projects/spring-batch

@Override
public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException {
  for (SkipPolicy policy : skipPolicies) {
    if (policy.shouldSkip(t, skipCount)) {
      return true;
    }
  }
  return false;
}
origin: spring-projects/spring-batch

/**
 * Convenience method for calling process skip policy, so that it can be
 * called from multiple places.
 *
 * @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, int skipCount) {
  try {
    return policy.shouldSkip(e, skipCount);
  }
  catch (SkipLimitExceededException ex) {
    throw ex;
  }
  catch (RuntimeException ex) {
    throw new SkipListenerFailedException("Fatal exception in SkipPolicy.", ex, e);
  }
}
origin: spring-projects/spring-batch

/**
 * 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, int skipCount) {
  try {
    return policy.shouldSkip(e, skipCount);
  }
  catch (SkipException ex) {
    throw ex;
  }
  catch (RuntimeException ex) {
    throw new SkipPolicyFailedException("Fatal exception in SkipPolicy.", ex, e);
  }
}
origin: spring-projects/spring-batch

/**
 * Wrap a {@link SkipPolicy} and make it consistent with known fatal exceptions.
 *
 * @param skipPolicy an existing skip policy
 * @return a skip policy that will not skip fatal exceptions
 */
protected SkipPolicy getFatalExceptionAwareProxy(SkipPolicy skipPolicy) {
  NeverSkipItemSkipPolicy neverSkipPolicy = new NeverSkipItemSkipPolicy();
  Map<Class<? extends Throwable>, SkipPolicy> map = new HashMap<>();
  for (Class<? extends Throwable> fatal : nonSkippableExceptionClasses) {
    map.put(fatal, neverSkipPolicy);
  }
  SubclassClassifier<Throwable, SkipPolicy> classifier = new SubclassClassifier<>(skipPolicy);
  classifier.setTypeMap(map);
  ExceptionClassifierSkipPolicy skipPolicyWrapper = new ExceptionClassifierSkipPolicy();
  skipPolicyWrapper.setExceptionClassifier(classifier);
  return skipPolicyWrapper;
}
origin: spring-projects/spring-batch

protected SkipPolicy createSkipPolicy() {
  SkipPolicy skipPolicy = this.skipPolicy;
  Map<Class<? extends Throwable>, Boolean> map = new HashMap<>(
      skippableExceptionClasses);
  map.put(ForceRollbackForWriteSkipException.class, true);
  LimitCheckingItemSkipPolicy limitCheckingItemSkipPolicy = new LimitCheckingItemSkipPolicy(skipLimit, map);
  if (skipPolicy == null) {
    Assert.state(!(skippableExceptionClasses.isEmpty() && skipLimit > 0),
        "If a skip limit is provided then skippable exceptions must also be specified");
    skipPolicy = limitCheckingItemSkipPolicy;
  }
  else if (limitCheckingItemSkipPolicy != null) {
    skipPolicy = new CompositeSkipPolicy(new SkipPolicy[] { skipPolicy, limitCheckingItemSkipPolicy });
  }
  return skipPolicy;
}
origin: spring-projects/spring-batch

private LimitCheckingItemSkipPolicy getFatalSubsetSkipPolicy() {
  Map<Class<? extends Throwable>, Boolean> skippableExceptions = new HashMap<>();
  skippableExceptions.put(WriteFailedException.class, false);
  skippableExceptions.put(ItemWriterException.class, true);
  return new LimitCheckingItemSkipPolicy(1, skippableExceptions);
}
origin: spring-projects/spring-batch

/**
 * Setter for policy map. This property should not be changed dynamically -
 * set it once, e.g. in configuration, and then don't change it during a
 * running application. Either this property or the exception classifier
 * directly should be set, but not both.
 *
 * @param policyMap a map of String to {@link SkipPolicy} that will be used
 * to create a {@link Classifier} to locate a policy.
 */
public void setPolicyMap(Map<Class<? extends Throwable>, SkipPolicy> policyMap) {
  SubclassClassifier<Throwable, SkipPolicy> subclassClassifier = new SubclassClassifier<>(
      policyMap, new NeverSkipItemSkipPolicy());
  this.classifier = subclassClassifier;
}
origin: spring-projects/spring-batch

@Override
public Exception getException(String msg, RuntimeException cause, Throwable e) throws Exception {
  return new SkipListenerFailedException(msg, cause, e);
}
origin: spring-projects/spring-batch

@Override
public Exception getException(String msg, Throwable e) throws Exception {
  return new NonSkippableReadException(msg, e);
}
origin: spring-projects/spring-batch

@Override
public Exception getException(String msg, RuntimeException cause, Throwable e) throws Exception {
  return new SkipPolicyFailedException(msg, cause, e);
}
origin: spring-projects/spring-batch

/**
 * condition: skippable < fatal; exception is unclassified
 * 
 * expected: false; default classification
 */
@Test
public void testSkippableSubset_unclassified() {
  assertFalse(getSkippableSubsetSkipPolicy().shouldSkip(new RuntimeException(), 0));
}
origin: spring-projects/spring-batch

/**
 * condition: fatal < skippable; exception is unclassified
 * 
 * expected: false; default classification
 */
@Test
public void testFatalSubset_unclassified() {
  assertFalse(getFatalSubsetSkipPolicy().shouldSkip(new RuntimeException(), 0));
}
origin: spring-projects/spring-batch

@Override
public Exception getException(String msg, Throwable e) throws Exception {
  return new NonSkippableWriteException(msg, e);
}
origin: spring-projects/spring-batch

/**
 * 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, int skipCount) {
  try {
    return policy.shouldSkip(e, skipCount);
  }
  catch (SkipException ex) {
    throw ex;
  }
  catch (RuntimeException ex) {
    throw new SkipPolicyFailedException("Fatal exception in SkipPolicy.", ex, e);
  }
}
origin: spring-projects/spring-batch

/**
 * Consult the classifier and find a delegate policy, and then use that to
 * determine the outcome.
 *
 * @param t the throwable to consider
 * @param skipCount the current skip count
 * @return true if the exception can be skipped
 * @throws SkipLimitExceededException if a limit is exceeded
 */
@Override
public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException {
  return classifier.classify(t).shouldSkip(t, skipCount);
}
origin: spring-projects/spring-batch

private LimitCheckingItemSkipPolicy getSkippableSubsetSkipPolicy() {
  Map<Class<? extends Throwable>, Boolean> skippableExceptions = new HashMap<>();
  skippableExceptions.put(WriteFailedException.class, true);
  skippableExceptions.put(ItemWriterException.class, false);
  return new LimitCheckingItemSkipPolicy(1, skippableExceptions);
}
origin: spring-projects/spring-batch

/**
 * condition: skippable < fatal; exception is skippable
 * 
 * expected: true
 */
@Test
public void testSkippableSubset_skippable() {
  assertTrue(getSkippableSubsetSkipPolicy().shouldSkip(new WriteFailedException(""), 0));
}
origin: spring-projects/spring-batch

/**
 * condition: fatal < skippable; exception is skippable
 * 
 * expected: true
 */
@Test
public void testFatalSubset_skippable() {
  assertTrue(getFatalSubsetSkipPolicy().shouldSkip(new WriterNotOpenException(""), 0));
}
origin: spring-projects/spring-batch

/**
 * condition: skippable < fatal; exception is fatal
 * 
 * expected: false
 */
@Test
public void testSkippableSubset_fatal() {
  assertFalse(getSkippableSubsetSkipPolicy().shouldSkip(new WriterNotOpenException(""), 0));
}
origin: spring-projects/spring-batch

  /**
   * condition: fatal < skippable; exception is fatal
   * 
   * expected: false
   */
  @Test
  public void testFatalSubset_fatal() {
    assertFalse(getFatalSubsetSkipPolicy().shouldSkip(new WriteFailedException(""), 0));
  }
}
org.springframework.batch.core.step.skip

Most used classes

  • ExceptionClassifierSkipPolicy
    A SkipPolicy that depends on an exception classifier to make its decision, and then delegates to the
  • LimitCheckingItemSkipPolicy
    SkipPolicy that determines whether or not reading should continue based upon how many items have be
  • NeverSkipItemSkipPolicy
    SkipPolicy implementation that always returns false, indicating that an item should not be skipped.
  • NonSkippableReadException
    Fatal exception to be thrown when a read operation could not be skipped.
  • SkipListenerFailedException
    Special exception to indicate a failure in a skip listener. These need special treatment in the fram
  • SkipPolicyFailedException,
  • NonSkippableProcessException,
  • SkipLimitExceededException,
  • CompositeSkipPolicy,
  • AlwaysSkipItemSkipPolicy,
  • LimitCheckingItemSkipPolicyTests,
  • NonSkippableWriteException,
  • ReprocessExceptionTests$Person
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now