From 2c45b092633df1d5515f232843087aaf6bc728cf Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 28 Feb 2018 15:08:09 +0100 Subject: [PATCH] Polishing --- .../aspectj/SimpleAspectInstanceFactory.java | 4 +- .../annotation/AspectJProxyFactory.java | 18 +---- .../groovy/GroovyBeanDefinitionReader.java | 6 +- .../beans/BeanWrapperImpl.java | 10 +-- .../beans/DirectFieldAccessor.java | 4 +- ...AbstractMessageListenerContainerTests.java | 42 ---------- .../DefaultMessageListenerContainerTests.java | 13 ++-- .../SimpleMessageListenerContainerTests.java | 76 +++++++++---------- .../jta/JtaTransactionManager.java | 4 +- .../web/method/annotation/ModelFactory.java | 17 ++--- .../ViewResolversBeanDefinitionParser.java | 4 +- 11 files changed, 67 insertions(+), 131 deletions(-) delete mode 100644 spring-jms/src/test/java/org/springframework/jms/listener/AbstractMessageListenerContainerTests.java diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java index 5d413bd697..ce243379e1 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -41,6 +41,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory { this.aspectClass = aspectClass; } + /** * Return the specified aspect class (never {@code null}). */ @@ -48,7 +49,6 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory { return this.aspectClass; } - @Override public final Object getAspectInstance() { try { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java index bf3971b0b5..9f6277ccab 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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,7 @@ import org.aspectj.lang.reflect.PerClauseKind; import org.springframework.aop.Advisor; import org.springframework.aop.aspectj.AspectJProxyUtils; -import org.springframework.aop.framework.AopConfigException; +import org.springframework.aop.aspectj.SimpleAspectInstanceFactory; import org.springframework.aop.framework.ProxyCreatorSupport; import org.springframework.aop.support.AopUtils; import org.springframework.core.annotation.AnnotationAwareOrderComparator; @@ -168,19 +168,9 @@ public class AspectJProxyFactory extends ProxyCreatorSupport { synchronized (aspectCache) { // To be safe, check within full lock now... instance = aspectCache.get(aspectClass); - if (instance != null) { - return instance; - } - try { - instance = aspectClass.newInstance(); + if (instance == null) { + instance = new SimpleAspectInstanceFactory(aspectClass).getAspectInstance(); aspectCache.put(aspectClass, instance); - return instance; - } - catch (InstantiationException ex) { - throw new AopConfigException("Unable to instantiate aspect class [" + aspectClass.getName() + "]", ex); - } - catch (IllegalAccessException ex) { - throw new AopConfigException("Cannot access aspect class [" + aspectClass.getName() + "]", ex); } } } diff --git a/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java b/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java index 657ac3808b..99d044644b 100644 --- a/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java +++ b/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -527,10 +527,10 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp Closure callable = (Closure) args[args.length - 1]; callable.setDelegate(this); callable.setResolveStrategy(Closure.DELEGATE_FIRST); - callable.call(new Object[]{currentBeanDefinition}); + callable.call(this.currentBeanDefinition); } - GroovyBeanDefinitionWrapper beanDefinition = currentBeanDefinition; + GroovyBeanDefinitionWrapper beanDefinition = this.currentBeanDefinition; this.currentBeanDefinition = null; beanDefinition.getBeanDefinition().setAttribute(GroovyBeanDefinitionWrapper.class.getName(), beanDefinition); getRegistry().registerBeanDefinition(beanName, beanDefinition.getBeanDefinition()); diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index 4d10dc0c81..a1686d0e80 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -224,10 +224,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements @Override protected BeanPropertyHandler getLocalPropertyHandler(String propertyName) { PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(propertyName); - if (pd != null) { - return new BeanPropertyHandler(pd); - } - return null; + return (pd != null ? new BeanPropertyHandler(pd) : null); } @Override @@ -238,8 +235,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements @Override protected NotWritablePropertyException createNotWritablePropertyException(String propertyName) { PropertyMatches matches = PropertyMatches.forProperty(propertyName, getRootClass()); - throw new NotWritablePropertyException( - getRootClass(), getNestedPath() + propertyName, + throw new NotWritablePropertyException(getRootClass(), getNestedPath() + propertyName, matches.buildErrorMessage(), matches.getPossibleMatches()); } diff --git a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java index 356231132d..b4777d4409 100644 --- a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -76,8 +76,8 @@ public class DirectFieldAccessor extends AbstractNestablePropertyAccessor { Field field = ReflectionUtils.findField(getWrappedClass(), propertyName); if (field != null) { propertyHandler = new FieldPropertyHandler(field); + this.fieldMap.put(propertyName, propertyHandler); } - this.fieldMap.put(propertyName, propertyHandler); } return propertyHandler; } diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/AbstractMessageListenerContainerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/AbstractMessageListenerContainerTests.java deleted file mode 100644 index b225303560..0000000000 --- a/spring-jms/src/test/java/org/springframework/jms/listener/AbstractMessageListenerContainerTests.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2002-2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.jms.listener; - -import org.junit.Test; - -/** - * Unit tests for the {@link AbstractMessageListenerContainer} class. - * - * @author Rick Evans - * @author Chris Beams - */ -public abstract class AbstractMessageListenerContainerTests { - - protected abstract AbstractMessageListenerContainer getContainer(); - - - @Test(expected=IllegalArgumentException.class) - public void testSettingMessageListenerToANullType() throws Exception { - getContainer().setMessageListener(null); - } - - @Test(expected=IllegalArgumentException.class) - public void testSettingMessageListenerToAnUnsupportedType() throws Exception { - getContainer().setMessageListener("Bingo"); - } - -} diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java index aa24fcd04f..08fade6b0d 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -78,7 +78,7 @@ public class DefaultMessageListenerContainerTests { public void recoverResetBackOff() { BackOff backOff = mock(BackOff.class); BackOffExecution execution = mock(BackOffExecution.class); - given(execution.nextBackOff()).willReturn(50L, 50L, 50L); // 3 attempts max + given(execution.nextBackOff()).willReturn(50L, 50L, 50L); // 3 attempts max given(backOff.start()).willReturn(execution); DefaultMessageListenerContainer container = createContainer(createRecoverableContainerFactory(1)); @@ -88,7 +88,7 @@ public class DefaultMessageListenerContainerTests { assertEquals(true, container.isRunning()); verify(backOff).start(); - verify(execution, times(1)).nextBackOff(); // only on attempt as the second one lead to a recovery + verify(execution, times(1)).nextBackOff(); // only on attempt as the second one lead to a recovery } @Test @@ -123,11 +123,8 @@ public class DefaultMessageListenerContainerTests { private ConnectionFactory createFailingContainerFactory() { try { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); - given(connectionFactory.createConnection()).will(new Answer() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - throw new JMSException("Test exception"); - } + given(connectionFactory.createConnection()).will(invocation -> { + throw new JMSException("Test exception"); }); return connectionFactory; } diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java index 962c7e0bf9..e96db305e2 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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 javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; -import org.junit.Before; import org.junit.Test; import org.springframework.context.support.GenericApplicationContext; @@ -44,7 +43,7 @@ import static org.mockito.BDDMockito.*; * @author Chris Beams * @author Mark Fisher */ -public class SimpleMessageListenerContainerTests extends AbstractMessageListenerContainerTests { +public class SimpleMessageListenerContainerTests { private static final String DESTINATION_NAME = "foo"; @@ -52,39 +51,38 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener private static final StubQueue QUEUE_DESTINATION = new StubQueue(); - - private SimpleMessageListenerContainer container; + private final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); - @Before - public void setUp() throws Exception { - this.container = (SimpleMessageListenerContainer) getContainer(); + @Test(expected = IllegalArgumentException.class) + public void testSettingMessageListenerToANullType() { + this.container.setMessageListener(null); + assertNull(this.container.getMessageListener()); } - @Override - protected AbstractMessageListenerContainer getContainer() { - return new SimpleMessageListenerContainer(); + @Test(expected = IllegalArgumentException.class) + public void testSettingMessageListenerToAnUnsupportedType() { + this.container.setMessageListener("Bingo"); } - @Test - public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception { + public void testSessionTransactedModeReallyDoesDefaultToFalse() { assertFalse("The [pubSubLocal] property of SimpleMessageListenerContainer " + "must default to false. Change this test (and the " + "attendant Javadoc) if you have changed the default.", - container.isPubSubNoLocal()); + this.container.isPubSubNoLocal()); } - @Test(expected=IllegalArgumentException.class) - public void testSettingConcurrentConsumersToZeroIsNotAllowed() throws Exception { - container.setConcurrentConsumers(0); - container.afterPropertiesSet(); + @Test(expected = IllegalArgumentException.class) + public void testSettingConcurrentConsumersToZeroIsNotAllowed() { + this.container.setConcurrentConsumers(0); + this.container.afterPropertiesSet(); } - @Test(expected=IllegalArgumentException.class) - public void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() throws Exception { - container.setConcurrentConsumers(-198); - container.afterPropertiesSet(); + @Test(expected = IllegalArgumentException.class) + public void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() { + this.container.setConcurrentConsumers(-198); + this.container.afterPropertiesSet(); } @Test @@ -94,7 +92,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener // Queue gets created in order to create MessageConsumer for that Destination... given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); // and then the MessageConsumer gets created... - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... Connection connection = mock(Connection.class); // session gets created in order to register MessageListener... @@ -124,7 +122,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener // Queue gets created in order to create MessageConsumer for that Destination... given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); // and then the MessageConsumer gets created... - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... Connection connection = mock(Connection.class); // session gets created in order to register MessageListener... @@ -156,7 +154,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener // Queue gets created in order to create MessageConsumer for that Destination... given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); // and then the MessageConsumer gets created... - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... // an exception is thrown, so the rollback logic is being applied here... given(session.getTransacted()).willReturn(false); given(session.getAcknowledgeMode()).willReturn(Session.AUTO_ACKNOWLEDGE); @@ -170,7 +168,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener final ConnectionFactory connectionFactory = mock(ConnectionFactory.class); given(connectionFactory.createConnection()).willReturn(connection); - final Set failure = new HashSet(1); + final Set failure = new HashSet<>(1); this.container.setConnectionFactory(connectionFactory); this.container.setDestinationName(DESTINATION_NAME); @@ -207,7 +205,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener final Session session = mock(Session.class); given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... given(session.getTransacted()).willReturn(false); given(session.getAcknowledgeMode()).willReturn(Session.AUTO_ACKNOWLEDGE); @@ -253,7 +251,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener // Queue gets created in order to create MessageConsumer for that Destination... given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); // and then the MessageConsumer gets created... - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... // an exception is thrown, so the rollback logic is being applied here... given(session.getTransacted()).willReturn(false); @@ -304,7 +302,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener // Queue gets created in order to create MessageConsumer for that Destination... given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); // and then the MessageConsumer gets created... - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... // an exception is thrown, so the rollback logic is being applied here... given(session.getTransacted()).willReturn(false); @@ -351,7 +349,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener // Queue gets created in order to create MessageConsumer for that Destination... given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); // and then the MessageConsumer gets created... - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... // an exception is thrown, so the rollback logic is being applied here... given(session.getTransacted()).willReturn(false); @@ -438,7 +436,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener // Queue gets created in order to create MessageConsumer for that Destination... given(session.createQueue(DESTINATION_NAME)).willReturn(QUEUE_DESTINATION); // and then the MessageConsumer gets created... - given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... + given(session.createConsumer(QUEUE_DESTINATION, null)).willReturn(messageConsumer); // no MessageSelector... Connection connection = mock(Connection.class); // session gets created in order to register MessageListener... @@ -482,42 +480,42 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener private MessageListener messageListener; - public void sendMessage(Message message) throws JMSException { + public void sendMessage(Message message) { this.messageListener.onMessage(message); } @Override - public String getMessageSelector() throws JMSException { + public String getMessageSelector() { throw new UnsupportedOperationException(); } @Override - public MessageListener getMessageListener() throws JMSException { + public MessageListener getMessageListener() { return this.messageListener; } @Override - public void setMessageListener(MessageListener messageListener) throws JMSException { + public void setMessageListener(MessageListener messageListener) { this.messageListener = messageListener; } @Override - public Message receive() throws JMSException { + public Message receive() { throw new UnsupportedOperationException(); } @Override - public Message receive(long l) throws JMSException { + public Message receive(long l) { throw new UnsupportedOperationException(); } @Override - public Message receiveNoWait() throws JMSException { + public Message receiveNoWait() { throw new UnsupportedOperationException(); } @Override - public void close() throws JMSException { + public void close() { throw new UnsupportedOperationException(); } } diff --git a/spring-tx/src/main/java/org/springframework/transaction/jta/JtaTransactionManager.java b/spring-tx/src/main/java/org/springframework/transaction/jta/JtaTransactionManager.java index 4d46ebbca0..7fef8515bf 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/jta/JtaTransactionManager.java +++ b/spring-tx/src/main/java/org/springframework/transaction/jta/JtaTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -831,12 +831,10 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager doJtaBegin(txObject, definition); } catch (NotSupportedException ex) { - // assume nested transaction not supported throw new NestedTransactionNotSupportedException( "JTA implementation does not support nested transactions", ex); } catch (UnsupportedOperationException ex) { - // assume nested transaction not supported throw new NestedTransactionNotSupportedException( "JTA implementation does not support nested transactions", ex); } diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java index 49fa3a3118..de80c7f462 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -101,8 +101,8 @@ public final class ModelFactory { * @param handlerMethod the method for which the model is initialized * @throws Exception may arise from {@code @ModelAttribute} methods */ - public void initModel(NativeWebRequest request, ModelAndViewContainer container, - HandlerMethod handlerMethod) throws Exception { + public void initModel(NativeWebRequest request, ModelAndViewContainer container, HandlerMethod handlerMethod) + throws Exception { Map sessionAttributes = this.sessionAttributesHandler.retrieveAttributes(request); container.mergeAttributes(sessionAttributes); @@ -241,13 +241,12 @@ public final class ModelFactory { /** - * Derive the model attribute name for a method parameter based on: - *
    - *
  1. the parameter {@code @ModelAttribute} annotation value - *
  2. the parameter type - *
+ * Derive the model attribute name for the given method parameter based on + * a {@code @ModelAttribute} parameter annotation (if present) or falling + * back on parameter type based conventions. * @param parameter a descriptor for the method parameter - * @return the derived name (never {@code null} or empty String) + * @return the derived name + * @see Conventions#getVariableNameForParameter(MethodParameter) */ public static String getNameForParameter(MethodParameter parameter) { ModelAttribute ann = parameter.getParameterAnnotation(ModelAttribute.class); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java index a8c8c53dc5..9b1561fe76 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java @@ -82,7 +82,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { resolvers.add(context.getDelegate().parsePropertySubElement(resolverElement, null)); continue; } - RootBeanDefinition resolverBeanDef = null; + RootBeanDefinition resolverBeanDef; if ("jsp".equals(name)) { resolverBeanDef = new RootBeanDefinition(InternalResourceViewResolver.class); resolverBeanDef.getPropertyValues().add("prefix", "/WEB-INF/"); @@ -180,7 +180,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); MutablePropertyValues values = beanDef.getPropertyValues(); - List elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"}); + List elements = DomUtils.getChildElementsByTagName(resolverElement, "default-views"); if (!elements.isEmpty()) { ManagedList list = new ManagedList(); for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {