BATCH-413: Added a more specific exception type for when an item reader doesn't find any work.

This commit is contained in:
lucasward
2008-03-04 19:32:49 +00:00
parent 6e5e60af64
commit a7fe4db96e
3 changed files with 35 additions and 5 deletions

View File

@@ -21,8 +21,8 @@ import java.util.List;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.exception.NoWorkFoundException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.util.Assert;
/**
@@ -141,7 +141,7 @@ public class DrivingQueryItemReader implements ItemReader, InitializingBean,
+ ", call close() first.");
keys = keyGenerator.retrieveKeys(executionContext);
if(keys == null || keys.size() == 0){
throw new DataRetrievalFailureException("KeyGenerator must return at least 1 key");
throw new NoWorkFoundException("KeyGenerator must return at least 1 key");
}
keysIterator = keys.listIterator();
initialized = true;

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2006-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.item.exception;
/**
* Exception indicating that an {@link ItemReader} found
* no work to process while initializing.
*
* @author Lucas Ward
*
*/
public class NoWorkFoundException extends StreamException {
public NoWorkFoundException(String msg) {
super(msg);
}
}