diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/TransactionValidException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ReadFailureException.java similarity index 66% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/TransactionValidException.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ReadFailureException.java index 12df250c7..06cdc1a51 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/TransactionValidException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ReadFailureException.java @@ -17,21 +17,24 @@ package org.springframework.batch.io.exception; /** - * This exception indicates an error which does not require the transaction to - * be rolled back (for example when an invalid record is skipped). + * This exception indicates an error encountered while reading. It should generally + * be thrown by classes that implement the {@link ItemReader} interface. + * + * @author Lucas Ward */ -public class TransactionValidException extends BatchCriticalException { +public class ReadFailureException extends BatchCriticalException { + private static final long serialVersionUID = 4113323182216735223L; - public TransactionValidException(String msg, Throwable ex) { + public ReadFailureException(String msg, Throwable ex) { super(msg, ex); } - public TransactionValidException(String msg) { + public ReadFailureException(String msg) { super(msg); } - public TransactionValidException(Throwable nested) { + public ReadFailureException(Throwable nested) { super(nested); } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ValidationException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ValidationException.java index dbc252d8a..dc8b2fd77 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ValidationException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/ValidationException.java @@ -20,7 +20,7 @@ package org.springframework.batch.io.exception; /** * This exception should be thrown when there are validation errors. */ -public class ValidationException extends TransactionValidException { +public class ValidationException extends ReadFailureException { private static final long serialVersionUID = 7926495144451758088L; public ValidationException(String message) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/TransactionInvalidException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/WriteFailureException.java similarity index 66% rename from spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/TransactionInvalidException.java rename to spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/WriteFailureException.java index 7abf8af28..f31fdf216 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/TransactionInvalidException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/exception/WriteFailureException.java @@ -17,20 +17,24 @@ package org.springframework.batch.io.exception; /** - * Throwing this exception causes transaction rollback. + * Exception thrown after encountering an error during a write. It should + * generally be thrown by classes that implement the {@link ItemWriter} + * interface. + * + * @author Lucas Ward */ -public class TransactionInvalidException extends BatchCriticalException { +public class WriteFailureException extends BatchCriticalException { private static final long serialVersionUID = -1933213086873834098L; - public TransactionInvalidException(String msg, Throwable ex) { + public WriteFailureException(String msg, Throwable ex) { super(msg, ex); } - public TransactionInvalidException(String msg) { + public WriteFailureException(String msg) { super(msg); } - public TransactionInvalidException(Throwable nested) { + public WriteFailureException(Throwable nested) { super(nested); } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java index eda1dd406..fc68a93ee 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/StreamManager.java @@ -21,7 +21,7 @@ import org.springframework.batch.item.exception.StreamException; import org.springframework.transaction.TransactionStatus; /** - * Generalised stream management broadcast strategy. Clients register + * Generalized stream management broadcast strategy. Clients register * {@link ItemStream} instances under a well-known key, and then when they ask * for {@link ItemStream} operations by that key, we call each one in turn that * is registered under the key. diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandler.java index 0868c4e34..f708e2583 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandler.java @@ -19,7 +19,7 @@ package org.springframework.batch.repeat.exception.handler; import java.util.HashMap; import org.springframework.batch.common.ExceptionClassifierSupport; -import org.springframework.batch.io.exception.TransactionInvalidException; +import org.springframework.batch.io.exception.WriteFailureException; import org.springframework.batch.repeat.RepeatContext; /** @@ -33,13 +33,13 @@ public class SimpleLimitExceptionHandler implements ExceptionHandler { /** * Name of exception classifier key for the - * {@link TransactionInvalidException}. + * {@link WriteFailureException}. */ private static final String TX_INVALID = "TX_INVALID"; private RethrowOnThresholdExceptionHandler delegate = new RethrowOnThresholdExceptionHandler(); - private Class type = TransactionInvalidException.class; + private Class type = WriteFailureException.class; /** * Flag to indicate the the exception counters should be shared between @@ -102,7 +102,7 @@ public class SimpleLimitExceptionHandler implements ExceptionHandler { /** * Setter for the Throwable type that this handler counts. Defaults to - * {@link TransactionInvalidException}. + * {@link WriteFailureException}. * * @param type */ diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionInvalidExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionInvalidExceptionTests.java index ca01b21ad..116b82347 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionInvalidExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionInvalidExceptionTests.java @@ -20,15 +20,15 @@ package org.springframework.batch.io.exception; public class TransactionInvalidExceptionTests extends AbstractExceptionTests { public Exception getException(String msg) throws Exception { - return new TransactionInvalidException(msg); + return new WriteFailureException(msg); } public Exception getException(Throwable t) throws Exception { - return new TransactionInvalidException(t); + return new WriteFailureException(t); } public Exception getException(String msg, Throwable t) throws Exception { - return new TransactionInvalidException(msg, t); + return new WriteFailureException(msg, t); } public void testNothing() throws Exception { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionValidExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionValidExceptionTests.java index ae8e70d0d..6e855a36e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionValidExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/exception/TransactionValidExceptionTests.java @@ -20,15 +20,15 @@ package org.springframework.batch.io.exception; public class TransactionValidExceptionTests extends AbstractExceptionTests { public Exception getException(String msg) throws Exception { - return new TransactionValidException(msg); + return new ReadFailureException(msg); } public Exception getException(Throwable t) throws Exception { - return new TransactionValidException(t); + return new ReadFailureException(t); } public Exception getException(String msg, Throwable t) throws Exception { - return new TransactionValidException(msg, t); + return new ReadFailureException(msg, t); } public void testNothing() throws Exception { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandlerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandlerTests.java index 577af9623..d75d3d089 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandlerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/handler/SimpleLimitExceptionHandlerTests.java @@ -22,7 +22,7 @@ import java.util.List; import junit.framework.TestCase; -import org.springframework.batch.io.exception.TransactionInvalidException; +import org.springframework.batch.io.exception.WriteFailureException; import org.springframework.batch.repeat.context.RepeatContextSupport; /** @@ -161,7 +161,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase { List throwables = new ArrayList() { { for (int i = 0; i < (EXCEPTION_LIMIT); i++) { - add(new TransactionInvalidException("below exception limit")); + add(new WriteFailureException("below exception limit")); } } }; @@ -195,13 +195,13 @@ public class SimpleLimitExceptionHandlerTests extends TestCase { List throwables = new ArrayList() { { for (int i = 0; i < (EXCEPTION_LIMIT); i++) { - add(new TransactionInvalidException("below exception limit")); + add(new WriteFailureException("below exception limit")); } } }; throwables - .add(new TransactionInvalidException("above exception limit")); + .add(new WriteFailureException("above exception limit")); RepeatContextSupport context = new RepeatContextSupport(null); @@ -213,7 +213,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase { assertTrue("exceptions up to limit are swallowed", true); } - } catch (TransactionInvalidException expected) { + } catch (WriteFailureException expected) { assertEquals("above exception limit", expected.getMessage()); }