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
cb0069f3
Commit
cb0069f3
authored
Jan 06, 2021
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-24674
parents
45ca4a5a
5b126b01
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
14 deletions
+33
-14
ConfigDataEnvironment.java
...gframework/boot/context/config/ConfigDataEnvironment.java
+22
-12
ConfigDataEnvironmentPostProcessorBootstrapContextIntegrationTests.java
...ronmentPostProcessorBootstrapContextIntegrationTests.java
+2
-1
TestConfigDataBootstrap.java
...ramework/boot/context/config/TestConfigDataBootstrap.java
+5
-1
application-bootstrap-registry-integration-tests.properties
...plication-bootstrap-registry-integration-tests.properties
+4
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironment.java
View file @
cb0069f3
...
...
@@ -22,7 +22,6 @@ import java.util.Collections;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.function.Supplier
;
import
org.apache.commons.logging.Log
;
...
...
@@ -107,6 +106,10 @@ class ConfigDataEnvironment {
private
static
final
Bindable
<
List
<
String
>>
STRING_LIST
=
Bindable
.
listOf
(
String
.
class
);
private
static
final
BinderOption
[]
ALLOW_INACTIVE_BINDING
=
{};
private
static
final
BinderOption
[]
DENY_INACTIVE_BINDING
=
{
BinderOption
.
FAIL_ON_BIND_TO_INACTIVE_SOURCE
};
private
final
DeferredLogFactory
logFactory
;
private
final
Log
logger
;
...
...
@@ -222,25 +225,22 @@ class ConfigDataEnvironment {
void
processAndApply
()
{
ConfigDataImporter
importer
=
new
ConfigDataImporter
(
this
.
logFactory
,
this
.
notFoundAction
,
this
.
resolvers
,
this
.
loaders
);
registerBootstrapBinder
(
()
->
this
.
contributors
.
getBinder
(
null
,
BinderOption
.
FAIL_ON_BIND_TO_INACTIVE_SOURCE
)
);
registerBootstrapBinder
(
this
.
contributors
,
null
,
DENY_INACTIVE_BINDING
);
ConfigDataEnvironmentContributors
contributors
=
processInitial
(
this
.
contributors
,
importer
);
Binder
initialBinder
=
contributors
.
getBinder
(
null
,
BinderOption
.
FAIL_ON_BIND_TO_INACTIVE_SOURCE
);
registerBootstrapBinder
(()
->
initialBinder
);
ConfigDataActivationContext
activationContext
=
createActivationContext
(
initialBinder
);
ConfigDataActivationContext
activationContext
=
createActivationContext
(
contributors
.
getBinder
(
null
,
BinderOption
.
FAIL_ON_BIND_TO_INACTIVE_SOURCE
));
contributors
=
processWithoutProfiles
(
contributors
,
importer
,
activationContext
);
activationContext
=
withProfiles
(
contributors
,
activationContext
);
contributors
=
processWithProfiles
(
contributors
,
importer
,
activationContext
);
applyToEnvironment
(
contributors
,
activationContext
);
}
private
void
registerBootstrapBinder
(
Supplier
<
Binder
>
supplier
)
{
this
.
bootstrapContext
.
register
(
Binder
.
class
,
InstanceSupplier
.
from
(
supplier
).
withScope
(
Scope
.
PROTOTYPE
));
}
private
ConfigDataEnvironmentContributors
processInitial
(
ConfigDataEnvironmentContributors
contributors
,
ConfigDataImporter
importer
)
{
this
.
logger
.
trace
(
"Processing initial config data environment contributors without activation context"
);
return
contributors
.
withProcessedImports
(
importer
,
null
);
contributors
=
contributors
.
withProcessedImports
(
importer
,
null
);
registerBootstrapBinder
(
contributors
,
null
,
DENY_INACTIVE_BINDING
);
return
contributors
;
}
private
ConfigDataActivationContext
createActivationContext
(
Binder
initialBinder
)
{
...
...
@@ -259,7 +259,9 @@ class ConfigDataEnvironment {
private
ConfigDataEnvironmentContributors
processWithoutProfiles
(
ConfigDataEnvironmentContributors
contributors
,
ConfigDataImporter
importer
,
ConfigDataActivationContext
activationContext
)
{
this
.
logger
.
trace
(
"Processing config data environment contributors with initial activation context"
);
return
contributors
.
withProcessedImports
(
importer
,
activationContext
);
contributors
=
contributors
.
withProcessedImports
(
importer
,
activationContext
);
registerBootstrapBinder
(
contributors
,
activationContext
,
DENY_INACTIVE_BINDING
);
return
contributors
;
}
private
ConfigDataActivationContext
withProfiles
(
ConfigDataEnvironmentContributors
contributors
,
...
...
@@ -304,7 +306,15 @@ class ConfigDataEnvironment {
private
ConfigDataEnvironmentContributors
processWithProfiles
(
ConfigDataEnvironmentContributors
contributors
,
ConfigDataImporter
importer
,
ConfigDataActivationContext
activationContext
)
{
this
.
logger
.
trace
(
"Processing config data environment contributors with profile activation context"
);
return
contributors
.
withProcessedImports
(
importer
,
activationContext
);
contributors
=
contributors
.
withProcessedImports
(
importer
,
activationContext
);
registerBootstrapBinder
(
contributors
,
activationContext
,
ALLOW_INACTIVE_BINDING
);
return
contributors
;
}
private
void
registerBootstrapBinder
(
ConfigDataEnvironmentContributors
contributors
,
ConfigDataActivationContext
activationContext
,
BinderOption
...
binderOptions
)
{
this
.
bootstrapContext
.
register
(
Binder
.
class
,
InstanceSupplier
.
from
(()
->
contributors
.
getBinder
(
activationContext
,
binderOptions
)).
withScope
(
Scope
.
PROTOTYPE
));
}
private
void
applyToEnvironment
(
ConfigDataEnvironmentContributors
contributors
,
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorBootstrapContextIntegrationTests.java
View file @
cb0069f3
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -51,6 +51,7 @@ class ConfigDataEnvironmentPostProcessorBootstrapContextIntegrationTests {
LoaderHelper
bean
=
context
.
getBean
(
TestConfigDataBootstrap
.
LoaderHelper
.
class
);
assertThat
(
bean
).
isNotNull
();
assertThat
(
bean
.
getBound
()).
isEqualTo
(
"igotbound"
);
assertThat
(
bean
.
getProfileBound
()).
isEqualTo
(
"igotprofilebound"
);
assertThat
(
bean
.
getLocation
().
getResolverHelper
().
getLocation
())
.
isEqualTo
(
ConfigDataLocation
.
of
(
"testbootstrap:test"
));
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/TestConfigDataBootstrap.java
View file @
cb0069f3
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -121,6 +121,10 @@ class TestConfigDataBootstrap {
return
this
.
binder
.
get
().
bind
(
"myprop"
,
String
.
class
).
orElse
(
null
);
}
String
getProfileBound
()
{
return
this
.
binder
.
get
().
bind
(
"myprofileprop"
,
String
.
class
).
orElse
(
null
);
}
@Override
public
void
onApplicationEvent
(
BootstrapContextClosedEvent
event
)
{
event
.
getApplicationContext
().
getBeanFactory
().
registerSingleton
(
"loaderHelper"
,
this
);
...
...
spring-boot-project/spring-boot/src/test/resources/application-bootstrap-registry-integration-tests.properties
View file @
cb0069f3
spring.config.import
=
testbootstrap:test
spring.profiles.active
=
test
myprop
=
igotbound
#---
spring.config.activate.on-profile
=
test
myprofileprop
=
igotprofilebound
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