@Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { for (SkipPolicy policy : skipPolicies) { if (policy.shouldSkip(t, skipCount)) { return true; } } return false; }
/** * 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); }
/** * 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); } }
/** * 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); } }
/** * 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); } }
@Test public void testSkipPolicyAttribute() throws Exception { @SuppressWarnings("resource") ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/batch/core/configuration/xml/ChunkElementSkipPolicyParserTests-context.xml"); SkipPolicy policy = getSkipPolicy("s1", context); assertTrue(policy.shouldSkip(new NullPointerException(), 0)); assertTrue(policy.shouldSkip(new ArithmeticException(), 0)); }
@Test public void testSkipPolicyElement() throws Exception { @SuppressWarnings("resource") ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/batch/core/configuration/xml/ChunkElementSkipPolicyParserTests-context.xml"); SkipPolicy policy = getSkipPolicy("s2", context); assertFalse(policy.shouldSkip(new NullPointerException(), 0)); assertTrue(policy.shouldSkip(new ArithmeticException(), 0)); }
/** * condition: skippable < fatal; exception is unclassified * * expected: false; default classification */ @Test public void testSkippableSubset_unclassified() throws Exception { assertFalse(getSkippableSubsetSkipPolicy().shouldSkip(new RuntimeException(), 0)); }
/** * condition: fatal < skippable; exception is unclassified * * expected: false; default classification */ @Test public void testFatalSubsetUnclassified() throws Exception { assertFalse(getFatalSubsetSkipPolicy().shouldSkip(new RuntimeException(), 0)); }
/** * condition: fatal < skippable; exception is fatal * * expected: false */ @Test public void testFatalSubsetFatal() throws Exception { assertFalse(getFatalSubsetSkipPolicy().shouldSkip(new WriteFailedException(""), 0)); }
/** * condition: skippable < fatal; exception is skippable * * expected: true */ @Test public void testSkippableSubset_skippable() throws Exception { assertTrue(getSkippableSubsetSkipPolicy().shouldSkip(new WriteFailedException(""), 0)); }
/** * condition: skippable < fatal; exception is fatal * * expected: false */ @Test public void testSkippableSubset_fatal() throws Exception { assertFalse(getSkippableSubsetSkipPolicy().shouldSkip(new WriterNotOpenException(""), 0)); }
/** * condition: fatal < skippable; exception is skippable * * expected: true */ @Test public void testFatalSubsetSkippable() throws Exception { assertTrue(getFatalSubsetSkipPolicy().shouldSkip(new WriterNotOpenException(""), 0)); }
@Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { for (SkipPolicy policy : skipPolicies) { if (policy.shouldSkip(t, skipCount)) { return true; } } return false; }
@Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { for (SkipPolicy policy : skipPolicies) { if (policy.shouldSkip(t, skipCount)) { return true; } } return false; }
@Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { for (SkipPolicy policy : skipPolicies) { if (policy.shouldSkip(t, skipCount)) { return true; } } return false; }
/** * 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 */ public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { return classifier.classify(t).shouldSkip(t, skipCount); }
/** * 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); }
/** * 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); }
/** * 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); }