diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java index 27b13810a7..cb2799c859 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java @@ -96,8 +96,8 @@ class JedisConnectionConfiguration extends RedisConnectionConfiguration { private JedisConnectionFactory createJedisConnectionFactory() { RedisProperties.Pool pool = this.properties.getJedis().getPool(); - JedisPoolConfig poolConfig = pool != null - ? jedisPoolConfig(pool) : new JedisPoolConfig(); + JedisPoolConfig poolConfig = pool != null ? jedisPoolConfig(pool) + : new JedisPoolConfig(); if (getSentinelConfig() != null) { return new JedisConnectionFactory(getSentinelConfig(), poolConfig); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java index d052b3ff13..f269b4a201 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java @@ -43,7 +43,8 @@ import org.springframework.util.StringUtils; * @author Mark Paluch */ @Configuration -@ConditionalOnClass({ GenericObjectPool.class, RedisClient.class, RedisClusterClient.class }) +@ConditionalOnClass({ GenericObjectPool.class, RedisClient.class, + RedisClusterClient.class }) class LettuceConnectionConfiguration extends RedisConnectionConfiguration { private final RedisProperties properties; @@ -149,8 +150,7 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration { return new LettuceConnectionFactory(applyProperties( applyClientResources(lettucePool, clientResources))); } - return applyClientResources( - new LettuceConnectionFactory(getSentinelConfig()), + return applyClientResources(new LettuceConnectionFactory(getSentinelConfig()), clientResources); } @@ -166,8 +166,8 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration { this.properties.getLettuce().getPool()); DefaultLettucePool lettucePool = new DefaultLettucePool( this.properties.getHost(), this.properties.getPort(), config); - return new LettuceConnectionFactory(applyProperties( - applyClientResources(lettucePool, clientResources))); + return new LettuceConnectionFactory( + applyProperties(applyClientResources(lettucePool, clientResources))); } return applyClientResources(new LettuceConnectionFactory(), clientResources); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java index 629cf2d381..cf452e83b6 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java @@ -46,15 +46,13 @@ import org.springframework.data.redis.core.StringRedisTemplate; @Configuration @ConditionalOnClass({ RedisOperations.class }) @EnableConfigurationProperties(RedisProperties.class) -@Import({ LettuceConnectionConfiguration.class, - JedisConnectionConfiguration.class }) +@Import({ LettuceConnectionConfiguration.class, JedisConnectionConfiguration.class }) public class RedisAutoConfiguration { @Bean @ConditionalOnMissingBean(name = "redisTemplate") public RedisTemplate redisTemplate( - RedisConnectionFactory redisConnectionFactory) - throws UnknownHostException { + RedisConnectionFactory redisConnectionFactory) throws UnknownHostException { RedisTemplate template = new RedisTemplate<>(); template.setConnectionFactory(redisConnectionFactory); return template; @@ -63,8 +61,7 @@ public class RedisAutoConfiguration { @Bean @ConditionalOnMissingBean(StringRedisTemplate.class) public StringRedisTemplate stringRedisTemplate( - RedisConnectionFactory redisConnectionFactory) - throws UnknownHostException { + RedisConnectionFactory redisConnectionFactory) throws UnknownHostException { StringRedisTemplate template = new StringRedisTemplate(); template.setConnectionFactory(redisConnectionFactory); return template; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerProperties.java index c4fbdd7bc6..07d493362c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerProperties.java @@ -200,11 +200,9 @@ public class ResourceServerProperties implements BeanFactoryAware { // resource token services return; } - if (!StringUtils.hasText(this.clientId)) { return; } - BindingResult result = getBindingResult(); if (result.hasErrors()) { throw new BindException(result); @@ -217,12 +215,11 @@ public class ResourceServerProperties implements BeanFactoryAware { } private BindingResult getBindingResult() { - BindingResult errors = new BeanPropertyBindingResult(this, "resourceServerProperties"); - + BindingResult errors = new BeanPropertyBindingResult(this, + "resourceServerProperties"); boolean jwtConfigPresent = StringUtils.hasText(this.jwt.getKeyUri()) || StringUtils.hasText(this.jwt.getKeyValue()); boolean jwkConfigPresent = StringUtils.hasText(this.jwk.getKeySetUri()); - if (jwtConfigPresent && jwkConfigPresent) { errors.reject("ambiguous.keyUri", "Only one of jwt.keyUri (or jwt.keyValue) and jwk.keySetUri should" diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java index 2311e45563..182259abbd 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java @@ -96,8 +96,7 @@ public class RedisAutoConfigurationJedisTests { assertThat(cf.getPoolConfig().getMinIdle()).isEqualTo(1); assertThat(cf.getPoolConfig().getMaxIdle()).isEqualTo(4); assertThat(cf.getPoolConfig().getMaxTotal()).isEqualTo(16); - assertThat(cf.getPoolConfig().getMaxWaitMillis()) - .isEqualTo(2000); + assertThat(cf.getPoolConfig().getMaxWaitMillis()).isEqualTo(2000); } @Test diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java index f878064764..1dfe9ac2a2 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java @@ -70,7 +70,8 @@ public class RedisAutoConfigurationTests { @Test public void testOverrideRedisConfiguration() { load("spring.redis.host:foo", "spring.redis.database:1"); - LettuceConnectionFactory cf = this.context.getBean(LettuceConnectionFactory.class); + LettuceConnectionFactory cf = this.context + .getBean(LettuceConnectionFactory.class); assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(cf.getDatabase()).isEqualTo(1); assertThat(cf.getPassword()).isNull(); @@ -81,7 +82,8 @@ public class RedisAutoConfigurationTests { public void testRedisUrlConfiguration() throws Exception { load("spring.redis.host:foo", "spring.redis.url:redis://user:password@example:33"); - LettuceConnectionFactory cf = this.context.getBean(LettuceConnectionFactory.class); + LettuceConnectionFactory cf = this.context + .getBean(LettuceConnectionFactory.class); assertThat(cf.getHostName()).isEqualTo("example"); assertThat(cf.getPort()).isEqualTo(33); assertThat(cf.getPassword()).isEqualTo("password"); @@ -93,7 +95,8 @@ public class RedisAutoConfigurationTests { load("spring.redis.host:foo", "spring.redis.password:xyz", "spring.redis.port:1000", "spring.redis.ssl:false", "spring.redis.url:rediss://user:password@example:33"); - LettuceConnectionFactory cf = this.context.getBean(LettuceConnectionFactory.class); + LettuceConnectionFactory cf = this.context + .getBean(LettuceConnectionFactory.class); assertThat(cf.getHostName()).isEqualTo("example"); assertThat(cf.getPort()).isEqualTo(33); assertThat(cf.getPassword()).isEqualTo("password"); @@ -106,7 +109,8 @@ public class RedisAutoConfigurationTests { "spring.redis.lettuce.pool.max-idle:4", "spring.redis.lettuce.pool.max-active:16", "spring.redis.lettuce.pool.max-wait:2000"); - LettuceConnectionFactory cf = this.context.getBean(LettuceConnectionFactory.class); + LettuceConnectionFactory cf = this.context + .getBean(LettuceConnectionFactory.class); assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(getDefaultLettucePool(cf).getHostName()).isEqualTo("foo"); assertThat(getDefaultLettucePool(cf).getPoolConfig().getMinIdle()).isEqualTo(1); @@ -119,7 +123,8 @@ public class RedisAutoConfigurationTests { @Test public void testRedisConfigurationWithTimeout() throws Exception { load("spring.redis.host:foo", "spring.redis.timeout:100"); - LettuceConnectionFactory cf = this.context.getBean(LettuceConnectionFactory.class); + LettuceConnectionFactory cf = this.context + .getBean(LettuceConnectionFactory.class); assertThat(cf.getHostName()).isEqualTo("foo"); assertThat(cf.getTimeout()).isEqualTo(100); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerPropertiesTests.java index bcc6c7378d..9ca41fa384 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerPropertiesTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerPropertiesTests.java @@ -78,8 +78,8 @@ public class ResourceServerPropertiesTests { this.properties.getJwt().setKeyUri("http://my-auth-server/token_key"); setListableBeanFactory(); this.thrown.expect(BindException.class); - this.thrown.expect(getMatcher("Only one of jwt.keyUri (or jwt.keyValue) " + - "and jwk.keySetUri should be configured.", null)); + this.thrown.expect(getMatcher("Only one of jwt.keyUri (or jwt.keyValue) " + + "and jwk.keySetUri should be configured.", null)); this.properties.validate(); } @@ -89,10 +89,9 @@ public class ResourceServerPropertiesTests { this.properties.getJwk().setKeySetUri("http://my-auth-server/token_keys"); this.properties.getJwt().setKeyValue("my-key"); setListableBeanFactory(); - this.thrown.expect(BindException.class); - this.thrown.expect(getMatcher("Only one of jwt.keyUri (or jwt.keyValue) " + - "and jwk.keySetUri should be configured.", null)); + this.thrown.expect(getMatcher("Only one of jwt.keyUri (or jwt.keyValue) " + + "and jwk.keySetUri should be configured.", null)); this.properties.validate(); } @@ -127,8 +126,8 @@ public class ResourceServerPropertiesTests { throws Exception { setListableBeanFactory(); this.thrown.expect(BindException.class); - this.thrown.expect(getMatcher("Missing tokenInfoUri and userInfoUri and there" + - " is no JWT verifier key", "tokenInfoUri")); + this.thrown.expect(getMatcher("Missing tokenInfoUri and userInfoUri and there" + + " is no JWT verifier key", "tokenInfoUri")); this.properties.validate(); } @@ -201,6 +200,7 @@ public class ResourceServerPropertiesTests { private BaseMatcher getMatcher(String message, String field) { return new BaseMatcher() { + @Override public void describeTo(Description description) { @@ -217,6 +217,7 @@ public class ResourceServerPropertiesTests { String fieldErrors = ((FieldError) error).getField(); return messageMatches && fieldErrors.equals(field); } + }; } diff --git a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzer.java b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzer.java index bde3fac3c0..0abe42df54 100644 --- a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzer.java +++ b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzer.java @@ -26,7 +26,8 @@ import org.springframework.util.StringUtils; /** * An {@link AbstractFailureAnalyzer} that performs analysis of failures caused by a - * {@link BindException} excluding {@link BindValidationException} and {@link UnboundConfigurationPropertiesException}. + * {@link BindException} excluding {@link BindValidationException} and + * {@link UnboundConfigurationPropertiesException}. * * @author Andy Wilkinson * @author Madhura Bhave @@ -36,8 +37,8 @@ class BindFailureAnalyzer extends AbstractFailureAnalyzer { @Override protected FailureAnalysis analyze(Throwable rootFailure, BindException cause) { Throwable rootCause = cause.getCause(); - if (rootCause instanceof BindValidationException || - rootCause instanceof UnboundConfigurationPropertiesException) { + if (rootCause instanceof BindValidationException + || rootCause instanceof UnboundConfigurationPropertiesException) { return null; } return analyzeGenericBindException(cause); diff --git a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzer.java b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzer.java index 9327cc30f3..7d9a792751 100644 --- a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzer.java +++ b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzer.java @@ -27,12 +27,13 @@ import org.springframework.validation.FieldError; import org.springframework.validation.ObjectError; /** - * An {@link AbstractFailureAnalyzer} that performs analysis of any bind validation failures - * caused by {@link BindValidationException} or {@link org.springframework.validation.BindException}. + * An {@link AbstractFailureAnalyzer} that performs analysis of any bind validation + * failures caused by {@link BindValidationException} or + * {@link org.springframework.validation.BindException}. * * @author Madhura Bhave */ -public class BindValidationFailureAnalyzer extends AbstractFailureAnalyzer { +class BindValidationFailureAnalyzer extends AbstractFailureAnalyzer { @Override protected FailureAnalysis analyze(Throwable rootFailure, Throwable cause) { @@ -44,13 +45,16 @@ public class BindValidationFailureAnalyzer extends AbstractFailureAnalyzer errors = validationException.getValidationErrors().getAllErrors(); + List errors = validationException.getValidationErrors() + .getAllErrors(); return new ExceptionDetails(errors, target, validationException); } - org.springframework.validation.BindException bindException = findCause(rootFailure, org.springframework.validation.BindException.class); + org.springframework.validation.BindException bindException = findCause( + rootFailure, org.springframework.validation.BindException.class); if (bindException != null) { List errors = bindException.getAllErrors(); return new ExceptionDetails(errors, bindException.getTarget(), bindException); @@ -111,6 +115,7 @@ public class BindValidationFailureAnalyzer extends AbstractFailureAnalyzer { +class UnboundConfigurationPropertyFailureAnalyzer + extends AbstractFailureAnalyzer { @Override - protected FailureAnalysis analyze(Throwable rootFailure, UnboundConfigurationPropertiesException cause) { + protected FailureAnalysis analyze(Throwable rootFailure, + UnboundConfigurationPropertiesException cause) { BindException exception = findCause(rootFailure, BindException.class); return analyzeUnboundConfigurationPropertiesException(exception, cause); } diff --git a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java index 253cbf1d4e..669c0613d6 100644 --- a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java @@ -91,10 +91,13 @@ public class BindValidationFailureAnalyzerTests { @Test public void otherBindExceptionShouldReturnAnalysis() throws Exception { - BindException cause = new BindException(new FieldValidationFailureProperties(), "fieldValidationFailureProperties"); + BindException cause = new BindException(new FieldValidationFailureProperties(), + "fieldValidationFailureProperties"); cause.addError(new FieldError("test", "value", "may not be null")); - BeanCreationException rootFailure = new BeanCreationException("bean creation failure", cause); - FailureAnalysis analysis = new BindValidationFailureAnalyzer().analyze(rootFailure, rootFailure); + BeanCreationException rootFailure = new BeanCreationException( + "bean creation failure", cause); + FailureAnalysis analysis = new BindValidationFailureAnalyzer() + .analyze(rootFailure, rootFailure); assertThat(analysis.getDescription()) .contains(failure("test.value", "null", "may not be null")); } diff --git a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java index af153a8e60..3bddd530ed 100644 --- a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java @@ -122,6 +122,7 @@ public class UnboundConfigurationPropertyFailureAnalyzerTests { public void setListValue(List listValue) { this.listValue = listValue; } + } }