diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj index 8a1beb8a896..2151561cb90 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2017 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. @@ -13,16 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.beans.factory.aspectj; /** * Generic-based dependency injection aspect. - *

- * This aspect allows users to implement efficient, type-safe dependency injection without - * the use of the @Configurable annotation. * - * The subaspect of this aspect doesn't need to include any AOP constructs. - * For example, here is a subaspect that configures the {@code PricingStrategyClient} objects. + *

This aspect allows users to implement efficient, type-safe dependency injection + * without the use of the {@code @Configurable} annotation. + * + *

The subaspect of this aspect doesn't need to include any AOP constructs. For + * example, here is a subaspect that configures the {@code PricingStrategyClient} objects. + * *

  * aspect PricingStrategyDependencyInjectionAspect
  *        extends GenericInterfaceDrivenDependencyInjectionAspect {
@@ -35,20 +37,23 @@ package org.springframework.beans.factory.aspectj;
  *     public void setPricingStrategy(PricingStrategy pricingStrategy) {
  *         this.pricingStrategy = pricingStrategy;
  *     }
- * }
- * 
+ * } + * * @author Ramnivas Laddad - * @since 3.0.0 + * @since 3.0 */ public abstract aspect GenericInterfaceDrivenDependencyInjectionAspect extends AbstractInterfaceDrivenDependencyInjectionAspect { - declare parents: I implements ConfigurableObject; + + declare parents: I implements ConfigurableObject; public pointcut inConfigurableBean() : within(I+); + @SuppressWarnings("unchecked") public final void configureBean(Object bean) { - configure((I)bean); + configure((I) bean); } // Unfortunately, erasure used with generics won't allow to use the same named method protected abstract void configure(I bean); + } diff --git a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj index 77da43176ab..cd3742f6e88 100644 --- a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj +++ b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj @@ -23,6 +23,7 @@ import org.aspectj.lang.annotation.SuppressAjWarnings; */ public aspect CodeStyleAspect { + @SuppressWarnings("unused") private String foo; pointcut somePC() : call(* someMethod()); diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java index 371c664d1ac..501d4cd50dd 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -16,22 +16,25 @@ package org.springframework.beans.factory.aspectj; -import org.junit.Assert; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; +import static org.junit.Assert.*; + /** * @author Chris Beams */ public class XmlBeanConfigurerTests { @Test - public void testInjection() { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "org/springframework/beans/factory/aspectj/beanConfigurerTests.xml"); - ShouldBeConfiguredBySpring myObject = new ShouldBeConfiguredBySpring(); - Assert.assertEquals("Rod", myObject.getName()); + public void injection() { + try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + "org/springframework/beans/factory/aspectj/beanConfigurerTests.xml")) { + + ShouldBeConfiguredBySpring myObject = new ShouldBeConfiguredBySpring(); + assertEquals("Rod", myObject.getName()); + } } } diff --git a/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java index 1baf04c2964..0f66aadcda8 100644 --- a/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -16,7 +16,6 @@ package org.springframework.context.annotation.aspectj; -import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.aspectj.ShouldBeConfiguredBySpring; @@ -24,6 +23,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; +import static org.junit.Assert.*; + /** * Tests that @EnableSpringConfigured properly registers an * {@link org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect}, @@ -35,10 +36,11 @@ import org.springframework.context.annotation.ImportResource; public class AnnotationBeanConfigurerTests { @Test - public void testInjection() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); - ShouldBeConfiguredBySpring myObject = new ShouldBeConfiguredBySpring(); - Assert.assertEquals("Rod", myObject.getName()); + public void injection() { + try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class)) { + ShouldBeConfiguredBySpring myObject = new ShouldBeConfiguredBySpring(); + assertEquals("Rod", myObject.getName()); + } } diff --git a/spring-core/src/main/java/org/springframework/core/codec/AbstractEncoder.java b/spring-core/src/main/java/org/springframework/core/codec/AbstractEncoder.java index 2aa053815ce..5313c3a3540 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/AbstractEncoder.java +++ b/spring-core/src/main/java/org/springframework/core/codec/AbstractEncoder.java @@ -18,7 +18,6 @@ package org.springframework.core.codec; import java.util.Arrays; import java.util.List; -import java.util.Map; import org.springframework.core.ResolvableType; import org.springframework.util.MimeType; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java index 57cc54f0818..ee663b101d6 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -1451,7 +1451,6 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { } @Override - @SuppressWarnings("rawtypes") public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // Invocation on ConnectionProxy interface coming in... diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java index 0f0df98cb1a..75528d351d5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -27,7 +27,6 @@ import org.springframework.core.MethodIntrospector; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.messaging.handler.annotation.MessageExceptionHandler; import org.springframework.messaging.handler.invocation.AbstractExceptionHandlerMethodResolver; -import org.springframework.util.ReflectionUtils.MethodFilter; /** * A sub-class of {@link AbstractExceptionHandlerMethodResolver} that looks for diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java index eba7a792f65..d18d94a8e40 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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. @@ -17,7 +17,6 @@ package org.springframework.messaging.simp.stomp; import java.nio.ByteBuffer; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java index 0a265907ebf..328b52c46e2 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -20,7 +20,6 @@ import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; import static org.springframework.messaging.simp.SimpMessageHeaderAccessor.*; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import org.junit.Before; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java index 0da28ee086c..c1e7d6f4bf5 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -20,8 +20,6 @@ import javax.persistence.EntityManager; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.jpa.HibernateEntityManager; -import org.hibernate.jpa.HibernateEntityManagerFactory; import org.junit.Test; import org.springframework.aop.framework.ProxyFactory; @@ -50,13 +48,13 @@ public class HibernateEntityManagerFactoryIntegrationTests extends AbstractConta @Test public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() { EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory; - assertTrue(emfi.getNativeEntityManagerFactory() instanceof HibernateEntityManagerFactory); + assertTrue(emfi.getNativeEntityManagerFactory() instanceof org.hibernate.jpa.HibernateEntityManagerFactory); assertTrue(emfi.getNativeEntityManagerFactory() instanceof SessionFactory); // as of Hibernate 5.2 } @Test public void testCanCastSharedEntityManagerProxyToHibernateEntityManager() { - assertTrue(sharedEntityManager instanceof HibernateEntityManager); + assertTrue(sharedEntityManager instanceof org.hibernate.jpa.HibernateEntityManager); assertTrue(((EntityManagerProxy) sharedEntityManager).getTargetEntityManager() instanceof Session); // as of Hibernate 5.2 } @@ -64,10 +62,10 @@ public class HibernateEntityManagerFactoryIntegrationTests extends AbstractConta public void testCanUnwrapAopProxy() { EntityManager em = entityManagerFactory.createEntityManager(); EntityManager proxy = ProxyFactory.getProxy(EntityManager.class, new SingletonTargetSource(em)); - assertTrue(em instanceof HibernateEntityManager); - assertFalse(proxy instanceof HibernateEntityManager); - assertTrue(proxy.unwrap(HibernateEntityManager.class) instanceof HibernateEntityManager); - assertSame(em, proxy.unwrap(HibernateEntityManager.class)); + assertTrue(em instanceof org.hibernate.jpa.HibernateEntityManager); + assertFalse(proxy instanceof org.hibernate.jpa.HibernateEntityManager); + assertTrue(proxy.unwrap(org.hibernate.jpa.HibernateEntityManager.class) != null); + assertSame(em, proxy.unwrap(org.hibernate.jpa.HibernateEntityManager.class)); assertSame(em.getDelegate(), proxy.getDelegate()); } diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 28537a96abd..88d9176ada3 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -544,7 +544,6 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi } } - @SuppressWarnings("deprecation") private Schema loadSchema(Resource[] resources, String schemaLanguage) throws IOException, SAXException { if (logger.isDebugEnabled()) { logger.debug("Setting validation schema to " + @@ -805,7 +804,6 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi } } - @SuppressWarnings("deprecation") private Source processSource(Source source) { if (StaxUtils.isStaxSource(source) || source instanceof DOMSource) { return source; diff --git a/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java index 6c2d43982a2..40f18637df3 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -183,7 +183,6 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller { * @return the XMLReader * @throws SAXException if thrown by JAXP methods */ - @SuppressWarnings("deprecation") protected XMLReader createXmlReader() throws SAXException { XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd()); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java index 98c86013eee..8229321833e 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -32,7 +32,6 @@ import static org.junit.Assert.*; * @author Jakub Narloch * @author Sam Brannen */ -@SuppressWarnings("deprecation") public class OxmNamespaceHandlerTests { private final ApplicationContext applicationContext = diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index 70b3a1f8ec6..4db96d3b397 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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,9 +34,6 @@ import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.Locator; -import org.xmlunit.diff.Comparison; -import org.xmlunit.diff.ComparisonResult; -import org.xmlunit.diff.ComparisonType; import org.xmlunit.diff.DifferenceEvaluator; import javax.activation.DataHandler; @@ -55,9 +52,7 @@ import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; -import java.util.Arrays; import java.util.Collections; -import java.util.EnumSet; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java index 5975e58afcf..55270f32a2b 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -56,6 +56,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -69,6 +70,7 @@ import static org.xmlunit.matchers.CompareMatcher.isSimilarTo; /** * @author Arjen Poutsma + * @author Sam Brannen */ public class XStreamMarshallerTests { @@ -350,25 +352,20 @@ public class XStreamMarshallerTests { private static void assertXpathExists(String xPathExpression, String inXMLString){ Source source = Input.fromString(inXMLString).build(); Iterable nodes = new JAXPXPathEngine().selectNodes(xPathExpression, source); - assertNotNull(nodes); - int count = 0; - - for (Node node : nodes){ - count++; - } - assertTrue("Expecting to find matches for Xpath " + xPathExpression, count > 0); + assertTrue("Expecting to find matches for Xpath " + xPathExpression, count(nodes) > 0); } - private static void assertXpathNotExists(String xPathExpression, String inXMLString){ Source source = Input.fromString(inXMLString).build(); Iterable nodes = new JAXPXPathEngine().selectNodes(xPathExpression, source); - assertNotNull(nodes); - int count = 0; - - for (Node node : nodes){ - count++; - } - assertEquals("Should be zero matches for Xpath " + xPathExpression, 0, count); + assertEquals("Should be zero matches for Xpath " + xPathExpression, 0, count(nodes)); } + + private static int count(Iterable nodes) { + assertNotNull(nodes); + AtomicInteger count = new AtomicInteger(); + nodes.forEach(n -> count.incrementAndGet()); + return count.get(); + } + } diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index a9e4728b19a..3473caed1b7 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -130,68 +130,69 @@ public class SimpleTransactionScopeTests { @Test public void getWithTransactionManager() throws Exception { - GenericApplicationContext context = new GenericApplicationContext(); - context.getBeanFactory().registerScope("tx", new SimpleTransactionScope()); + try (GenericApplicationContext context = new GenericApplicationContext()) { + context.getBeanFactory().registerScope("tx", new SimpleTransactionScope()); - GenericBeanDefinition bd1 = new GenericBeanDefinition(); - bd1.setBeanClass(TestBean.class); - bd1.setScope("tx"); - bd1.setPrimary(true); - context.registerBeanDefinition("txScopedObject1", bd1); + GenericBeanDefinition bd1 = new GenericBeanDefinition(); + bd1.setBeanClass(TestBean.class); + bd1.setScope("tx"); + bd1.setPrimary(true); + context.registerBeanDefinition("txScopedObject1", bd1); - GenericBeanDefinition bd2 = new GenericBeanDefinition(); - bd2.setBeanClass(DerivedTestBean.class); - bd2.setScope("tx"); - context.registerBeanDefinition("txScopedObject2", bd2); + GenericBeanDefinition bd2 = new GenericBeanDefinition(); + bd2.setBeanClass(DerivedTestBean.class); + bd2.setScope("tx"); + context.registerBeanDefinition("txScopedObject2", bd2); - context.refresh(); + context.refresh(); - CallCountingTransactionManager tm = new CallCountingTransactionManager(); - TransactionTemplate tt = new TransactionTemplate(tm); - Set finallyDestroy = new HashSet<>(); + CallCountingTransactionManager tm = new CallCountingTransactionManager(); + TransactionTemplate tt = new TransactionTemplate(tm); + Set finallyDestroy = new HashSet<>(); - tt.execute(status -> { - TestBean bean1 = context.getBean(TestBean.class); - assertSame(bean1, context.getBean(TestBean.class)); + tt.execute(status -> { + TestBean bean1 = context.getBean(TestBean.class); + assertSame(bean1, context.getBean(TestBean.class)); - DerivedTestBean bean2 = context.getBean(DerivedTestBean.class); - assertSame(bean2, context.getBean(DerivedTestBean.class)); - context.getBeanFactory().destroyScopedBean("txScopedObject2"); - assertFalse(TransactionSynchronizationManager.hasResource("txScopedObject2")); - assertTrue(bean2.wasDestroyed()); + DerivedTestBean bean2 = context.getBean(DerivedTestBean.class); + assertSame(bean2, context.getBean(DerivedTestBean.class)); + context.getBeanFactory().destroyScopedBean("txScopedObject2"); + assertFalse(TransactionSynchronizationManager.hasResource("txScopedObject2")); + assertTrue(bean2.wasDestroyed()); - DerivedTestBean bean2a = context.getBean(DerivedTestBean.class); - assertSame(bean2a, context.getBean(DerivedTestBean.class)); - assertNotSame(bean2, bean2a); - context.getBeanFactory().getRegisteredScope("tx").remove("txScopedObject2"); - assertFalse(TransactionSynchronizationManager.hasResource("txScopedObject2")); - assertFalse(bean2a.wasDestroyed()); + DerivedTestBean bean2a = context.getBean(DerivedTestBean.class); + assertSame(bean2a, context.getBean(DerivedTestBean.class)); + assertNotSame(bean2, bean2a); + context.getBeanFactory().getRegisteredScope("tx").remove("txScopedObject2"); + assertFalse(TransactionSynchronizationManager.hasResource("txScopedObject2")); + assertFalse(bean2a.wasDestroyed()); - DerivedTestBean bean2b = context.getBean(DerivedTestBean.class); - finallyDestroy.add(bean2b); - assertSame(bean2b, context.getBean(DerivedTestBean.class)); - assertNotSame(bean2, bean2b); - assertNotSame(bean2a, bean2b); + DerivedTestBean bean2b = context.getBean(DerivedTestBean.class); + finallyDestroy.add(bean2b); + assertSame(bean2b, context.getBean(DerivedTestBean.class)); + assertNotSame(bean2, bean2b); + assertNotSame(bean2a, bean2b); + + Set immediatelyDestroy = new HashSet<>(); + TransactionTemplate tt2 = new TransactionTemplate(tm); + tt2.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED); + tt2.execute(status2 -> { + DerivedTestBean bean2c = context.getBean(DerivedTestBean.class); + immediatelyDestroy.add(bean2c); + assertSame(bean2c, context.getBean(DerivedTestBean.class)); + assertNotSame(bean2, bean2c); + assertNotSame(bean2a, bean2c); + assertNotSame(bean2b, bean2c); + return null; + }); + assertTrue(immediatelyDestroy.iterator().next().wasDestroyed()); + assertFalse(bean2b.wasDestroyed()); - Set immediatelyDestroy = new HashSet<>(); - TransactionTemplate tt2 = new TransactionTemplate(tm); - tt2.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED); - tt2.execute(status2 -> { - DerivedTestBean bean2c = context.getBean(DerivedTestBean.class); - immediatelyDestroy.add(bean2c); - assertSame(bean2c, context.getBean(DerivedTestBean.class)); - assertNotSame(bean2, bean2c); - assertNotSame(bean2a, bean2c); - assertNotSame(bean2b, bean2c); return null; }); - assertTrue(immediatelyDestroy.iterator().next().wasDestroyed()); - assertFalse(bean2b.wasDestroyed()); - return null; - }); - - assertTrue(finallyDestroy.iterator().next().wasDestroyed()); + assertTrue(finallyDestroy.iterator().next().wasDestroyed()); + } } } diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java index ccb636379ab..19ac6e4cb2d 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/function/BodyExtractors.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -16,7 +16,6 @@ package org.springframework.web.reactive.function; -import java.util.Collections; import java.util.List; import java.util.function.Function; import java.util.function.Supplier; diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ContentVersionStrategy.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ContentVersionStrategy.java index ca6106b9ee2..341fc673345 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ContentVersionStrategy.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ContentVersionStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -20,7 +20,6 @@ import java.io.IOException; import org.springframework.core.io.Resource; import org.springframework.util.DigestUtils; -import org.springframework.util.FileCopyUtils; /** * A {@code VersionStrategy} that calculates an Hex MD5 hashes from the content diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceTransformerChain.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceTransformerChain.java index 423d4c6fd9e..1d2fd737ccd 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceTransformerChain.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/resource/ResourceTransformerChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -16,8 +16,6 @@ package org.springframework.web.reactive.resource; -import java.io.IOException; - import reactor.core.publisher.Mono; import org.springframework.core.io.Resource; diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java index 6ac46ad8b71..472944ee22e 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -26,7 +26,6 @@ import org.springframework.beans.BeanUtils; import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapter; import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.core.ReactiveTypeDescriptor; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.Assert; diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.java index a9ae9f86125..9461446cdaf 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -21,7 +21,6 @@ import java.util.Optional; import org.springframework.core.MethodParameter; import org.springframework.util.Assert; -import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestParam; diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/WebSocketHandler.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/WebSocketHandler.java index 85c7448bbfa..20f24371d1a 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/WebSocketHandler.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/socket/WebSocketHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -15,9 +15,6 @@ */ package org.springframework.web.reactive.socket; -import java.util.Collections; -import java.util.List; - import reactor.core.publisher.Mono; /** diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java index b388d6714d9..e92644b5bab 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -28,7 +28,6 @@ import reactor.test.StepVerifier; import org.springframework.cache.concurrent.ConcurrentMapCache; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.support.DataBufferTestUtils; import org.springframework.http.CacheControl; import org.springframework.http.HttpMethod; diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java index f46b722e636..30baf2f77b7 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -29,7 +29,6 @@ import org.junit.Test; import reactor.test.StepVerifier; import org.springframework.core.codec.CharSequenceEncoder; -import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.support.DataBufferTestUtils; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java index 8294964fc18..b7493f87ede 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpConnector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -24,7 +24,6 @@ import reactor.core.publisher.Mono; import reactor.ipc.netty.http.client.HttpClientOptions; import reactor.ipc.netty.options.ClientOptions; import reactor.ipc.netty.http.client.HttpClient; -import reactor.ipc.netty.http.client.HttpClientException; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/main/java/org/springframework/http/codec/ResourceRegionHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ResourceRegionHttpMessageWriter.java index 4b4a8c77473..4ccef76a951 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ResourceRegionHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ResourceRegionHttpMessageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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,6 @@ import org.springframework.core.io.support.ResourceRegion; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; import org.springframework.http.ZeroCopyHttpOutputMessage; -import org.springframework.util.ResourceUtils; /** * Implementation of {@link HttpMessageWriter} that can write diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java index 56c59c7124b..06480f1025c 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2JsonDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -23,7 +23,6 @@ import java.util.Map; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.type.TypeFactory; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java index 1fcab306384..a0c5425a578 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -24,15 +24,12 @@ import io.netty.handler.codec.http.HttpResponseStatus; import io.reactivex.netty.protocol.http.server.HttpServerRequest; import io.reactivex.netty.protocol.http.server.HttpServerResponse; import io.reactivex.netty.protocol.http.server.RequestHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; import rx.Observable; import rx.RxReactiveStreams; import org.springframework.core.io.buffer.NettyDataBufferFactory; -import org.springframework.util.Assert; /** * Adapt {@link HttpHandler} to the RxNetty {@link RequestHandler}. diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java index c51ccfa8acd..215bc82692f 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -19,7 +19,6 @@ package org.springframework.http.server.reactive; import java.net.InetSocketAddress; import java.net.URI; import java.net.URISyntaxException; -import java.util.HashMap; import io.netty.buffer.ByteBuf; import io.netty.handler.codec.http.cookie.Cookie; diff --git a/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java b/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java index 59623e9503d..9a41b4044e5 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java +++ b/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -16,7 +16,6 @@ package org.springframework.web.bind.support; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -25,8 +24,6 @@ import java.util.TreeMap; import reactor.core.publisher.Mono; import org.springframework.beans.MutablePropertyValues; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.multipart.MultipartFile; diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/TimeoutCallableProcessingInterceptor.java b/spring-web/src/main/java/org/springframework/web/context/request/async/TimeoutCallableProcessingInterceptor.java index c26e476bb9d..27dbe06d497 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/TimeoutCallableProcessingInterceptor.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/TimeoutCallableProcessingInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -17,9 +17,7 @@ package org.springframework.web.context.request.async; import java.util.concurrent.Callable; -import javax.servlet.http.HttpServletResponse; -import org.springframework.http.HttpStatus; import org.springframework.web.context.request.NativeWebRequest; /** diff --git a/spring-web/src/main/java/org/springframework/web/cors/reactive/DefaultCorsProcessor.java b/spring-web/src/main/java/org/springframework/web/cors/reactive/DefaultCorsProcessor.java index adfebe204a3..6232318eff7 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/reactive/DefaultCorsProcessor.java +++ b/spring-web/src/main/java/org/springframework/web/cors/reactive/DefaultCorsProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.util.CollectionUtils; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.WebUtils; /** * The default implementation of {@link CorsProcessor}, @@ -52,7 +51,6 @@ public class DefaultCorsProcessor implements CorsProcessor { @Override - @SuppressWarnings("resource") public boolean processRequest(CorsConfiguration config, ServerWebExchange exchange) { ServerHttpRequest request = exchange.getRequest(); diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java index c81f183ee0d..5b4fab2a3fb 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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. @@ -136,7 +136,7 @@ public abstract class AbstractHttpRequestFactoryTestCase extends AbstractMockWeb StreamUtils.copy(body, request.getBody()); } - ClientHttpResponse response = request.execute(); + request.execute(); FileCopyUtils.copy(body, request.getBody()); } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java index 15a663f65f6..abd7be32760 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -16,10 +16,6 @@ package org.springframework.http.server.reactive; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.isA; -import static org.mockito.Mockito.mock; - import java.io.IOException; import org.junit.Test; @@ -27,8 +23,12 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; + import org.springframework.core.io.buffer.DataBuffer; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.isA; +import static org.mockito.Mockito.mock; import static org.junit.Assert.assertTrue; /** @@ -40,8 +40,8 @@ import static org.junit.Assert.assertTrue; public class ListenerReadPublisherTests { @Test + @SuppressWarnings("unchecked") public void testReceiveTwoRequestCallsWhenOnSubscribe() { - @SuppressWarnings("unchecked") Subscriber subscriber = mock(Subscriber.class); doAnswer(new SubscriptionAnswer()).when(subscriber).onSubscribe(isA(Subscription.class)); @@ -84,4 +84,5 @@ public class ListenerReadPublisherTests { } } + } diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java index 3ab4d3734eb..28f1d71d3cf 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -35,6 +35,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.io.ClassPathResource; @@ -50,7 +52,6 @@ import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.client.Netty4ClientHttpRequestFactory; import org.springframework.http.client.OkHttp3ClientHttpRequestFactory; -import org.springframework.http.client.OkHttpClientHttpRequestFactory; import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.converter.json.MappingJacksonValue; import org.springframework.util.LinkedMultiValueMap; @@ -67,17 +68,18 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase private RestTemplate template; - @Parameterized.Parameter + @Parameter public ClientHttpRequestFactory clientHttpRequestFactory; - @Parameterized.Parameters + @Parameters + @SuppressWarnings("deprecation") public static Iterable data() { return Arrays.asList( new SimpleClientHttpRequestFactory(), new HttpComponentsClientHttpRequestFactory(), new Netty4ClientHttpRequestFactory(), new OkHttp3ClientHttpRequestFactory(), - new OkHttpClientHttpRequestFactory() + new org.springframework.http.client.OkHttpClientHttpRequestFactory() ); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 4d5c4c2473f..331af0ebec1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -74,7 +74,6 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodReturnValueHandler; import org.springframework.web.servlet.HandlerAdapter; import org.springframework.web.servlet.HandlerExceptionResolver; -import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.handler.AbstractHandlerMapping; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java index d87ac50c8c6..305012b21aa 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -28,8 +28,6 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.http.InvalidMediaTypeException; import org.springframework.http.MediaType; import org.springframework.util.StringUtils; -import org.springframework.web.HttpMediaTypeException; -import org.springframework.web.HttpMediaTypeNotSupportedException; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.cors.CorsUtils; import org.springframework.web.servlet.mvc.condition.HeadersRequestCondition.HeaderExpression; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 13bca3e7453..aa1f8976cb1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import javax.xml.transform.Source; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java index ce8e862f971..c8905b21f4c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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,6 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.http.CacheControl; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import org.springframework.web.HttpRequestMethodNotSupportedException; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java index e16295693b9..0cf770d4b61 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -44,7 +44,6 @@ import org.w3c.dom.Node; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContextException; import org.springframework.core.io.Resource; -import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java index 1e96199032a..80049799a13 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.mvc.method.annotation; import java.lang.reflect.Method; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.concurrent.CountDownLatch; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java index 8bcf940f872..85123f3559a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -16,7 +16,6 @@ package org.springframework.web.servlet.resource; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java index 2886edd282d..ee9d2a7fe9f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -19,11 +19,11 @@ package org.springframework.web.servlet.view.feed; import com.rometools.rome.feed.rss.Channel; import com.rometools.rome.feed.rss.Description; import com.rometools.rome.feed.rss.Item; -import org.junit.Before; + import org.junit.Test; + import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; -import org.xmlunit.matchers.CompareMatcher; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -41,12 +41,8 @@ import static org.xmlunit.matchers.CompareMatcher.isSimilarTo; */ public class RssFeedViewTests { - private AbstractRssFeedView view; + private final AbstractRssFeedView view = new MyRssFeedView(); - @Before - public void createView() throws Exception { - view = new MyRssFeedView(); - } @Test public void render() throws Exception { @@ -70,7 +66,7 @@ public class RssFeedViewTests { private static class MyRssFeedView extends AbstractRssFeedView { @Override - protected void buildFeedMetadata(Map model, Channel channel, HttpServletRequest request) { + protected void buildFeedMetadata(Map model, Channel channel, HttpServletRequest request) { channel.setTitle("Test Feed"); channel.setDescription("Test feed description"); channel.setLink("http://example.com"); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java index 94b81e60504..015d3055592 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -646,7 +646,6 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { private final List factories; - @SuppressWarnings("unused") private DecoratingFactoryBean(WebSocketHandler handler, List factories) { this.handler = handler; this.factories = factories; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java index 9988d51d45d..b8c048e0440 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/EventSourceTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -27,7 +27,6 @@ import org.springframework.web.socket.sockjs.frame.SockJsFrameFormat; import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig; import org.springframework.web.socket.sockjs.transport.SockJsSession; import org.springframework.web.socket.sockjs.transport.TransportType; -import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession; import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession; /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java index 7a96a66cff2..7f00fddb796 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/HtmlFileTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -36,7 +36,6 @@ import org.springframework.web.socket.sockjs.transport.SockJsSession; import org.springframework.web.socket.sockjs.transport.TransportHandler; import org.springframework.web.socket.sockjs.transport.TransportType; import org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession; -import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession; import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession; import org.springframework.web.util.JavaScriptUtils; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java index e635f17a250..4114e2170c7 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrPollingTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -27,7 +27,6 @@ import org.springframework.web.socket.sockjs.frame.SockJsFrameFormat; import org.springframework.web.socket.sockjs.transport.SockJsSession; import org.springframework.web.socket.sockjs.transport.TransportHandler; import org.springframework.web.socket.sockjs.transport.TransportType; -import org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession; import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession; /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java index a29557c0705..f0ceaf9c377 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/XhrStreamingTransportHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -28,7 +28,6 @@ import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig; import org.springframework.web.socket.sockjs.transport.SockJsSession; import org.springframework.web.socket.sockjs.transport.TransportHandler; import org.springframework.web.socket.sockjs.transport.TransportType; -import org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession; import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession; /** diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java index 94b157f69cc..da7e4a8bb54 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java @@ -545,9 +545,9 @@ public class StompSubProtocolHandlerTests { private static class TestMessageHandler implements MessageHandler { - private final List messages = new ArrayList<>(); + private final List> messages = new ArrayList<>(); - public List getMessages() { + public List> getMessages() { return this.messages; } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java index 601c0589606..f110662f355 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java @@ -100,7 +100,6 @@ public class WebSocketStompClientTests { } @Test - @SuppressWarnings("unchecked") public void webSocketConnectionEstablished() throws Exception { connect().afterConnectionEstablished(this.webSocketSession); verify(this.stompSession).afterConnected(notNull()); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java index 7565c178948..6767120e965 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java @@ -147,7 +147,6 @@ public class SockJsServiceTests extends AbstractHttpRequestTests { } @Test // SPR-11919 - @SuppressWarnings("unchecked") public void handleInfoGetWildflyNPE() throws Exception { HttpServletResponse mockResponse = mock(HttpServletResponse.class); ServletOutputStream ous = mock(ServletOutputStream.class);