Browse Source

Clean up warnings in Gradle build, polishing, etc.

pull/25316/head
Sam Brannen 6 years ago
parent
commit
b33d2fe683
  1. 10
      spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java
  2. 6
      spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java
  3. 6
      spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java
  4. 2
      spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java
  5. 3
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java
  6. 22
      spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java
  7. 90
      spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java
  8. 4
      spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java
  9. 5
      spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java
  10. 1
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java
  11. 1
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java

10
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 // not currently testable in a reliable fashion
//assertDoesNotMatchStringClass(classFilter); //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, 12D)).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, 11)).as("Should not match setSomeNumber with Integer input").isFalse();
assertThat(methodMatcher.matches(getAge, TestBean.class)).as("Should not match getAge").isFalse(); assertThat(methodMatcher.matches(getAge, TestBean.class)).as("Should not match getAge").isFalse();
assertThat(methodMatcher.isRuntime()).as("Should be a runtime match").isTrue(); assertThat(methodMatcher.isRuntime()).as("Should be a runtime match").isTrue();
} }
@ -224,10 +224,10 @@ public class AspectJExpressionPointcutTests {
TestBean testBean = getAdvisedProxy(expression, interceptor); TestBean testBean = getAdvisedProxy(expression, interceptor);
assertThat(interceptor.getCount()).as("Calls should be 0").isEqualTo(0); 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); 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); assertThat(interceptor.getCount()).as("Calls should be 1").isEqualTo(1);
} }

6
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 // Make sure the interface is loaded from the parent class loader
loader.excludeClass(TestService.class.getName()); loader.excludeClass(TestService.class.getName());
loader.excludeClass(TestException.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"); testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, other, "TestServiceImpl");
} }
private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message) private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message)
@ -127,7 +126,6 @@ public class TrickyAspectJPointcutExpressionTests {
public SimpleThrowawayClassLoader(ClassLoader parent) { public SimpleThrowawayClassLoader(ClassLoader parent) {
super(parent); super(parent);
} }
} }

6
spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java

@ -83,6 +83,7 @@ public class AspectProxyFactoryTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void testSerializable() throws Exception { public void testSerializable() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class); proxyFactory.addAspect(LoggingAspectOnVarargs.class);
@ -114,11 +115,11 @@ public class AspectProxyFactoryTests {
@Test @Test
public void testWithNonSingletonAspectInstance() throws Exception { public void testWithNonSingletonAspectInstance() throws Exception {
AspectJProxyFactory pf = new AspectJProxyFactory(); AspectJProxyFactory pf = new AspectJProxyFactory();
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new PerThisAspect()));
pf.addAspect(new PerThisAspect()));
} }
@Test // SPR-13328 @Test // SPR-13328
@SuppressWarnings("unchecked")
public void testProxiedVarargsWithEnumArray() throws Exception { public void testProxiedVarargsWithEnumArray() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class); proxyFactory.addAspect(LoggingAspectOnVarargs.class);
@ -127,6 +128,7 @@ public class AspectProxyFactoryTests {
} }
@Test // SPR-13328 @Test // SPR-13328
@SuppressWarnings("unchecked")
public void testUnproxiedVarargsWithEnumArray() throws Exception { public void testUnproxiedVarargsWithEnumArray() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean()); AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnSetter.class); proxyFactory.addAspect(LoggingAspectOnSetter.class);

2
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.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
given(methodInvocation.getThis()).willReturn(this); 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!"); given(methodInvocation.proceed()).willReturn("Hello!");
Log log = mock(Log.class); Log log = mock(Log.class);

3
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 BeanPropertySqlParameterSource
* @see NamedParameterJdbcTemplate#batchUpdate(String, SqlParameterSource[]) * @see NamedParameterJdbcTemplate#batchUpdate(String, SqlParameterSource[])
*/ */
@SuppressWarnings("unchecked")
public static SqlParameterSource[] createBatch(Object... candidates) { public static SqlParameterSource[] createBatch(Object... candidates) {
return createBatch(Arrays.asList(candidates)); return createBatch(Arrays.asList(candidates));
} }

22
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 SocketAcceptor} adapter to register with the
* {@link io.rsocket.core.RSocketServer}. * {@link io.rsocket.core.RSocketServer}.
* *
* <p>For a client, possibly in the same process as a server, consider * <p>For a client, possibly in the same process as a server, consider using the
* consider using the static factory method * static factory method {@link #responder(RSocketStrategies, Object...)} to
* {@link #responder(RSocketStrategies, Object...)} to obtain a client * obtain a client responder to be registered via
* responder to be registered via
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketConnector * {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketConnector
* RSocketRequester.Builder}. * RSocketRequester.Builder}.
* *
@ -500,8 +499,8 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
* annotated handler methods. This is intended to be passed into * annotated handler methods. This is intended to be passed into
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}. * {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}.
* <p>In effect a shortcut to create and initialize * <p>In effect a shortcut to create and initialize
* {@code RSocketMessageHandler} with the given strategies and handlers, * {@code RSocketMessageHandler} with the given strategies and handlers.
* use {@link #responder()} to obtain the responder, and plug that into * Use {@link #responder()} to obtain the responder and plug that into
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory ClientRSocketFactory}. * {@link io.rsocket.RSocketFactory.ClientRSocketFactory ClientRSocketFactory}.
* For more advanced scenarios, e.g. discovering handlers through a custom * For more advanced scenarios, e.g. discovering handlers through a custom
* stereotype annotation, consider declaring {@code RSocketMessageHandler} * stereotype annotation, consider declaring {@code RSocketMessageHandler}
@ -509,15 +508,16 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
* @param strategies the strategies to set on the created * @param strategies the strategies to set on the created
* {@code RSocketMessageHandler} * {@code RSocketMessageHandler}
* @param candidateHandlers a list of Objects and/or Classes with annotated * @param candidateHandlers a list of Objects and/or Classes with annotated
* handler methods; used to call {@link #setHandlers(List)} with * handler methods; used to call {@link #setHandlers(List)} on the created
* on the created {@code RSocketMessageHandler} * {@code RSocketMessageHandler}
* @return a configurer that may be passed into * @return a configurer that may be passed into
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory} * {@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} * {@link io.rsocket.RSocketFactory.ClientRSocketFactory RSocketFactory.ClientRSocketFactory}
* in RSocket 1.0 RC7. * in RSocket 1.0 RC7
*/ */
@Deprecated @Deprecated
@SuppressWarnings("deprecation")
public static org.springframework.messaging.rsocket.ClientRSocketFactoryConfigurer clientResponder( public static org.springframework.messaging.rsocket.ClientRSocketFactoryConfigurer clientResponder(
RSocketStrategies strategies, Object... candidateHandlers) { RSocketStrategies strategies, Object... candidateHandlers) {
@ -536,5 +536,3 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
}; };
} }
} }

90
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 * Set the Hibernate SessionFactory that should be used to create
* Hibernate Sessions. * Hibernate Sessions.
*/ */
public void setSessionFactory(@Nullable SessionFactory sessionFactory) { public void setSessionFactory(@Nullable SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory; this.sessionFactory = sessionFactory;
} }
@ -184,7 +184,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
* @see #enableFilters(Session) * @see #enableFilters(Session)
* @see Session#enableFilter(String) * @see Session#enableFilter(String)
*/ */
public void setFilterNames(@Nullable String... filterNames) { public void setFilterNames(@Nullable String... filterNames) {
this.filterNames = filterNames; this.filterNames = filterNames;
} }
@ -465,9 +465,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@Nullable @Nullable
public <T> T get(final Class<T> entityClass, final Serializable id, @Nullable final LockMode lockMode) public <T> T get(Class<T> entityClass, Serializable id, @Nullable LockMode lockMode) throws DataAccessException {
throws DataAccessException {
return executeWithNativeSession(session -> { return executeWithNativeSession(session -> {
if (lockMode != null) { if (lockMode != null) {
return session.get(entityClass, id, new LockOptions(lockMode)); return session.get(entityClass, id, new LockOptions(lockMode));
@ -486,9 +484,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@Nullable @Nullable
public Object get(final String entityName, final Serializable id, @Nullable final LockMode lockMode) public Object get(String entityName, Serializable id, @Nullable LockMode lockMode) throws DataAccessException {
throws DataAccessException {
return executeWithNativeSession(session -> { return executeWithNativeSession(session -> {
if (lockMode != null) { if (lockMode != null) {
return session.get(entityName, id, new LockOptions(lockMode)); return session.get(entityName, id, new LockOptions(lockMode));
@ -505,7 +501,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public <T> T load(final Class<T> entityClass, final Serializable id, @Nullable final LockMode lockMode) public <T> T load(Class<T> entityClass, Serializable id, @Nullable LockMode lockMode)
throws DataAccessException { throws DataAccessException {
return nonNull(executeWithNativeSession(session -> { return nonNull(executeWithNativeSession(session -> {
@ -524,9 +520,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public Object load(final String entityName, final Serializable id, @Nullable final LockMode lockMode) public Object load(String entityName, Serializable id, @Nullable LockMode lockMode) throws DataAccessException {
throws DataAccessException {
return nonNull(executeWithNativeSession(session -> { return nonNull(executeWithNativeSession(session -> {
if (lockMode != null) { if (lockMode != null) {
return session.load(entityName, id, new LockOptions(lockMode)); return session.load(entityName, id, new LockOptions(lockMode));
@ -539,7 +533,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@SuppressWarnings({"unchecked", "deprecation"}) @SuppressWarnings({"unchecked", "deprecation"})
public <T> List<T> loadAll(final Class<T> entityClass) throws DataAccessException { public <T> List<T> loadAll(Class<T> entityClass) throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback<List<T>>) session -> { return nonNull(executeWithNativeSession((HibernateCallback<List<T>>) session -> {
Criteria criteria = session.createCriteria(entityClass); Criteria criteria = session.createCriteria(entityClass);
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
@ -550,7 +544,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@SuppressWarnings({"deprecation"}) @SuppressWarnings({"deprecation"})
public void load(final Object entity, final Serializable id) throws DataAccessException { public void load(Object entity, Serializable id) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
session.load(entity, id); session.load(entity, id);
return null; return null;
@ -558,12 +552,12 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void refresh(final Object entity) throws DataAccessException { public void refresh(Object entity) throws DataAccessException {
refresh(entity, null); refresh(entity, null);
} }
@Override @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 -> { executeWithNativeSession(session -> {
if (lockMode != null) { if (lockMode != null) {
session.refresh(entity, new LockOptions(lockMode)); session.refresh(entity, new LockOptions(lockMode));
@ -576,14 +570,14 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public boolean contains(final Object entity) throws DataAccessException { public boolean contains(Object entity) throws DataAccessException {
Boolean result = executeWithNativeSession(session -> session.contains(entity)); Boolean result = executeWithNativeSession(session -> session.contains(entity));
Assert.state(result != null, "No contains result"); Assert.state(result != null, "No contains result");
return result; return result;
} }
@Override @Override
public void evict(final Object entity) throws DataAccessException { public void evict(Object entity) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
session.evict(entity); session.evict(entity);
return null; return null;
@ -616,7 +610,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@Override @Override
public void lock(final Object entity, final LockMode lockMode) throws DataAccessException { public void lock(Object entity, LockMode lockMode) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
session.buildLockRequest(new LockOptions(lockMode)).lock(entity); session.buildLockRequest(new LockOptions(lockMode)).lock(entity);
return null; return null;
@ -624,7 +618,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void lock(final String entityName, final Object entity, final LockMode lockMode) public void lock(String entityName, Object entity, LockMode lockMode)
throws DataAccessException { throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
@ -634,7 +628,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public Serializable save(final Object entity) throws DataAccessException { public Serializable save(Object entity) throws DataAccessException {
return nonNull(executeWithNativeSession(session -> { return nonNull(executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
return session.save(entity); return session.save(entity);
@ -642,7 +636,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @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 -> { return nonNull(executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
return session.save(entityName, entity); return session.save(entityName, entity);
@ -655,7 +649,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @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 -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
session.update(entity); session.update(entity);
@ -672,7 +666,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @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 { throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
@ -686,7 +680,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void saveOrUpdate(final Object entity) throws DataAccessException { public void saveOrUpdate(Object entity) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
session.saveOrUpdate(entity); session.saveOrUpdate(entity);
@ -695,7 +689,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void saveOrUpdate(final String entityName, final Object entity) throws DataAccessException { public void saveOrUpdate(String entityName, Object entity) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
session.saveOrUpdate(entityName, entity); session.saveOrUpdate(entityName, entity);
@ -704,9 +698,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void replicate(final Object entity, final ReplicationMode replicationMode) public void replicate(Object entity, ReplicationMode replicationMode) throws DataAccessException {
throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
session.replicate(entity, replicationMode); session.replicate(entity, replicationMode);
@ -715,7 +707,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode) public void replicate(String entityName, Object entity, ReplicationMode replicationMode)
throws DataAccessException { throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
@ -726,7 +718,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void persist(final Object entity) throws DataAccessException { public void persist(Object entity) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
session.persist(entity); session.persist(entity);
@ -735,7 +727,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void persist(final String entityName, final Object entity) throws DataAccessException { public void persist(String entityName, Object entity) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
session.persist(entityName, entity); session.persist(entityName, entity);
@ -745,7 +737,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T merge(final T entity) throws DataAccessException { public <T> T merge(T entity) throws DataAccessException {
return nonNull(executeWithNativeSession(session -> { return nonNull(executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
return (T) session.merge(entity); return (T) session.merge(entity);
@ -754,7 +746,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T merge(final String entityName, final T entity) throws DataAccessException { public <T> T merge(String entityName, T entity) throws DataAccessException {
return nonNull(executeWithNativeSession(session -> { return nonNull(executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
return (T) session.merge(entityName, entity); return (T) session.merge(entityName, entity);
@ -767,7 +759,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void delete(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException { public void delete(Object entity, @Nullable LockMode lockMode) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
if (lockMode != null) { if (lockMode != null) {
@ -784,7 +776,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void delete(final String entityName, final Object entity, @Nullable final LockMode lockMode) public void delete(String entityName, Object entity, @Nullable LockMode lockMode)
throws DataAccessException { throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
@ -798,7 +790,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
public void deleteAll(final Collection<?> entities) throws DataAccessException { public void deleteAll(Collection<?> entities) throws DataAccessException {
executeWithNativeSession(session -> { executeWithNativeSession(session -> {
checkWriteOperationAllowed(session); checkWriteOperationAllowed(session);
for (Object entity : entities) { for (Object entity : entities) {
@ -835,8 +827,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
} }
@Override @Override
@SuppressWarnings("unchecked") public List<?> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults)
public List<?> findByCriteria(final DetachedCriteria criteria, final int firstResult, final int maxResults)
throws DataAccessException { throws DataAccessException {
Assert.notNull(criteria, "DetachedCriteria must not be null"); Assert.notNull(criteria, "DetachedCriteria must not be null");
@ -870,8 +861,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@SuppressWarnings({"unchecked", "deprecation"}) @SuppressWarnings({"unchecked", "deprecation"})
public <T> List<T> findByExample( public <T> List<T> findByExample(@Nullable String entityName, T exampleEntity, int firstResult, int maxResults)
@Nullable final String entityName, final T exampleEntity, final int firstResult, final int maxResults)
throws DataAccessException { throws DataAccessException {
Assert.notNull(exampleEntity, "Example entity must not be null"); Assert.notNull(exampleEntity, "Example entity must not be null");
@ -898,7 +888,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) @SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
public List<?> find(final String queryString, @Nullable final Object... values) throws DataAccessException { public List<?> find(String queryString, @Nullable Object... values) throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> { return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> {
org.hibernate.Query queryObject = queryObject( org.hibernate.Query queryObject = queryObject(
ReflectionUtils.invokeMethod(createQueryMethod, session, queryString)); ReflectionUtils.invokeMethod(createQueryMethod, session, queryString));
@ -923,7 +913,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) @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 { throws DataAccessException {
if (paramNames.length != values.length) { if (paramNames.length != values.length) {
@ -943,8 +933,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) @SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
public List<?> findByValueBean(final String queryString, final Object valueBean) public List<?> findByValueBean(String queryString, Object valueBean) throws DataAccessException {
throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> { return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> {
org.hibernate.Query queryObject = queryObject( org.hibernate.Query queryObject = queryObject(
@ -963,7 +952,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) @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<List<?>>) session -> { return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> {
org.hibernate.Query queryObject = queryObject( org.hibernate.Query queryObject = queryObject(
ReflectionUtils.invokeMethod(getNamedQueryMethod, session, queryName)); ReflectionUtils.invokeMethod(getNamedQueryMethod, session, queryName));
@ -989,7 +978,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override @Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) @SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
public List<?> findByNamedQueryAndNamedParam( public List<?> findByNamedQueryAndNamedParam(
final String queryName, @Nullable final String[] paramNames, @Nullable final Object[] values) String queryName, @Nullable String[] paramNames, @Nullable Object[] values)
throws DataAccessException { throws DataAccessException {
if (values != null && (paramNames == null || paramNames.length != values.length)) { if (values != null && (paramNames == null || paramNames.length != values.length)) {
@ -1011,8 +1000,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) @SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
public List<?> findByNamedQueryAndValueBean(final String queryName, final Object valueBean) public List<?> findByNamedQueryAndValueBean(String queryName, Object valueBean) throws DataAccessException {
throws DataAccessException {
return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> { return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> {
org.hibernate.Query queryObject = queryObject( org.hibernate.Query queryObject = queryObject(
@ -1031,7 +1019,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings({"rawtypes", "deprecation"}) @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<Iterator<?>>) session -> { return nonNull(executeWithNativeSession((HibernateCallback<Iterator<?>>) session -> {
org.hibernate.Query queryObject = queryObject( org.hibernate.Query queryObject = queryObject(
ReflectionUtils.invokeMethod(createQueryMethod, session, queryString)); ReflectionUtils.invokeMethod(createQueryMethod, session, queryString));
@ -1059,7 +1047,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Deprecated @Deprecated
@Override @Override
@SuppressWarnings({"rawtypes", "deprecation"}) @SuppressWarnings({"rawtypes", "deprecation"})
public int bulkUpdate(final String queryString, @Nullable final Object... values) throws DataAccessException { public int bulkUpdate(String queryString, @Nullable Object... values) throws DataAccessException {
Integer result = executeWithNativeSession(session -> { Integer result = executeWithNativeSession(session -> {
org.hibernate.Query queryObject = queryObject( org.hibernate.Query queryObject = queryObject(
ReflectionUtils.invokeMethod(createQueryMethod, session, queryString)); ReflectionUtils.invokeMethod(createQueryMethod, session, queryString));

4
spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java

@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks; import reactor.core.publisher.Sinks;
import reactor.core.publisher.UnicastProcessor;
import org.springframework.core.ResolvableType; import org.springframework.core.ResolvableType;
import org.springframework.core.codec.StringDecoder; import org.springframework.core.codec.StringDecoder;
@ -233,7 +232,8 @@ public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTests {
@Test // SPR-16402 @Test // SPR-16402
public void singleSubscriberWithStrings() { public void singleSubscriberWithStrings() {
UnicastProcessor<String> processor = UnicastProcessor.create(); @SuppressWarnings("deprecation")
reactor.core.publisher.UnicastProcessor<String> processor = reactor.core.publisher.UnicastProcessor.create();
Flux.just("foo", "bar", "baz").subscribe(processor); Flux.just("foo", "bar", "baz").subscribe(processor);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder(); MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();

5
spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java

@ -64,10 +64,11 @@ public class ForwardedHeaderFilterTests {
private final ForwardedHeaderFilter filter = new ForwardedHeaderFilter(); private final ForwardedHeaderFilter filter = new ForwardedHeaderFilter();
private MockHttpServletRequest request; @SuppressWarnings("serial")
private final MockFilterChain filterChain = new MockFilterChain(new HttpServlet() {}); private final MockFilterChain filterChain = new MockFilterChain(new HttpServlet() {});
private MockHttpServletRequest request;
@BeforeEach @BeforeEach
@SuppressWarnings("serial") @SuppressWarnings("serial")

1
spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java

@ -138,7 +138,6 @@ public class RedirectViewTests {
} }
@Test @Test
@SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
public void flashMap() throws Exception { public void flashMap() throws Exception {
RedirectView rv = new RedirectView(); RedirectView rv = new RedirectView();
rv.setUrl("https://url.somewhere.com/path"); rv.setUrl("https://url.somewhere.com/path");

1
spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java

@ -304,7 +304,6 @@ public class ScriptTemplateViewTests {
assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true); assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true);
} }
@SuppressWarnings("unchecked")
@Test // gh-23258 @Test // gh-23258
public void engineSupplierWithNonSharedEngine() { public void engineSupplierWithNonSharedEngine() {
this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.class)); this.configurer.setEngineSupplier(() -> mock(InvocableScriptEngine.class));

Loading…
Cancel
Save