Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed potential race on throwing job abort exception

  • Loading branch information...
commit 119ff84ff117ec36d5233a3067e08dd7e281bb64 1 parent 3a9ef95
Andrew Elmore authored
View
14 c24-spring-batch/src/main/java/biz/c24/io/spring/batch/reader/C24BatchItemReader.java
@@ -36,11 +36,11 @@
private boolean validate = false;
- private Thread parsingThread = null;
+ private volatile Thread parsingThread = null;
/**
* Store this separately to make sure we report a job abort once only
*/
- private Throwable abortJobException = null;
+ private volatile Throwable abortJobException = null;
private BlockingQueue<Object> queue = new ArrayBlockingQueue<Object>(128);
private ThreadLocal<ValidationManager> validator = new ThreadLocal<ValidationManager>();
@@ -138,10 +138,12 @@ public ComplexDataObject read() throws Exception, UnexpectedInputException,
if(cdo == null && abortJobException != null) {
synchronized(this) {
- Throwable ex = abortJobException;
- abortJobException = null;
- ParseException rethrow = ex instanceof ParseException? (ParseException)ex : new ParseException("Failure during parsing", ex);
- throw rethrow;
+ if(abortJobException != null) {
+ Throwable ex = abortJobException;
+ abortJobException = null;
+ ParseException rethrow = ex instanceof ParseException? (ParseException)ex : new ParseException("Failure during parsing", ex);
+ throw rethrow;
+ }
}
} else if(cdo != null && validate) {
try {
Please sign in to comment.
Something went wrong with that request. Please try again.