Fix [serial] compiler warnings

Fix serialization warnings by applying @SuppressWarnings("serial")
when appropriate.

In certain cases and for unknown reasons, a correctly-placed
@SuppressWarnings("serial") annotation will fix the warning at the
javac level (i.e. the Gradle command-line), but will produce an
"unnecessary @SuppressWarnings" warning within Eclipse. In these
cases, a private static final serialVersionUID field has been added
with the default value of 1L.
This commit is contained in:
Phillip Webb
2012-12-19 14:35:57 -08:00
committed by Chris Beams
parent 7f0aa5cfb2
commit b0986049a3
550 changed files with 705 additions and 36 deletions

View File

@@ -21,6 +21,7 @@ import org.springframework.core.enums.ShortCodedLabeledEnum;
/**
* @author Rob Harrop
*/
@SuppressWarnings("serial")
public class Colour extends ShortCodedLabeledEnum {
public static final Colour RED = new Colour(0, "RED");
@@ -32,4 +33,4 @@ public class Colour extends ShortCodedLabeledEnum {
super(code, label);
}
}
}

View File

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.ObjectFactory;
/**
* @author Juergen Hoeller
*/
@SuppressWarnings("serial")
public class SimpleMapScope implements Scope, Serializable {
private final Map map = new HashMap();

View File

@@ -62,6 +62,7 @@ import org.springframework.jdbc.datasource.DriverManagerDataSource;
*/
public class LocalSessionFactoryBeanTests extends TestCase {
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithDataSource() throws Exception {
final DriverManagerDataSource ds = new DriverManagerDataSource();
final List invocations = new ArrayList();
@@ -93,6 +94,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals("newSessionFactory", invocations.get(0));
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithCacheRegionFactory() throws Exception {
final RegionFactory regionFactory = new NoCachingRegionFactory(null);
final List invocations = new ArrayList();
@@ -124,6 +126,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals("newSessionFactory", invocations.get(0));
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithCacheProvider() throws Exception {
final CacheProvider cacheProvider = new NoCacheProvider();
final List invocations = new ArrayList();
@@ -156,6 +159,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals("newSessionFactory", invocations.get(0));
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithTransactionAwareDataSource() throws Exception {
final DriverManagerDataSource ds = new DriverManagerDataSource();
final List invocations = new ArrayList();
@@ -189,6 +193,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals("newSessionFactory", invocations.get(0));
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithDataSourceAndMappingResources() throws Exception {
final DriverManagerDataSource ds = new DriverManagerDataSource();
MockControl tmControl = MockControl.createControl(TransactionManager.class);
@@ -232,6 +237,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals("newSessionFactory", invocations.get(2));
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithDataSourceAndMappingJarLocations() throws Exception {
final DriverManagerDataSource ds = new DriverManagerDataSource();
final Set invocations = new HashSet();
@@ -263,6 +269,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertTrue(invocations.contains("newSessionFactory"));
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithDataSourceAndProperties() throws Exception {
final DriverManagerDataSource ds = new DriverManagerDataSource();
final Set invocations = new HashSet();
@@ -368,6 +375,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
factoryControl.verify();
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithEntityInterceptor() throws Exception {
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
protected Configuration newConfiguration() {
@@ -394,6 +402,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
}
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithNamingStrategy() throws Exception {
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
protected Configuration newConfiguration() {
@@ -417,6 +426,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
}
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithCacheStrategies() throws Exception {
final Properties registeredClassCache = new Properties();
final Properties registeredCollectionCache = new Properties();
@@ -452,6 +462,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals(collectionCache, registeredCollectionCache);
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithCacheStrategiesAndRegions() throws Exception {
final Properties registeredClassCache = new Properties();
final Properties registeredCollectionCache = new Properties();
@@ -486,6 +497,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals(collectionCache, registeredCollectionCache);
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithEventListeners() throws Exception {
final Map registeredListeners = new HashMap();
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
@@ -510,6 +522,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
assertEquals(listeners, registeredListeners);
}
@SuppressWarnings("serial")
public void testLocalSessionFactoryBeanWithEventListenerSet() throws Exception {
final Map registeredListeners = new HashMap();
LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
@@ -576,6 +589,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
}
@SuppressWarnings("serial")
public static class FilterTestLocalSessionFactoryBean extends LocalSessionFactoryBean {
public List registeredFilterDefinitions = new LinkedList();
@@ -605,6 +619,7 @@ public class LocalSessionFactoryBeanTests extends TestCase {
}
@SuppressWarnings("serial")
public static class DummyMergeEventListener implements MergeEventListener {
public void onMerge(MergeEvent event) throws HibernateException {

View File

@@ -67,6 +67,8 @@ public abstract class AbstractEntityManagerFactoryBeanTests extends TestCase {
protected static class DummyEntityManagerFactoryBean extends AbstractEntityManagerFactoryBean {
private static final long serialVersionUID = 1L;
private final EntityManagerFactory emf;
public DummyEntityManagerFactoryBean(EntityManagerFactory emf) {

View File

@@ -120,6 +120,7 @@ public class EntityManagerFactoryUtilsTests extends TestCase {
* Test method for
* 'org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessException(PersistenceException)'
*/
@SuppressWarnings("serial")
public void testConvertJpaPersistenceException() {
EntityNotFoundException entityNotFound = new EntityNotFoundException();
assertSame(JpaObjectRetrievalFailureException.class,

View File

@@ -705,6 +705,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
}
@SuppressWarnings("serial")
private static class MockPersistenceAnnotationBeanPostProcessor extends PersistenceAnnotationBeanPostProcessor {
@Override
@@ -762,6 +763,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
@Repository
@SuppressWarnings("serial")
public static class DefaultPublicPersistenceContextSetter implements Serializable {
private EntityManager em;
@@ -780,6 +782,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
}
@SuppressWarnings("serial")
public static class SpecificPublicPersistenceContextSetter extends DefaultPublicPersistenceContextSetter {
@PersistenceContext(unitName="unit2", type = PersistenceContextType.EXTENDED)
@@ -872,6 +875,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
}
@SuppressWarnings("serial")
private static class DummyInvocationHandler implements InvocationHandler, Serializable {
public static boolean closed;