eliminated all compiler warnings throughout all projects

updated pom to emit compiler warnings so that any new ones become obvious
added serialVersionUID to classes that could reasonably need to be serialized (GenericMessage, MessageHeaders, etc)
@SuppressWarnings("serial") on all others
@SuppressWarnings("unused") on private static classes used as spring beans for testing (their methods never get called from java)
eliminated all redundant casting
introducted generics metadata where raw types were still being used
changed public API on several FactoryBeans (by adding <Type> information to 'implements FactoryBean' clause)
This commit is contained in:
Chris Beams
2010-05-25 23:18:25 +00:00
parent 8599343832
commit e5219dfe8f
69 changed files with 291 additions and 277 deletions

View File

@@ -180,7 +180,7 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
if (resultFile != null) {
if (originalFileFromHeader == null && payload instanceof File) {
return MessageBuilder.withPayload(resultFile)
.setHeader(FileHeaders.ORIGINAL_FILE, (File) payload);
.setHeader(FileHeaders.ORIGINAL_FILE, payload);
}
}
return resultFile;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -30,7 +30,7 @@ import org.springframework.integration.file.PatternMatchingFileListFilter;
* @author Mark Fisher
* @since 1.0.3
*/
public class FileListFilterFactoryBean implements FactoryBean {
public class FileListFilterFactoryBean implements FactoryBean<FileListFilter> {
private volatile FileListFilter fileListFilter;
@@ -55,7 +55,7 @@ public class FileListFilterFactoryBean implements FactoryBean {
this.preventDuplicates = preventDuplicates;
}
public Object getObject() throws Exception {
public FileListFilter getObject() throws Exception {
if (this.fileListFilter == null) {
synchronized (this.monitor) {
this.intializeFileListFilter();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -33,7 +33,7 @@ import java.util.Comparator;
* @author Iwein Fuld
* @since 1.0.3
*/
public class FileReadingMessageSourceFactoryBean implements FactoryBean {
public class FileReadingMessageSourceFactoryBean implements FactoryBean<FileReadingMessageSource> {
private static Log logger = LogFactory.getLog(FileReadingMessageSourceFactoryBean.class);
@@ -92,7 +92,7 @@ public class FileReadingMessageSourceFactoryBean implements FactoryBean {
this.locker = locker;
}
public Object getObject() throws Exception {
public FileReadingMessageSource getObject() throws Exception {
if (this.source == null) {
initSource();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -34,7 +34,8 @@ import org.springframework.util.Assert;
* @author Mark Fisher
* @since 1.0.3
*/
public class FileWritingMessageHandlerFactoryBean implements FactoryBean, BeanFactoryAware, ResourceLoaderAware {
public class FileWritingMessageHandlerFactoryBean implements FactoryBean<FileWritingMessageHandler>,
BeanFactoryAware, ResourceLoaderAware {
private volatile FileWritingMessageHandler handler;
@@ -117,7 +118,7 @@ public class FileWritingMessageHandlerFactoryBean implements FactoryBean, BeanFa
this.order = order;
}
public Object getObject() throws Exception {
public FileWritingMessageHandler getObject() throws Exception {
if (this.handler == null) {
initHandler();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -45,7 +45,7 @@ public class FileListFilterFactoryBeanTests {
FileListFilterFactoryBean factory = new FileListFilterFactoryBean();
TestFilter testFilter = new TestFilter();
factory.setFilterReference(testFilter);
FileListFilter result = (FileListFilter) factory.getObject();
FileListFilter result = factory.getObject();
assertFalse(result instanceof CompositeFileListFilter);
assertSame(testFilter, result);
}
@@ -57,7 +57,7 @@ public class FileListFilterFactoryBeanTests {
TestFilter testFilter = new TestFilter();
factory.setFilterReference(testFilter);
factory.setPreventDuplicates(Boolean.TRUE);
FileListFilter result = (FileListFilter) factory.getObject();
FileListFilter result = factory.getObject();
assertTrue(result instanceof CompositeFileListFilter);
Collection filters = (Collection) new DirectFieldAccessor(result).getPropertyValue("fileFilters");
assertTrue(filters.iterator().next() instanceof AcceptOnceFileListFilter);
@@ -70,7 +70,7 @@ public class FileListFilterFactoryBeanTests {
TestFilter testFilter = new TestFilter();
factory.setFilterReference(testFilter);
factory.setPreventDuplicates(Boolean.FALSE);
FileListFilter result = (FileListFilter) factory.getObject();
FileListFilter result = factory.getObject();
assertFalse(result instanceof CompositeFileListFilter);
assertSame(testFilter, result);
}
@@ -80,7 +80,7 @@ public class FileListFilterFactoryBeanTests {
public void filenamePatternAndPreventDuplicatesNull() throws Exception {
FileListFilterFactoryBean factory = new FileListFilterFactoryBean();
factory.setFilenamePattern(Pattern.compile("foo"));
FileListFilter result = (FileListFilter) factory.getObject();
FileListFilter result = factory.getObject();
assertTrue(result instanceof CompositeFileListFilter);
Collection filters = (Collection) new DirectFieldAccessor(result).getPropertyValue("fileFilters");
Iterator<FileListFilter> iterator = filters.iterator();
@@ -94,7 +94,7 @@ public class FileListFilterFactoryBeanTests {
FileListFilterFactoryBean factory = new FileListFilterFactoryBean();
factory.setFilenamePattern(Pattern.compile("foo"));
factory.setPreventDuplicates(Boolean.TRUE);
FileListFilter result = (FileListFilter) factory.getObject();
FileListFilter result = factory.getObject();
assertTrue(result instanceof CompositeFileListFilter);
Collection filters = (Collection) new DirectFieldAccessor(result).getPropertyValue("fileFilters");
Iterator<FileListFilter> iterator = filters.iterator();
@@ -107,7 +107,7 @@ public class FileListFilterFactoryBeanTests {
FileListFilterFactoryBean factory = new FileListFilterFactoryBean();
factory.setFilenamePattern(Pattern.compile("foo"));
factory.setPreventDuplicates(Boolean.FALSE);
FileListFilter result = (FileListFilter) factory.getObject();
FileListFilter result = factory.getObject();
assertFalse(result instanceof CompositeFileListFilter);
assertTrue(result instanceof PatternMatchingFileListFilter);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -66,7 +66,7 @@ public class NioFileLockerTests {
testFile.createNewFile();
assertThat(filter1.filterFiles(workdir.listFiles()).get(0), is(testFile));
filter1.lock(testFile);
assertThat(filter2.filterFiles(workdir.listFiles()), is((List)new ArrayList<File>()));
assertThat(filter2.filterFiles(workdir.listFiles()), is((List<File>)new ArrayList<File>()));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -31,7 +31,6 @@ import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItem;
import static org.junit.matchers.JUnitMatchers.hasItems;
import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;
@@ -60,7 +59,8 @@ public class FileInboundChannelAdapterWithRecursiveDirectoryTests {
assertThat(files.receive(), hasPayload(file));
}
@Test(timeout = 2000)
@Test(timeout = 2000)
@SuppressWarnings("unchecked")
public void shouldReturnFilesMultipleLevels() throws IOException {
//when