diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java index 5415954889..694e926d25 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java @@ -20,7 +20,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -145,6 +144,17 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { this.beanDefinitions.clear(); } + private void updateTypesIfNecessary() { + this.beanFactory.getBeanNamesIterator().forEachRemaining((name) -> { + if (!this.beanTypes.containsKey(name)) { + addBeanType(name); + } + else { + updateBeanType(name); + } + }); + } + private void addBeanType(String name) { if (this.beanFactory.containsSingleton(name)) { this.beanTypes.put(name, this.beanFactory.getType(name)); @@ -161,13 +171,17 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { } } - private RootBeanDefinition getBeanDefinition(String name) { - try { - return (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(name); + private void updateBeanType(String name) { + if (this.beanFactory.isAlias(name) || this.beanFactory.containsSingleton(name)) { + return; } - catch (BeanDefinitionStoreException ex) { - logIgnoredError("unresolvable metadata in bean definition", name, ex); - return null; + RootBeanDefinition beanDefinition = getBeanDefinition(name); + if (beanDefinition == null) { + return; + } + RootBeanDefinition previous = this.beanDefinitions.put(name, beanDefinition); + if (previous != null && !beanDefinition.equals(previous)) { + addBeanTypeForNonAliasDefinition(name, beanDefinition); } } @@ -196,6 +210,16 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { } } + private RootBeanDefinition getBeanDefinition(String name) { + try { + return (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(name); + } + catch (BeanDefinitionStoreException ex) { + logIgnoredError("unresolvable metadata in bean definition", name, ex); + return null; + } + } + private void logIgnoredError(String message, String name, Exception ex) { if (logger.isDebugEnabled()) { logger.debug("Ignoring " + message + " '" + name + "'", ex); @@ -207,30 +231,6 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { && !this.beanFactory.containsSingleton(factoryBeanName)); } - private void updateTypesIfNecessary() { - Iterator names = this.beanFactory.getBeanNamesIterator(); - while (names.hasNext()) { - String name = names.next(); - if (!this.beanTypes.containsKey(name)) { - addBeanType(name); - } - else { - if (!this.beanFactory.isAlias(name) - && !this.beanFactory.containsSingleton(name)) { - RootBeanDefinition beanDefinition = getBeanDefinition(name); - if (beanDefinition != null) { - RootBeanDefinition existingDefinition = this.beanDefinitions - .put(name, beanDefinition); - if (existingDefinition != null - && !beanDefinition.equals(existingDefinition)) { - addBeanTypeForNonAliasDefinition(name, beanDefinition); - } - } - } - } - } - } - /** * Attempt to guess the type that a {@link FactoryBean} will return based on the * generics in its method signature. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java index 85e9ddfec5..6ae41a8f34 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java @@ -347,7 +347,6 @@ public class ConditionalOnBeanTests { public static class ConsumingConfiguration { ConsumingConfiguration(String testBean) { - } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java index 44797ca3ee..46d9600ea0 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java @@ -30,19 +30,16 @@ import java.util.zip.InflaterInputStream; */ class ZipInflaterInputStream extends InflaterInputStream { - private final Inflater inflater; + private int available; private boolean extraBytesWritten; - private int available; - ZipInflaterInputStream(InputStream inputStream, int size) { this(inputStream, new Inflater(true), size); } private ZipInflaterInputStream(InputStream inputStream, Inflater inflater, int size) { - super(inputStream, inflater, getInflaterBufferSize(size)); - this.inflater = inflater; + super(inputStream, new Inflater(true), getInflaterBufferSize(size)); this.available = size; } @@ -66,7 +63,7 @@ class ZipInflaterInputStream extends InflaterInputStream { @Override public void close() throws IOException { super.close(); - this.inflater.end(); + this.inf.end(); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java index 3ab1d65511..34d4c8f1a1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java @@ -48,24 +48,8 @@ class NoSuchMethodFailureAnalyzer extends AbstractFailureAnalyzer candidates, URL actual) { + StringWriter description = new StringWriter(); + PrintWriter writer = new PrintWriter(description); + writer.print("An attempt was made to call the method "); + writer.print(cause.getMessage()); + writer.print(" but it does not exist. Its class, "); + writer.print(className); + writer.println(", is available from the following locations:"); + writer.println(); + for (URL candidate : candidates) { + writer.print(" "); + writer.println(candidate); + } + writer.println(); + writer.println("It was loaded from the following location:"); + writer.println(); + writer.print(" "); + writer.println(actual); + return description.toString(); + } + } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index 1097a98584..72b32af3f9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -319,8 +319,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac private AccessLogHandler createAccessLogHandler(HttpHandler handler, AccessLogReceiver accessLogReceiver) { createAccessLogDirectoryIfNecessary(); - String formatString = ((this.accessLogPattern != null) ? this.accessLogPattern - : "common"); + String formatString = (this.accessLogPattern != null) ? this.accessLogPattern + : "common"; return new AccessLogHandler(handler, accessLogReceiver, formatString, Undertow.class.getClassLoader()); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java index 4f2a2429ca..34fcf1e657 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java @@ -196,7 +196,6 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit ((ConfigurableWebEnvironment) environment) .initPropertySources(this.servletContext, null); } - } @Override diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java index e1453474e7..a13bcfe66e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java @@ -30,7 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; /** - * @author awilkinson + * Tests for {@link NoSuchMethodFailureAnalyzer}. + * + * @author Andy Wilkinson */ @RunWith(ModifiedClassPathRunner.class) @ClassPathOverrides("javax.servlet:servlet-api:2.5")