findbugs fixes

This commit is contained in:
robokaso
2008-11-24 10:10:11 +00:00
parent d2c1d5b380
commit 55dd2d5b69
16 changed files with 63 additions and 47 deletions

View File

@@ -17,6 +17,8 @@ package org.springframework.batch.item.database.support;
import static org.springframework.batch.support.DatabaseType.*;
import java.util.Arrays;
import org.springframework.batch.support.DatabaseType;
import org.springframework.dao.InvalidDataAccessResourceUsageException;
@@ -65,7 +67,7 @@ public class SimpleDelegatingPagingQueryProvider extends AbstractSqlPagingQueryP
else {
throw new InvalidDataAccessResourceUsageException(type.name() +
" is not a supported database. The supported databases are " +
DatabaseType.values().toString());
Arrays.toString(DatabaseType.values()));
}
delegate.setSelectClause(this.getSelectClause());
delegate.setFromClause(this.getFromClause());

View File

@@ -18,6 +18,7 @@ package org.springframework.batch.repeat.exception;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,7 +44,9 @@ public class RethrowOnThresholdExceptionHandler implements ExceptionHandler {
protected final Log logger = LogFactory.getLog(RethrowOnThresholdExceptionHandler.class);
private Classifier<? super Throwable, IntegerHolder> exceptionClassifier = new Classifier<Throwable, IntegerHolder>() {
public RethrowOnThresholdExceptionHandler.IntegerHolder classify(Throwable classifiable) { return ZERO;}
public RethrowOnThresholdExceptionHandler.IntegerHolder classify(Throwable classifiable) {
return ZERO;
}
};
private boolean useParent = false;
@@ -75,8 +78,8 @@ public class RethrowOnThresholdExceptionHandler implements ExceptionHandler {
*/
public void setThresholds(Map<Class<? extends Throwable>, Integer> thresholds) {
Map<Class<? extends Throwable>, IntegerHolder> typeMap = new HashMap<Class<? extends Throwable>, IntegerHolder>();
for (Class<? extends Throwable> type : thresholds.keySet()) {
typeMap.put(type, new IntegerHolder(thresholds.get(type)));
for (Entry<Class<? extends Throwable>, Integer> entry : thresholds.entrySet()) {
typeMap.put(entry.getKey(), new IntegerHolder(entry.getValue()));
}
exceptionClassifier = new SubclassClassifier<Throwable, IntegerHolder>(typeMap, ZERO);
}
@@ -92,7 +95,7 @@ public class RethrowOnThresholdExceptionHandler implements ExceptionHandler {
public void handleException(RepeatContext context, Throwable throwable) throws Throwable {
IntegerHolder key = exceptionClassifier.classify(throwable);
RepeatContextCounter counter = getCounter(context, key);
counter.increment();
int count = counter.getCount();
@@ -123,7 +126,7 @@ public class RethrowOnThresholdExceptionHandler implements ExceptionHandler {
public IntegerHolder(int value) {
this.value = value;
}
/**
* Public getter for the value.
* @return the value
@@ -131,13 +134,15 @@ public class RethrowOnThresholdExceptionHandler implements ExceptionHandler {
public int getValue() {
return value;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return ObjectUtils.getIdentityHexString(this)+"."+value;
return ObjectUtils.getIdentityHexString(this) + "." + value;
}
}

View File

@@ -107,7 +107,7 @@ public class ExceptionClassifierRetryPolicy implements RetryPolicy {
((RetryContextSupport) context).registerThrowable(throwable);
}
private class ExceptionClassifierRetryContext extends RetryContextSupport implements RetryPolicy {
private static class ExceptionClassifierRetryContext extends RetryContextSupport implements RetryPolicy {
final private Classifier<Throwable, RetryPolicy> exceptionClassifier;

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.batch.support;
import java.io.Serializable;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
@@ -131,7 +132,7 @@ public class SubclassClassifier<T, C> implements Classifier<T, C> {
* @author Dave Syer
*
*/
private static class ClassComparator implements Comparator<Class<?>> {
private static class ClassComparator implements Comparator<Class<?>>, Serializable {
/**
* @return 1 if arg0 is assignable from arg1, -1 otherwise
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)