diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointMBeanExportProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointMBeanExportProperties.java index c7701cd6f2..557b5ac309 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointMBeanExportProperties.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointMBeanExportProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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. diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java index 7f4f86dbe1..76ccff5867 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java index c43dd79e47..c040016574 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java index 9532c1d192..344a63cd4e 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2015 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. diff --git a/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc b/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc index 05226419dd..dce0c18437 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc @@ -142,9 +142,9 @@ Their purpose is to load resources (`.class` files etc.) from nested jar files o files in directories (as opposed to explicitly on the classpath). In the case of the `[Jar|War]Launcher` the nested paths are fixed (`+lib/*.jar+` and `+lib-provided/*.jar+` for the war case) so you just add extra jars in those locations if you want more. The -`PropertiesLauncher` looks in `lib/` in your application archive by default, but you can add additional locations by -setting an environment variable `LOADER_PATH` or `loader.path` in `application.properties` -(comma-separated list of directories or archives). +`PropertiesLauncher` looks in `lib/` in your application archive by default, but you can +add additional locations by setting an environment variable `LOADER_PATH` or `loader.path` +in `application.properties` (comma-separated list of directories or archives). diff --git a/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/MultiProjectRepackagingTests.java b/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/MultiProjectRepackagingTests.java index 2666bc510a..21cc2d660b 100644 --- a/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/MultiProjectRepackagingTests.java +++ b/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/MultiProjectRepackagingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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,4 +76,5 @@ public class MultiProjectRepackagingTests { assertThat(jarFile.getEntry("lib/projectB.jar"), notNullValue()); jarFile.close(); } + } diff --git a/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/EmbeddedJarStarter.java b/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/EmbeddedJarStarter.java index 12936e2c70..5c29654a62 100644 --- a/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/EmbeddedJarStarter.java +++ b/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/EmbeddedJarStarter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2015 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. @@ -21,7 +21,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext /** * Main class to start the embedded server. * - * @author Phillip Webb + * @author Dave Syer */ public final class EmbeddedJarStarter { @@ -30,4 +30,5 @@ public final class EmbeddedJarStarter { context.getBean(SpringConfiguration.class).run(args); context.close(); } + } diff --git a/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/SpringConfiguration.java b/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/SpringConfiguration.java index 54e39662f2..5396340644 100644 --- a/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/SpringConfiguration.java +++ b/spring-boot-tools/spring-boot-loader/src/it/executable-props/src/main/java/org/springframework/launcher/it/props/SpringConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2015 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,19 +27,19 @@ import org.springframework.core.io.support.PropertiesLoaderUtils; /** * Spring configuration. * - * @author Phillip Webb + * @author Dave Syer */ @Configuration @ComponentScan public class SpringConfiguration { - + private String message = "Jar"; - + @PostConstruct public void init() throws IOException { String value = PropertiesLoaderUtils.loadAllProperties("application.properties").getProperty("message"); if (value!=null) { - this.message = value; + this.message = value; } } @@ -48,6 +48,4 @@ public class SpringConfiguration { System.err.println("Hello Embedded " + this.message + "!"); } - - } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 2cd66f0073..75f0f16c65 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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. @@ -553,7 +553,7 @@ public class PropertiesLauncher extends Launcher { urls.addAll(index + 1, extra); } } - catch (Exception e) { + catch (Exception ex) { // ignore } } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java index c802f9e78d..40df88f0e4 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/web/ErrorPageFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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. @@ -272,7 +272,7 @@ public class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContaine private String message; - private boolean errorToSend = false; + private boolean hasErrorToSend = false; public ErrorWrapperResponse(HttpServletResponse response) { super(response); @@ -287,25 +287,23 @@ public class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContaine public void sendError(int status, String message) throws IOException { this.status = status; this.message = message; - this.errorToSend = true; + this.hasErrorToSend = true; // Do not call super because the container may prevent us from handling the // error ourselves } @Override public int getStatus() { - if (this.errorToSend) { + if (this.hasErrorToSend) { return this.status; } - else { - // If there was no error we need to trust the wrapped response - return super.getStatus(); - } + // If there was no error we need to trust the wrapped response + return super.getStatus(); } @Override public void flushBuffer() throws IOException { - if (this.errorToSend && !isCommitted()) { + if (this.hasErrorToSend && !isCommitted()) { ((HttpServletResponse) getResponse()) .sendError(this.status, this.message); } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java index 2f6ae29e7c..a3c9144d57 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java @@ -141,7 +141,7 @@ public class LoggingApplicationListener implements SmartApplicationListener { return isAssignableFrom(sourceType, SOURCE_TYPES); } - private boolean isAssignableFrom(Class type, Class[] supportedTypes) { + private boolean isAssignableFrom(Class type, Class... supportedTypes) { for (Class supportedType : supportedTypes) { if (supportedType.isAssignableFrom(type)) { return true; @@ -153,25 +153,32 @@ public class LoggingApplicationListener implements SmartApplicationListener { @Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationEnvironmentPreparedEvent) { - ApplicationEnvironmentPreparedEvent available = (ApplicationEnvironmentPreparedEvent) event; - initialize(available.getEnvironment(), available.getSpringApplication() - .getClassLoader()); + onApplicationEnvironmentPreparedEvent((ApplicationEnvironmentPreparedEvent) event); } else if (event instanceof ApplicationStartedEvent) { - if (System.getProperty(PID_KEY) == null) { - System.setProperty(PID_KEY, new ApplicationPid().toString()); - } - LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils - .getDefaultClassLoader()); - loggingSystem.beforeInitialize(); + onApplicationStartedEvent((ApplicationStartedEvent) event); } - else { - LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils - .getDefaultClassLoader()); - loggingSystem.cleanUp(); + else if (event instanceof ContextClosedEvent) { + onContextClosedEvent((ContextClosedEvent) event); } } + private void onApplicationEnvironmentPreparedEvent( + ApplicationEnvironmentPreparedEvent event) { + initialize(event.getEnvironment(), event.getSpringApplication().getClassLoader()); + } + + private void onApplicationStartedEvent(ApplicationStartedEvent event) { + if (System.getProperty(PID_KEY) == null) { + System.setProperty(PID_KEY, new ApplicationPid().toString()); + } + LoggingSystem.get(ClassUtils.getDefaultClassLoader()).beforeInitialize(); + } + + private void onContextClosedEvent(ContextClosedEvent event) { + LoggingSystem.get(ClassUtils.getDefaultClassLoader()).cleanUp(); + } + /** * Initialize the logging system according to preferences expressed through the * {@link Environment} and the classpath. diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java index 4749609bf6..1af2785da6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java @@ -67,7 +67,6 @@ public abstract class LoggingSystem { * should override this method to perform any logging system-specific cleanup. */ public void cleanUp() { - } /** diff --git a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterIntegrationTests.java b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterIntegrationTests.java index 34e5041ce7..66a9a3bfdb 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterIntegrationTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2015 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. @@ -55,6 +55,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; /** + * Integration tests for {@link ErrorPageFilter}. * * @author Dave Syer */ @@ -120,6 +121,7 @@ public class ErrorPageFilterIntegrationTests { public HelloWorldController helloWorldController() { return new HelloWorldController(); } + } @Controller diff --git a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java index 30fcce0556..f83be0f6c0 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/web/ErrorPageFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2015 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.