@Override public void afterChunk(ChunkContext context) { try { delegate.afterChunk(); } catch (Exception e) { throw new UncheckedTransactionException(e); } }
@Override public void beforeChunk(ChunkContext context) { try { delegate.beforeChunk(); } catch (Exception e) { throw new UncheckedTransactionException(e); } }
@Override public void afterChunkError(ChunkContext context) { if(context != null) { try { delegate.onError((Exception) context.getAttribute(ChunkListener.ROLLBACK_EXCEPTION_KEY)); } catch (Exception e) { throw new UncheckedTransactionException(e); } } else { throw new BatchRuntimeException("Unable to retrieve causing exception due to null ChunkContext"); } } }
chunkProxy.beforeChunk(); chunkProxy.afterChunk(); chunkProxy.onError(e); } catch (final Exception e1) { logger.log(Level.SEVERE, e1.getMessage(), e1);
l.beforeChunk(); l.onError(e);
@Test(expected=UncheckedTransactionException.class) public void testAfterChunkException() throws Exception { doThrow(new Exception("This is expected")).when(delegate).afterChunk(); adapter.afterChunk(null); }
@Test public void testAfterChunkError() throws Exception { Exception exception = new Exception("This was expected"); when(context.getAttribute(org.springframework.batch.core.ChunkListener.ROLLBACK_EXCEPTION_KEY)).thenReturn(exception); adapter.afterChunkError(context); verify(delegate).onError(exception); } }
@Test(expected=UncheckedTransactionException.class) public void testBeforeChunkException() throws Exception { doThrow(new Exception("This is expected")).when(delegate).beforeChunk(); adapter.beforeChunk(null); }
@Test(expected=UncheckedTransactionException.class) public void testAfterChunkErrorException() throws Exception { doThrow(new Exception("This is expected")).when(delegate).afterChunk(); adapter.afterChunk(null); }
@Override public void onError(Exception ex) throws Exception { try { this.delegate.onError(ex); } catch (Exception e) { this.stepContext.setException(e); throw new BatchContainerRuntimeException(e); } }
@Test public void testBeforeChunk() throws Exception { adapter.beforeChunk(null); verify(delegate).beforeChunk(); }
@Test public void testAfterChunk() throws Exception { adapter.afterChunk(null); verify(delegate).afterChunk(); }
@Override public void onError(Exception ex) throws Exception { try { this.delegate.onError(ex); } catch (Exception e) { this.stepContext.setException(e); throw new BatchContainerRuntimeException(e); } }
@Override public void beforeChunk(ChunkContext context) { try { delegate.beforeChunk(); } catch (Exception e) { throw new UncheckedTransactionException(e); } }
@Override public void afterChunk(ChunkContext context) { try { delegate.afterChunk(); } catch (Exception e) { throw new UncheckedTransactionException(e); } }
@Override public void onError(Exception ex) throws Exception { try { this.delegate.onError(ex); } catch (Exception e) { this.stepContext.setException(e); throw new BatchContainerRuntimeException(e); } }
@Override public void beforeChunk(ChunkContext context) { try { delegate.beforeChunk(); } catch (Exception e) { throw new UncheckedTransactionException(e); } }
@Override public void afterChunk(ChunkContext context) { try { delegate.afterChunk(); } catch (Exception e) { throw new UncheckedTransactionException(e); } }
private void rollbackAfterRetryableException() throws Exception { doClose(); for (ChunkListener chunkProxy : chunkListeners) { try { chunkProxy.onError(currentChunkStatus.getRetryableException()); } catch (final Exception e1) { logger.log(Level.SEVERE, e1.getMessage(), e1); } } transactionManager.rollback(); stepContext.getMetric(MetricImpl.MetricType.ROLLBACK_COUNT).incValue(); }
@Override public void beforeChunk(ChunkContext context) { try { delegate.beforeChunk(); } catch (Exception e) { throw new UncheckedTransactionException(e); } }