diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java index eaad22e98..f77a2f0d2 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.batch.item.ItemStream; /** * @author Dave Syer - * + * @author Michael Minella */ public class MulticasterBatchListener implements StepExecutionListener, ChunkListener, ItemReadListener, ItemProcessListener, ItemWriteListener, SkipListener { @@ -57,7 +57,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch /** * Register each of the objects as listeners. Once registered, calls to the * {@link MulticasterBatchListener} broadcast to the individual listeners. - * + * * @param listeners listener objects of types known to the multicaster. */ public void setListeners(List listeners) { @@ -169,7 +169,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch } /** - * + * * @see org.springframework.batch.core.listener.CompositeChunkListener#afterChunk() */ public void afterChunk() { @@ -182,7 +182,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch } /** - * + * * @see org.springframework.batch.core.listener.CompositeChunkListener#beforeChunk() */ public void beforeChunk() { @@ -208,7 +208,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch } /** - * + * * @see org.springframework.batch.core.listener.CompositeItemReadListener#beforeRead() */ public void beforeRead() { @@ -229,12 +229,12 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch itemReadListener.onReadError(ex); } catch (RuntimeException e) { - throw new StepListenerFailedException("Error in onReadError.", ex, e); + throw new StepListenerFailedException("Error in onReadError.", e); } } /** - * + * * @see ItemWriteListener#afterWrite(List) */ public void afterWrite(List items) { @@ -269,7 +269,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch itemWriteListener.onWriteError(ex, items); } catch (RuntimeException e) { - throw new StepListenerFailedException("Error in onWriteError.", ex, e); + throw new StepListenerFailedException("Error in onWriteError.", e); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFailedException.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFailedException.java index a5b2ad053..0bd597f7e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFailedException.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFailedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,9 @@ package org.springframework.batch.core.listener; /** * Exception to indicate a problem in a step listener. - * + * * @author Dave Syer + * @author Michael Minella * */ public class StepListenerFailedException extends RuntimeException { @@ -31,14 +32,4 @@ public class StepListenerFailedException extends RuntimeException { public StepListenerFailedException(String message, Throwable t) { super(message, t); } - - /** - * @param message describes the error to the user - * @param ex the exception that was thrown by a listener - * @param e the exception that caused the skip - */ - public StepListenerFailedException(String message, Throwable ex, RuntimeException e) { - super(message + "\n" + e.getClass().getName() + ": " + e.getMessage(), ex); - } - } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java index 11f996a5e..decbd9c5b 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +32,9 @@ import org.springframework.batch.repeat.RepeatStatus; /** * Simple implementation of the ChunkProvider interface that does basic chunk * providing from an {@link ItemReader}. - * + * * @author Dave Syer + * @author Michael Minella * @see ChunkOrientedTasklet */ public class SimpleChunkProvider implements ChunkProvider { @@ -54,7 +55,7 @@ public class SimpleChunkProvider implements ChunkProvider { /** * Register some {@link StepListener}s with the handler. Each will get the * callbacks in the order specified at the correct stage. - * + * * @param listeners */ public void setListeners(List listeners) { @@ -65,7 +66,7 @@ public class SimpleChunkProvider implements ChunkProvider { /** * Register a listener for callbacks at the appropriate stages in a process. - * + * * @param listener a {@link StepListener} */ public void registerListener(StepListener listener) { @@ -94,6 +95,7 @@ public class SimpleChunkProvider implements ChunkProvider { return item; } catch (Exception e) { + logger.debug(e.getMessage() + " : " + e.getClass().getName()); listener.onReadError(e); throw e; } @@ -136,14 +138,14 @@ public class SimpleChunkProvider implements ChunkProvider { /** * Delegates to {@link #doRead()}. Subclasses can add additional behaviour * (e.g. exception handling). - * + * * @param contribution the current step execution contribution * @param chunk the current chunk * @return a new item for processing - * + * * @throws SkipOverflowException if specifically the chunk is accumulating * too much data (e.g. skips) and it wants to force a commit. - * + * * @throws Exception if there is a generic issue */ protected I read(StepContribution contribution, Chunk chunk) throws SkipOverflowException, Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java index 8bf4f7cc6..c02d9d108 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java @@ -28,7 +28,7 @@ import org.springframework.batch.core.StepExecution; /** * @author Dave Syer - * + * */ public class MulticasterBatchListenerTests { @@ -276,7 +276,7 @@ public class MulticasterBatchListenerTests { catch (StepListenerFailedException e) { // expected String message = e.getCause().getMessage(); - assertEquals("Wrong message: " + message, "foo", message); + assertEquals("Wrong message: " + message, "listener error", message); } assertEquals(1, count); } @@ -369,7 +369,7 @@ public class MulticasterBatchListenerTests { catch (StepListenerFailedException e) { // expected String message = e.getCause().getMessage(); - assertEquals("Wrong message: " + message, "foo", message); + assertEquals("Wrong message: " + message, "listener error", message); } assertEquals(1, count); } @@ -508,7 +508,7 @@ public class MulticasterBatchListenerTests { /** * @author Dave Syer - * + * */ private final class CountingStepListenerSupport extends StepListenerSupport { @Override @@ -522,7 +522,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#afterChunk * () @@ -538,7 +538,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#afterRead * (java.lang.Object) @@ -554,7 +554,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#afterStep * (org.springframework.batch.core.StepExecution) @@ -570,7 +570,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#beforeChunk * () @@ -586,7 +586,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#beforeRead * () @@ -602,7 +602,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#beforeStep * (org.springframework.batch.core.StepExecution) @@ -618,7 +618,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#afterWrite * (java.util.List) @@ -634,7 +634,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#beforeWrite * (java.util.List) @@ -650,7 +650,7 @@ public class MulticasterBatchListenerTests { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.listener.StepListenerSupport#onWriteError * (java.lang.Exception, java.util.List) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFailedExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFailedExceptionTests.java index a752ecbb3..785fcebd6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFailedExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFailedExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.junit.Test; /** * @author Dave Syer + * @author Michael Minella * */ public class StepListenerFailedExceptionTests { @@ -32,11 +33,4 @@ public class StepListenerFailedExceptionTests { Exception exception = new StepListenerFailedException("foo", new IllegalStateException("bar")); assertEquals("foo", exception.getMessage().substring(0, 3)); } - - @Test - public void testExceptionStringThrowableThrowable() throws Exception { - Exception exception = new StepListenerFailedException("foo", new IllegalStateException(), new RuntimeException("bar")); - assertEquals("foo", exception.getMessage().substring(0, 3)); - } - }