findbugs fixes
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -24,9 +24,9 @@ import org.springframework.xml.transform.StaxResult;
|
||||
*/
|
||||
public class MultiResourceItemWriterXmlTests extends AbstractMultiResourceItemWriterTests {
|
||||
|
||||
final private String xmlDocStart = "<root>";
|
||||
final static private String xmlDocStart = "<root>";
|
||||
|
||||
final private String xmlDocEnd = "</root>";
|
||||
final static private String xmlDocEnd = "</root>";
|
||||
|
||||
@Override
|
||||
@Before
|
||||
|
||||
@@ -72,7 +72,7 @@ public class AbstractDelegatorTests extends TestCase {
|
||||
final String FOO_NAME = "fooName";
|
||||
final int FOO_VALUE = 12345;
|
||||
|
||||
delegator.invokeDelegateMethodWithArguments(new Object[]{FOO_NAME, new Integer(FOO_VALUE)});
|
||||
delegator.invokeDelegateMethodWithArguments(new Object[]{FOO_NAME, Integer.valueOf(FOO_VALUE)});
|
||||
Foo foo = (Foo) fooService.getProcessedFooNameValuePairs().get(0);
|
||||
assertEquals(FOO_NAME, foo.getName());
|
||||
assertEquals(FOO_VALUE, foo.getValue());
|
||||
|
||||
@@ -30,8 +30,8 @@ public class ColumnMapExecutionContextRowMapperTests extends TestCase {
|
||||
mapper = new ColumnMapItemPreparedStatementSetter();
|
||||
|
||||
key = new LinkedHashMap<String, Object>(2);
|
||||
key.put("1", new Integer(1));
|
||||
key.put("2", new Integer(2));
|
||||
key.put("1", Integer.valueOf(1));
|
||||
key.put("2", Integer.valueOf(2));
|
||||
}
|
||||
|
||||
public void testCreateExecutionContextFromEmptyKeys() throws Exception {
|
||||
@@ -43,8 +43,8 @@ public class ColumnMapExecutionContextRowMapperTests extends TestCase {
|
||||
|
||||
public void testCreateSetter() throws Exception {
|
||||
|
||||
ps.setObject(1, new Integer(1));
|
||||
ps.setObject(2, new Integer(2));
|
||||
ps.setObject(1, Integer.valueOf(1));
|
||||
ps.setObject(2, Integer.valueOf(2));
|
||||
replay(ps);
|
||||
mapper.setValues(key, ps);
|
||||
verify(ps);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests {
|
||||
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
Long id = keys.get(i);
|
||||
assertEquals(new Long(i + 1), id);
|
||||
assertEquals(Long.valueOf(i + 1), id);
|
||||
}
|
||||
for (Long key : keys) {
|
||||
System.out.println(key);
|
||||
@@ -72,8 +72,8 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests {
|
||||
List<Long> keys = keyStrategy.retrieveKeys(executionContext);
|
||||
|
||||
assertEquals(2, keys.size());
|
||||
assertEquals(new Long(4), keys.get(0));
|
||||
assertEquals(new Long(5), keys.get(1));
|
||||
assertEquals(Long.valueOf(4), keys.get(0));
|
||||
assertEquals(Long.valueOf(5), keys.get(1));
|
||||
|
||||
for (Long key : keys) {
|
||||
System.out.println(key);
|
||||
|
||||
@@ -22,30 +22,35 @@ public class AbstractMultiResourceItemWriterTests {
|
||||
|
||||
protected ResourceSuffixCreator suffixCreator = new SimpleResourceSuffixCreator();
|
||||
|
||||
protected ResourceAwareItemWriterItemStream<String> delegate;
|
||||
protected ResourceAwareItemWriterItemStream<String> delegate;
|
||||
|
||||
protected ExecutionContext executionContext = new ExecutionContext();
|
||||
protected ExecutionContext executionContext = new ExecutionContext();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
file = File.createTempFile(MultiResourceItemWriterFlatFileTests.class.getSimpleName(), null);
|
||||
tested.setResource(new FileSystemResource(file));
|
||||
tested.setDelegate(delegate);
|
||||
tested.setResourceSuffixCreator(suffixCreator);
|
||||
tested.setItemCountLimitPerResource(2);
|
||||
tested.setSaveState(true);
|
||||
tested.open(executionContext);
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
file = File.createTempFile(MultiResourceItemWriterFlatFileTests.class.getSimpleName(), null);
|
||||
tested.setResource(new FileSystemResource(file));
|
||||
tested.setDelegate(delegate);
|
||||
tested.setResourceSuffixCreator(suffixCreator);
|
||||
tested.setItemCountLimitPerResource(2);
|
||||
tested.setSaveState(true);
|
||||
tested.open(executionContext);
|
||||
}
|
||||
|
||||
protected String readFile(File f) throws Exception {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(f));
|
||||
StringBuilder result = new StringBuilder();
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
try {
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
result.append(line);
|
||||
}
|
||||
result.append(line);
|
||||
}
|
||||
finally {
|
||||
reader.close();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public class FlatFileItemReaderTests {
|
||||
|
||||
reader.open(executionContext);
|
||||
|
||||
assertEquals("testLine1testLine2", reader.read().toString());
|
||||
assertEquals("testLine3testLine4", reader.read().toString());
|
||||
assertEquals("testLine1testLine2", reader.read());
|
||||
assertEquals("testLine3testLine4", reader.read());
|
||||
|
||||
reader.update(executionContext);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class FlatFileItemReaderTests {
|
||||
|
||||
reader.open(executionContext);
|
||||
|
||||
assertEquals("testLine5testLine6", reader.read().toString());
|
||||
assertEquals("testLine5testLine6", reader.read());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,8 +95,8 @@ public class FlatFileItemReaderTests {
|
||||
reader.open(executionContext);
|
||||
|
||||
// read remaining records
|
||||
assertEquals("testLine3", reader.read().toString());
|
||||
assertEquals("testLine4", reader.read().toString());
|
||||
assertEquals("testLine3", reader.read());
|
||||
assertEquals("testLine4", reader.read());
|
||||
|
||||
reader.update(executionContext);
|
||||
assertEquals(4, executionContext.getInt(ClassUtils.getShortName(FlatFileItemReader.class) + ".read.count"));
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SpringValidatorTests extends TestCase {
|
||||
*/
|
||||
public void testValidateUnsupportedType() {
|
||||
try {
|
||||
validator.validate(new Integer(1)); // only strings are supported
|
||||
validator.validate(Integer.valueOf(1)); // only strings are supported
|
||||
fail("must not validate unsupported classes");
|
||||
}
|
||||
catch (ValidationException expected) {
|
||||
|
||||
@@ -351,7 +351,7 @@ public class StaxEventItemReaderTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class NonExistentResource extends AbstractResource {
|
||||
private static class NonExistentResource extends AbstractResource {
|
||||
|
||||
public NonExistentResource() {
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ public class RepeatOperationsInterceptorTests extends TestCase {
|
||||
public Object service() throws Exception {
|
||||
count++;
|
||||
if (count <= maxService) {
|
||||
return new Integer(count);
|
||||
return Integer.valueOf(count);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class DummySleeper implements Sleeper {
|
||||
* @see org.springframework.batch.retry.backoff.Sleeper#sleep(long)
|
||||
*/
|
||||
public void sleep(long backOffPeriod) throws InterruptedException {
|
||||
this.backOffs.add(new Long(backOffPeriod));
|
||||
this.backOffs.add(Long.valueOf(backOffPeriod));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class StatefulRetryIntegrationTests {
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
private final class MockRetryCallback implements RetryCallback<String> {
|
||||
private static final class MockRetryCallback implements RetryCallback<String> {
|
||||
int attempts = 0;
|
||||
|
||||
public String doWithRetry(RetryContext context) throws Exception {
|
||||
|
||||
@@ -308,6 +308,9 @@ public class StatefulRecoveryRetryTests {
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof StringHolder)) {
|
||||
return false;
|
||||
}
|
||||
return string.equals(((StringHolder) obj).string);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user