diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java index 5b0ee945f5b..5672ddcc7a6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java @@ -377,7 +377,7 @@ public class BeanDefinitionParserDelegate { */ public BeanDefinitionDefaults getBeanDefinitionDefaults() { BeanDefinitionDefaults bdd = new BeanDefinitionDefaults(); - bdd.setLazyInit("TRUE".equalsIgnoreCase(this.defaults.getLazyInit())); + bdd.setLazyInit(TRUE_VALUE.equalsIgnoreCase(this.defaults.getLazyInit())); bdd.setAutowireMode(getAutowireMode(DEFAULT_VALUE)); bdd.setInitMethodName(this.defaults.getInitMethod()); bdd.setDestroyMethodName(this.defaults.getDestroyMethod()); diff --git a/spring-core/src/main/java/org/springframework/core/log/LogFormatUtils.java b/spring-core/src/main/java/org/springframework/core/log/LogFormatUtils.java index cced2bf3d73..c00c33464fc 100644 --- a/spring-core/src/main/java/org/springframework/core/log/LogFormatUtils.java +++ b/spring-core/src/main/java/org/springframework/core/log/LogFormatUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -82,8 +82,9 @@ public abstract class LogFormatUtils { */ public static void traceDebug(Log logger, Function messageFactory) { if (logger.isDebugEnabled()) { - String logMessage = messageFactory.apply(logger.isTraceEnabled()); - if (logger.isTraceEnabled()) { + boolean traceEnabled = logger.isTraceEnabled(); + String logMessage = messageFactory.apply(traceEnabled); + if (traceEnabled) { logger.trace(logMessage); } else { diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index d8002d6128e..594be96c10f 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -64,6 +64,8 @@ import org.springframework.util.StringUtils; *
  • {@link #set(String, String)} sets the header value to a single string value
  • * * + *

    Note that {@code HttpHeaders} generally treats header names in a case-insensitive manner. + * * @author Arjen Poutsma * @author Sebastien Deleuze * @author Brian Clozel @@ -416,6 +418,7 @@ public class HttpHeaders implements MultiValueMap, Serializable /** * Construct a new, empty instance of the {@code HttpHeaders} object. + *

    This is the common constructor, using a case-insensitive map structure. */ public HttpHeaders() { this(CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))); @@ -423,6 +426,9 @@ public class HttpHeaders implements MultiValueMap, Serializable /** * Construct a new {@code HttpHeaders} instance backed by an existing map. + *

    This constructor is available as an optimization for adapting to existing + * headers map structures, primarily for internal use within the framework. + * @param headers the headers map (expected to operate with case-insensitive keys) * @since 5.1 */ public HttpHeaders(MultiValueMap headers) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java index ef81b9e6495..bea11de0467 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java @@ -117,7 +117,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport public void setAlwaysUseFullPath(boolean alwaysUseFullPath) { this.urlPathHelper.setAlwaysUseFullPath(alwaysUseFullPath); if (this.corsConfigurationSource instanceof UrlBasedCorsConfigurationSource) { - ((UrlBasedCorsConfigurationSource)this.corsConfigurationSource).setAlwaysUseFullPath(alwaysUseFullPath); + ((UrlBasedCorsConfigurationSource) this.corsConfigurationSource).setAlwaysUseFullPath(alwaysUseFullPath); } } @@ -128,7 +128,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport public void setUrlDecode(boolean urlDecode) { this.urlPathHelper.setUrlDecode(urlDecode); if (this.corsConfigurationSource instanceof UrlBasedCorsConfigurationSource) { - ((UrlBasedCorsConfigurationSource)this.corsConfigurationSource).setUrlDecode(urlDecode); + ((UrlBasedCorsConfigurationSource) this.corsConfigurationSource).setUrlDecode(urlDecode); } } @@ -139,7 +139,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport public void setRemoveSemicolonContent(boolean removeSemicolonContent) { this.urlPathHelper.setRemoveSemicolonContent(removeSemicolonContent); if (this.corsConfigurationSource instanceof UrlBasedCorsConfigurationSource) { - ((UrlBasedCorsConfigurationSource)this.corsConfigurationSource).setRemoveSemicolonContent(removeSemicolonContent); + ((UrlBasedCorsConfigurationSource) this.corsConfigurationSource).setRemoveSemicolonContent(removeSemicolonContent); } } @@ -153,7 +153,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport Assert.notNull(urlPathHelper, "UrlPathHelper must not be null"); this.urlPathHelper = urlPathHelper; if (this.corsConfigurationSource instanceof UrlBasedCorsConfigurationSource) { - ((UrlBasedCorsConfigurationSource)this.corsConfigurationSource).setUrlPathHelper(urlPathHelper); + ((UrlBasedCorsConfigurationSource) this.corsConfigurationSource).setUrlPathHelper(urlPathHelper); } } @@ -173,7 +173,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport Assert.notNull(pathMatcher, "PathMatcher must not be null"); this.pathMatcher = pathMatcher; if (this.corsConfigurationSource instanceof UrlBasedCorsConfigurationSource) { - ((UrlBasedCorsConfigurationSource)this.corsConfigurationSource).setPathMatcher(pathMatcher); + ((UrlBasedCorsConfigurationSource) this.corsConfigurationSource).setPathMatcher(pathMatcher); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index a09b1e251be..ea688a37840 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -169,7 +169,7 @@ public class MvcNamespaceTests { @Before - public void setUp() throws Exception { + public void setup() throws Exception { TestMockServletContext servletContext = new TestMockServletContext(); appContext = new XmlWebApplicationContext(); appContext.setServletContext(servletContext); @@ -889,7 +889,7 @@ public class MvcNamespaceTests { AbstractHandlerMapping handlerMapping = (AbstractHandlerMapping)appContext.getBean(beanName); assertNotNull(handlerMapping); DirectFieldAccessor accessor = new DirectFieldAccessor(handlerMapping); - Map configs = ((UrlBasedCorsConfigurationSource)accessor + Map configs = ((UrlBasedCorsConfigurationSource) accessor .getPropertyValue("corsConfigurationSource")).getCorsConfigurations(); assertNotNull(configs); assertEquals(1, configs.size()); @@ -914,7 +914,7 @@ public class MvcNamespaceTests { AbstractHandlerMapping handlerMapping = (AbstractHandlerMapping)appContext.getBean(beanName); assertNotNull(handlerMapping); DirectFieldAccessor accessor = new DirectFieldAccessor(handlerMapping); - Map configs = ((UrlBasedCorsConfigurationSource)accessor + Map configs = ((UrlBasedCorsConfigurationSource) accessor .getPropertyValue("corsConfigurationSource")).getCorsConfigurations(); assertNotNull(configs); assertEquals(2, configs.size());