Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f81921c0
Commit
f81921c0
authored
Mar 05, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-25517
parents
5a0c3a84
8c220d6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
Bootstrapper.java
.../src/main/java/org/springframework/boot/Bootstrapper.java
+11
-0
SpringApplication.java
...main/java/org/springframework/boot/SpringApplication.java
+1
-1
SpringApplicationTests.java
...java/org/springframework/boot/SpringApplicationTests.java
+54
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/Bootstrapper.java
View file @
f81921c0
...
...
@@ -31,6 +31,17 @@ public interface Bootstrapper {
* Initialize the given {@link BootstrapRegistry} with any required registrations.
* @param registry the registry to initialize
*/
default
void
initialize
(
BootstrapRegistry
registry
)
{
intitialize
(
registry
);
}
/**
* Initialize the given {@link BootstrapRegistry} with any required registrations.
* @param registry the registry to initialize
* @deprecated since 2.4.4 in favor of
* {@link Bootstrapper#initialize(BootstrapRegistry)}
*/
@Deprecated
void
intitialize
(
BootstrapRegistry
registry
);
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
View file @
f81921c0
...
...
@@ -351,7 +351,7 @@ public class SpringApplication {
private
DefaultBootstrapContext
createBootstrapContext
()
{
DefaultBootstrapContext
bootstrapContext
=
new
DefaultBootstrapContext
();
this
.
bootstrappers
.
forEach
((
initializer
)
->
initializer
.
in
t
itialize
(
bootstrapContext
));
this
.
bootstrappers
.
forEach
((
initializer
)
->
initializer
.
initialize
(
bootstrapContext
));
return
bootstrapContext
;
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
View file @
f81921c0
...
...
@@ -1247,6 +1247,29 @@ class SpringApplicationTests {
assertThat
(
applicationContext
.
getBean
(
"test"
)).
isEqualTo
(
"boot"
);
}
@Test
void
whenABootstrapperImplementsOnlyTheOldMethodThenItIsCalled
()
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
OnlyOldMethodTestBootstrapper
bootstrapper
=
new
OnlyOldMethodTestBootstrapper
();
application
.
addBootstrapper
(
bootstrapper
);
try
(
ConfigurableApplicationContext
applicationContext
=
application
.
run
())
{
assertThat
(
bootstrapper
.
intitialized
).
isTrue
();
}
}
@Test
void
whenABootstrapperImplementsTheOldMethodAndTheNewMethodThenOnlyTheNewMethodIsCalled
()
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
BothMethodsTestBootstrapper
bootstrapper
=
new
BothMethodsTestBootstrapper
();
application
.
addBootstrapper
(
bootstrapper
);
try
(
ConfigurableApplicationContext
applicationContext
=
application
.
run
())
{
assertThat
(
bootstrapper
.
intitialized
).
isFalse
();
assertThat
(
bootstrapper
.
initialized
).
isTrue
();
}
}
@Test
void
settingEnvironmentPrefixViaPropertiesThrowsException
()
{
assertThatIllegalStateException
()
...
...
@@ -1735,4 +1758,35 @@ class SpringApplicationTests {
}
static
class
OnlyOldMethodTestBootstrapper
implements
Bootstrapper
{
private
boolean
intitialized
;
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
intitialize
(
BootstrapRegistry
registry
)
{
this
.
intitialized
=
true
;
}
}
static
class
BothMethodsTestBootstrapper
implements
Bootstrapper
{
private
boolean
intitialized
;
private
boolean
initialized
;
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
intitialize
(
BootstrapRegistry
registry
)
{
this
.
intitialized
=
true
;
}
@Override
public
void
initialize
(
BootstrapRegistry
registry
)
{
this
.
initialized
=
true
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment