/** * Surrounds the read call with listener callbacks. * @return the item or {@code null} if the data source is exhausted * @throws Exception is thrown if error occurs during read. */ @Nullable protected final I doRead() throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } return item; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); } listener.onReadError(e); throw e; } }
/** * Implements reading as well as any related listener calls required. * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @return an item * @throws Exception thrown if error occurs during reading or listener calls. */ protected final I doProvide(final StepContribution contribution, final Chunk<I> chunk) throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } else { chunk.setEnd(); } return item; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); } listener.onReadError(e); throw e; } }
/** * Test method for * {@link org.springframework.batch.core.listener.MulticasterBatchListener#onReadError(java.lang.Exception)} * . */ @Test public void testOnReadError() { multicast.onReadError(new RuntimeException("foo")); assertEquals(1, count); }
/** * Test method for * {@link org.springframework.batch.core.listener.MulticasterBatchListener#onReadError(java.lang.Exception)} * . */ @Test public void testOnReadErrorFails() { error = true; try { multicast.onReadError(new RuntimeException("foo")); fail("Expected StepListenerFailedException"); } catch (StepListenerFailedException e) { // expected String message = e.getCause().getMessage(); assertEquals("Wrong message: " + message, "listener error", message); } assertEquals(1, count); }
/** * Surrounds the read call with listener callbacks. * @return the item or {@code null} if the data source is exhausted * @throws Exception is thrown if error occurs during read. */ @Nullable protected final I doRead() throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } return item; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); } listener.onReadError(e); throw e; } }
/** * Surrounds the read call with listener callbacks. * @return item * @throws Exception */ protected final I doRead() throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } return item; } catch (Exception e) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); listener.onReadError(e); throw e; } }
/** * Surrounds the read call with listener callbacks. * @return the item or {@code null} if the data source is exhausted * @throws Exception is thrown if error occurs during read. */ @Nullable protected final I doRead() throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } return item; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); } listener.onReadError(e); throw e; } }
/** * Implements reading as well as any related listener calls required. * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @return an item * @throws Exception */ protected final I doProvide(final StepContribution contribution, final Chunk<I> chunk) throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } else { chunk.setEnd(); } return item; } catch (Exception e) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); listener.onReadError(e); throw e; } }
/** * Implements reading as well as any related listener calls required. * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @return an item * @throws Exception thrown if error occurs during reading or listener calls. */ protected final I doProvide(final StepContribution contribution, final Chunk<I> chunk) throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } else { chunk.setEnd(); } return item; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); } listener.onReadError(e); throw e; } }
/** * Implements reading as well as any related listener calls required. * * @param contribution a {@link StepContribution} * @param chunk a {@link Chunk} * @return an item * @throws Exception thrown if error occurs during reading or listener calls. */ protected final I doProvide(final StepContribution contribution, final Chunk<I> chunk) throws Exception { try { listener.beforeRead(); I item = itemReader.read(); if(item != null) { listener.afterRead(item); } else { chunk.setEnd(); } return item; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage() + " : " + e.getClass().getName()); } listener.onReadError(e); throw e; } }
/** * Surrounds the read call with listener callbacks. * @return item * @throws Exception */ protected final I doRead() throws Exception { try { listener.beforeRead(); I item = itemReader.read(); listener.afterRead(item); return item; } catch (Exception e) { listener.onReadError(e); throw e; } }