diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java index 008df78e64d..20f3106c624 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -198,8 +198,8 @@ public class AspectJExpressionPointcutTests { // not currently testable in a reliable fashion //assertDoesNotMatchStringClass(classFilter); - assertThat(methodMatcher.matches(setSomeNumber, TestBean.class, new Double(12))).as("Should match with setSomeNumber with Double input").isTrue(); - assertThat(methodMatcher.matches(setSomeNumber, TestBean.class, new Integer(11))).as("Should not match setSomeNumber with Integer input").isFalse(); + assertThat(methodMatcher.matches(setSomeNumber, TestBean.class, 12D)).as("Should match with setSomeNumber with Double input").isTrue(); + assertThat(methodMatcher.matches(setSomeNumber, TestBean.class, 11)).as("Should not match setSomeNumber with Integer input").isFalse(); assertThat(methodMatcher.matches(getAge, TestBean.class)).as("Should not match getAge").isFalse(); assertThat(methodMatcher.isRuntime()).as("Should be a runtime match").isTrue(); } @@ -224,10 +224,10 @@ public class AspectJExpressionPointcutTests { TestBean testBean = getAdvisedProxy(expression, interceptor); assertThat(interceptor.getCount()).as("Calls should be 0").isEqualTo(0); - testBean.setSomeNumber(new Double(30)); + testBean.setSomeNumber(30D); assertThat(interceptor.getCount()).as("Calls should be 1").isEqualTo(1); - testBean.setSomeNumber(new Integer(90)); + testBean.setSomeNumber(90); assertThat(interceptor.getCount()).as("Calls should be 1").isEqualTo(1); } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java index bac21dadf9f..7a6c7e93c7b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -91,9 +91,8 @@ public class TrickyAspectJPointcutExpressionTests { // Make sure the interface is loaded from the parent class loader loader.excludeClass(TestService.class.getName()); loader.excludeClass(TestException.class.getName()); - TestService other = (TestService) loader.loadClass(TestServiceImpl.class.getName()).newInstance(); + TestService other = (TestService) loader.loadClass(TestServiceImpl.class.getName()).getDeclaredConstructor().newInstance(); testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, other, "TestServiceImpl"); - } private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message) @@ -127,7 +126,6 @@ public class TrickyAspectJPointcutExpressionTests { public SimpleThrowawayClassLoader(ClassLoader parent) { super(parent); } - } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java index 30ac2adc43f..a00a27bb6de 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java @@ -83,6 +83,7 @@ public class AspectProxyFactoryTests { } @Test + @SuppressWarnings("unchecked") public void testSerializable() throws Exception { AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); proxyFactory.addAspect(LoggingAspectOnVarargs.class); @@ -114,11 +115,11 @@ public class AspectProxyFactoryTests { @Test public void testWithNonSingletonAspectInstance() throws Exception { AspectJProxyFactory pf = new AspectJProxyFactory(); - assertThatIllegalArgumentException().isThrownBy(() -> - pf.addAspect(new PerThisAspect())); + assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new PerThisAspect())); } @Test // SPR-13328 + @SuppressWarnings("unchecked") public void testProxiedVarargsWithEnumArray() throws Exception { AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); proxyFactory.addAspect(LoggingAspectOnVarargs.class); @@ -127,6 +128,7 @@ public class AspectProxyFactoryTests { } @Test // SPR-13328 + @SuppressWarnings("unchecked") public void testUnproxiedVarargsWithEnumArray() throws Exception { AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); proxyFactory.addAspect(LoggingAspectOnSetter.class); diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java index d5fcae4bd3c..b98acc38e94 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java @@ -136,7 +136,7 @@ public class CustomizableTraceInterceptorTests { given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[0])); given(methodInvocation.getThis()).willReturn(this); - given(methodInvocation.getArguments()).willReturn(new Object[]{"$ One \\$", new Long(2)}); + given(methodInvocation.getArguments()).willReturn(new Object[]{"$ One \\$", 2L}); given(methodInvocation.proceed()).willReturn("Hello!"); Log log = mock(Log.class); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java index bb9a000df3e..4ae12a9533a 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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 @@ public abstract class SqlParameterSourceUtils { * @see BeanPropertySqlParameterSource * @see NamedParameterJdbcTemplate#batchUpdate(String, SqlParameterSource[]) */ - @SuppressWarnings("unchecked") public static SqlParameterSource[] createBatch(Object... candidates) { return createBatch(Arrays.asList(candidates)); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java index 919e392d8dc..890bb3d99c6 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java @@ -71,10 +71,9 @@ import org.springframework.util.StringUtils; * {@link SocketAcceptor} adapter to register with the * {@link io.rsocket.core.RSocketServer}. * - *
For a client, possibly in the same process as a server, consider - * consider using the static factory method - * {@link #responder(RSocketStrategies, Object...)} to obtain a client - * responder to be registered via + *
For a client, possibly in the same process as a server, consider using the + * static factory method {@link #responder(RSocketStrategies, Object...)} to + * obtain a client responder to be registered via * {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketConnector * RSocketRequester.Builder}. * @@ -500,8 +499,8 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler { * annotated handler methods. This is intended to be passed into * {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}. *
In effect a shortcut to create and initialize
- * {@code RSocketMessageHandler} with the given strategies and handlers,
- * use {@link #responder()} to obtain the responder, and plug that into
+ * {@code RSocketMessageHandler} with the given strategies and handlers.
+ * Use {@link #responder()} to obtain the responder and plug that into
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory ClientRSocketFactory}.
* For more advanced scenarios, e.g. discovering handlers through a custom
* stereotype annotation, consider declaring {@code RSocketMessageHandler}
@@ -509,15 +508,16 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
* @param strategies the strategies to set on the created
* {@code RSocketMessageHandler}
* @param candidateHandlers a list of Objects and/or Classes with annotated
- * handler methods; used to call {@link #setHandlers(List)} with
- * on the created {@code RSocketMessageHandler}
+ * handler methods; used to call {@link #setHandlers(List)} on the created
+ * {@code RSocketMessageHandler}
* @return a configurer that may be passed into
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}
- * @deprecated as of 5.2.6 following the deprecation of
+ * @deprecated as of 5.2.6 following the deprecation of
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory RSocketFactory.ClientRSocketFactory}
- * in RSocket 1.0 RC7.
+ * in RSocket 1.0 RC7
*/
@Deprecated
+ @SuppressWarnings("deprecation")
public static org.springframework.messaging.rsocket.ClientRSocketFactoryConfigurer clientResponder(
RSocketStrategies strategies, Object... candidateHandlers) {
@@ -536,5 +536,3 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
};
}
}
-
-
diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java
index b025de49003..75978df75c3 100644
--- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java
+++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java
@@ -149,7 +149,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
* Set the Hibernate SessionFactory that should be used to create
* Hibernate Sessions.
*/
- public void setSessionFactory(@Nullable SessionFactory sessionFactory) {
+ public void setSessionFactory(@Nullable SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@@ -184,7 +184,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
* @see #enableFilters(Session)
* @see Session#enableFilter(String)
*/
- public void setFilterNames(@Nullable String... filterNames) {
+ public void setFilterNames(@Nullable String... filterNames) {
this.filterNames = filterNames;
}
@@ -465,9 +465,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@Nullable
- public >) session -> {
Criteria criteria = session.createCriteria(entityClass);
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
@@ -550,7 +544,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@SuppressWarnings({"deprecation"})
- public void load(final Object entity, final Serializable id) throws DataAccessException {
+ public void load(Object entity, Serializable id) throws DataAccessException {
executeWithNativeSession(session -> {
session.load(entity, id);
return null;
@@ -558,12 +552,12 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void refresh(final Object entity) throws DataAccessException {
+ public void refresh(Object entity) throws DataAccessException {
refresh(entity, null);
}
@Override
- public void refresh(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException {
+ public void refresh(Object entity, @Nullable LockMode lockMode) throws DataAccessException {
executeWithNativeSession(session -> {
if (lockMode != null) {
session.refresh(entity, new LockOptions(lockMode));
@@ -576,14 +570,14 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public boolean contains(final Object entity) throws DataAccessException {
+ public boolean contains(Object entity) throws DataAccessException {
Boolean result = executeWithNativeSession(session -> session.contains(entity));
Assert.state(result != null, "No contains result");
return result;
}
@Override
- public void evict(final Object entity) throws DataAccessException {
+ public void evict(Object entity) throws DataAccessException {
executeWithNativeSession(session -> {
session.evict(entity);
return null;
@@ -616,7 +610,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
//-------------------------------------------------------------------------
@Override
- public void lock(final Object entity, final LockMode lockMode) throws DataAccessException {
+ public void lock(Object entity, LockMode lockMode) throws DataAccessException {
executeWithNativeSession(session -> {
session.buildLockRequest(new LockOptions(lockMode)).lock(entity);
return null;
@@ -624,7 +618,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void lock(final String entityName, final Object entity, final LockMode lockMode)
+ public void lock(String entityName, Object entity, LockMode lockMode)
throws DataAccessException {
executeWithNativeSession(session -> {
@@ -634,7 +628,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public Serializable save(final Object entity) throws DataAccessException {
+ public Serializable save(Object entity) throws DataAccessException {
return nonNull(executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
return session.save(entity);
@@ -642,7 +636,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public Serializable save(final String entityName, final Object entity) throws DataAccessException {
+ public Serializable save(String entityName, Object entity) throws DataAccessException {
return nonNull(executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
return session.save(entityName, entity);
@@ -655,7 +649,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void update(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException {
+ public void update(Object entity, @Nullable LockMode lockMode) throws DataAccessException {
executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
session.update(entity);
@@ -672,7 +666,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void update(final String entityName, final Object entity, @Nullable final LockMode lockMode)
+ public void update(String entityName, Object entity, @Nullable LockMode lockMode)
throws DataAccessException {
executeWithNativeSession(session -> {
@@ -686,7 +680,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void saveOrUpdate(final Object entity) throws DataAccessException {
+ public void saveOrUpdate(Object entity) throws DataAccessException {
executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
session.saveOrUpdate(entity);
@@ -695,7 +689,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void saveOrUpdate(final String entityName, final Object entity) throws DataAccessException {
+ public void saveOrUpdate(String entityName, Object entity) throws DataAccessException {
executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
session.saveOrUpdate(entityName, entity);
@@ -704,9 +698,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void replicate(final Object entity, final ReplicationMode replicationMode)
- throws DataAccessException {
-
+ public void replicate(Object entity, ReplicationMode replicationMode) throws DataAccessException {
executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
session.replicate(entity, replicationMode);
@@ -715,7 +707,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
+ public void replicate(String entityName, Object entity, ReplicationMode replicationMode)
throws DataAccessException {
executeWithNativeSession(session -> {
@@ -726,7 +718,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void persist(final Object entity) throws DataAccessException {
+ public void persist(Object entity) throws DataAccessException {
executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
session.persist(entity);
@@ -735,7 +727,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
}
@Override
- public void persist(final String entityName, final Object entity) throws DataAccessException {
+ public void persist(String entityName, Object entity) throws DataAccessException {
executeWithNativeSession(session -> {
checkWriteOperationAllowed(session);
session.persist(entityName, entity);
@@ -745,7 +737,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@SuppressWarnings("unchecked")
- public
>) session -> {
org.hibernate.Query queryObject = queryObject(
ReflectionUtils.invokeMethod(createQueryMethod, session, queryString));
@@ -923,7 +913,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated
@Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
- public List> findByNamedParam(final String queryString, final String[] paramNames, final Object[] values)
+ public List> findByNamedParam(String queryString, String[] paramNames, Object[] values)
throws DataAccessException {
if (paramNames.length != values.length) {
@@ -943,8 +933,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated
@Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
- public List> findByValueBean(final String queryString, final Object valueBean)
- throws DataAccessException {
+ public List> findByValueBean(String queryString, Object valueBean) throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback
>) session -> {
org.hibernate.Query queryObject = queryObject(
@@ -963,7 +952,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated
@Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
- public List> findByNamedQuery(final String queryName, @Nullable final Object... values) throws DataAccessException {
+ public List> findByNamedQuery(String queryName, @Nullable Object... values) throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback
>) session -> {
org.hibernate.Query queryObject = queryObject(
ReflectionUtils.invokeMethod(getNamedQueryMethod, session, queryName));
@@ -989,7 +978,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
public List> findByNamedQueryAndNamedParam(
- final String queryName, @Nullable final String[] paramNames, @Nullable final Object[] values)
+ String queryName, @Nullable String[] paramNames, @Nullable Object[] values)
throws DataAccessException {
if (values != null && (paramNames == null || paramNames.length != values.length)) {
@@ -1011,8 +1000,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated
@Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
- public List> findByNamedQueryAndValueBean(final String queryName, final Object valueBean)
- throws DataAccessException {
+ public List> findByNamedQueryAndValueBean(String queryName, Object valueBean) throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback
>) session -> {
org.hibernate.Query queryObject = queryObject(
@@ -1031,7 +1019,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated
@Override
@SuppressWarnings({"rawtypes", "deprecation"})
- public Iterator> iterate(final String queryString, @Nullable final Object... values) throws DataAccessException {
+ public Iterator> iterate(String queryString, @Nullable Object... values) throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback