From 997f07d13f9f04df4197411b32c7e4c2eedd2e9e Mon Sep 17 00:00:00 2001 From: ayudovin Date: Wed, 6 Mar 2019 00:33:49 +0300 Subject: [PATCH 1/2] Add default no-op method to SpringApplicationRunListener See gh-16104 --- .../boot/SpringApplicationRunListener.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java index f74df169ab..98833bcb35 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java @@ -31,6 +31,7 @@ import org.springframework.core.io.support.SpringFactoriesLoader; * @author Phillip Webb * @author Dave Syer * @author Andy Wilkinson + * @author Artsiom Yudovin */ public interface SpringApplicationRunListener { @@ -38,28 +39,32 @@ public interface SpringApplicationRunListener { * Called immediately when the run method has first started. Can be used for very * early initialization. */ - void starting(); + default void starting() { + } /** * Called once the environment has been prepared, but before the * {@link ApplicationContext} has been created. * @param environment the environment */ - void environmentPrepared(ConfigurableEnvironment environment); + default void environmentPrepared(ConfigurableEnvironment environment) { + } /** * Called once the {@link ApplicationContext} has been created and prepared, but * before sources have been loaded. * @param context the application context */ - void contextPrepared(ConfigurableApplicationContext context); + default void contextPrepared(ConfigurableApplicationContext context) { + } /** * Called once the application context has been loaded but before it has been * refreshed. * @param context the application context */ - void contextLoaded(ConfigurableApplicationContext context); + default void contextLoaded(ConfigurableApplicationContext context) { + } /** * The context has been refreshed and the application has started but @@ -68,7 +73,8 @@ public interface SpringApplicationRunListener { * @param context the application context. * @since 2.0.0 */ - void started(ConfigurableApplicationContext context); + default void started(ConfigurableApplicationContext context) { + } /** * Called immediately before the run method finishes, when the application context has @@ -77,7 +83,8 @@ public interface SpringApplicationRunListener { * @param context the application context. * @since 2.0.0 */ - void running(ConfigurableApplicationContext context); + default void running(ConfigurableApplicationContext context) { + } /** * Called when a failure occurs when running the application. @@ -86,6 +93,7 @@ public interface SpringApplicationRunListener { * @param exception the failure * @since 2.0.0 */ - void failed(ConfigurableApplicationContext context, Throwable exception); + default void failed(ConfigurableApplicationContext context, Throwable exception) { + } } From d6250250512008505982b6ff409fe283e20f5834 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sat, 16 Mar 2019 08:02:13 +0100 Subject: [PATCH 2/2] Polish "Add default no-op method to SpringApplicationRunListener" Closes gh-16104 --- .../org/springframework/boot/SpringApplicationRunListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java index 98833bcb35..0d396620c4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-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. @@ -31,7 +31,6 @@ import org.springframework.core.io.support.SpringFactoriesLoader; * @author Phillip Webb * @author Dave Syer * @author Andy Wilkinson - * @author Artsiom Yudovin */ public interface SpringApplicationRunListener {