Commit Graph

82 Commits

Author SHA1 Message Date
Matt Benson
941275ded2 consider spring.profiles.include values from bootstrap PropertySources (#123) 2017-01-26 12:14:43 -05:00
Spencer Gibb
210c7b9017 Update spring-cloud-build to 1.3.1.BUILD-SNAPSHOT 2017-01-09 18:25:48 -07:00
Matthew Reid
63e4e3b8d6 Allow lifecycle endpoints to be globally disabled using endpoints.enabled property (#148)
fixes gh-158
2017-01-09 14:37:48 -05:00
Anders Båtstrand
69192f6f67 Exposing context names, fixes https://github.com/spring-cloud/spring-cloud-netflix/issues/1585. 2017-01-04 11:00:51 +01:00
Ryan Baxter
8d3d07bde6 We no longer need InfoEndpointRebinderConfiguration since we will not be supporting Boot 1.3.x in Dalston. See #145. 2016-11-21 12:07:01 -05:00
Ryan Baxter
dde952982e Revert "Make sure we copy variables to new InfoEndpoint. Fixes #143."
This reverts commit 30f34cf3bc.
2016-11-21 12:01:31 -05:00
Ryan Baxter
0a6466d9c0 Revert "Added TODO to remove InfoEndpointRebinderConfiguration"
This reverts commit 2266cc9c1a.
2016-11-21 12:01:21 -05:00
Ryan Baxter
2266cc9c1a Added TODO to remove InfoEndpointRebinderConfiguration 2016-11-21 11:47:12 -05:00
Ryan Baxter
30f34cf3bc Make sure we copy variables to new InfoEndpoint. Fixes #143. 2016-11-21 11:47:12 -05:00
Dave Syer
d4fd2b7aa5 Extract logging system shutdown into a separate listener
LoggingSystemShutdownListener runs immediately after
BootstrapApplicationListener and contains the code which used to be
in that to clean up the logging system (and make it go dark). That
is still a little bit of a hack to work around some limitations in
the static logging libraries (via the Spring Boot Logging System
and LoggingApplicationListener).

If the LoggingApplicationListener is then *not* applied in the
ContextRefresher, then we don't need the LoggingSystemShutdownListener
either. In fact we can narrow down the ContextRefresher to be only
interested in the listeners that affect the Environment (of which
we know of only 2). It means that any listeners that are added that
affect the Environment will not be applied, but there are plenty of
more "official" channels for modifying the Environment
(EnvironmentPostProcessor and PropertySourceLocator), so users can
easily migrate to a better implementation.
2016-09-16 13:44:48 +01:00
Dave Syer
68c7fcf7d8 Apply correct ordering in logging system on startup
Completes the work started in 7f687b1, where the call to
LoggingSystem.beforeInitialization() was ommitted which results
in JUL logging never being available in the application.

Partial fix for #131 (but a /refresh is still broken)
2016-09-16 12:11:15 +01:00
Spencer Gibb
e13764db66 Fixes indexed properties merging problem.
Given the following in one property source
```
mine[0].someValue=Foo
mine[0].someKey={cipher}XXXX
mine[1].someValue=Bar
mine[1].someKey={cipher}XXXX
yours[0].anotherKey=Baz
```
only `mine[*].someKey` were added to "decrypted" property source. Due to house spring boot manages indexed properties, they can not be merged across property source. This change includes all indexed properties in the "decrypted" property source if any one of them is encrypted.

In the above example, `yours[*].*` is included even though unrelated.

fixes gh-466
2016-09-09 14:23:19 -06:00
Dave Syer
7f687b10e3 Adjust the logging lifecycle during bootstrap
Anticipating a change in Spring Boot 1.4.1 to support child context
creation without (needless) re-initialization of the logging system,
we need to carefully manage the lifecycle, in particular calling
cleanUp() when we know there are changes in the pipeline.

Fixes gh-125
2016-08-25 18:04:14 +01:00
Matt Benson
8281c829e2 correct GenericScope#setName() Javadoc (#124) 2016-08-17 13:26:00 -04:00
Dave Syer
ee56f22b20 Add comment about shutdown errors in context.close() 2016-06-01 12:06:28 +01:00
Dave Syer
31a2b3ea0e Make some tests more robust so they pass with BOot 1.4 as well
A couple of tests here make assumptions about the property source
names added using @IntegrationTest. If we are a bit more defensive
and search for a source with a matching name instead of grabbing
one by the precise name, we can have tests that pass in Boot 1.3
and 1.4.
2016-05-05 14:05:46 +01:00
Dave Syer
6f3cb2f132 Remove usage of deprecated code 2016-05-05 12:37:46 +01:00
Spencer Gibb
6e24ebd2f0 fix typo 2016-04-25 13:39:35 -06:00
Dave Syer
bda78f53a5 Add metadata manually for health endpoint 2016-04-25 15:35:56 +01:00
Dave Syer
c940192867 Switch off info endpoint rebinding in Spring Boot 1.4
The new info endpoint doesn't need special treatment to pick up
changes in the Environment, so we can just skip installing the
old bean that manipulates it.

Fixes gh-108
2016-04-20 11:27:40 +01:00
Dave Syer
b54c8e80e8 Add support for endpoints.env.post.enabled=false
Separately disable the POST /env from the GET. Fixes gh-106.
2016-04-18 10:04:56 +01:00
Dave Syer
1824a96968 Add conditional annotation to the refresh scope health indicator
i.e. management.health.refresh.enabled=false to disable

Fixes gh-106
2016-04-07 15:56:58 +01:00
Venil Noronha
b92016b260 Moved RefreshEndpoint logic to ContextRefresher.
Fixes gh-101
2016-04-01 15:03:30 -06:00
David Welch
072d6b40c7 Disable startup logging for Bootstrap environment
Fixes gh-100
2016-03-11 08:52:40 +00:00
Dave Syer
34c9b11284 Prevent possible memory leak with restart 2016-03-09 16:57:33 +00:00
Dave Syer
091b6af12a Sort bean names before generating serialization ID
Fixes gh-93
2016-03-09 16:57:33 +00:00
Dave Syer
7eccbc4bac Make LoggingRebinder case insensitive
Partly to account for the fact that Sprng Boot publishes config
meta data with lower case values (don't ask).
2016-03-04 09:22:03 +00:00
Dave Syer
1c430d4ff3 Add test for serialization ID in RefreshScope
It should be unique and deterministic by default.
2016-02-29 13:57:37 +00:00
Dave Syer
099953f795 Use system environment property source 2016-02-25 11:52:34 +00:00
Spencer Gibb
86ff712398 Properly close child contexts in destroy()
fixes gh-91
2016-02-22 10:49:54 -07:00
Dave Syer
624be9d19e Fix ordering of property sources
When the bootstrap properties are added back into the main Environment
we have to be careful that any source that is already there (such as
one that was added in a Spring Boot EnvironmentPostProcessor) is not
replaced in the wrong order.

Fixes gh-90
2016-02-15 10:25:19 +00:00
tc
bcb4e60448 Fix property source for decrypted variables
Use SystemEnvironmentPropertySource so that env vars can be
encrypted as well as property values (i.e. FOO_BAR will bind to
@Value("foo.bar")).

Fixes gh-89, fixes gh-87
2016-02-11 14:46:26 +00:00
Spencer Gibb
42b21d8399 Move RefreshEvent and Listener from consul/zk 2016-02-08 17:04:41 -07:00
Spencer Gibb
8a21f71ad1 Reuse pause and resume endpoints to the can be disabled.
fixes gh-86
2016-02-03 12:38:28 -07:00
Dave Syer
9c6aeba780 Ensure spring.main.sources is not used in refresh cycle
When the RefreshEndpoint makes a new Environment it creates a new
ApplicationContext with (hopefully) empty sources. If the user has
set spring.main.sources it won't be empty, so we should take care
to mask it off in the process.

Fixes gh-79
2016-02-02 21:55:19 +00:00
Dave Syer
6f463ad10d Add RefreshScopeHealthIndicator
Repots DOWN if there are errors in RefreshScope or
ConfigurationProperties rebinding, N.B. RefreshScope instantiates
its beans lazily after a refresh by default, so you won't see an
error until the bean is used.

Fixes gh-85
2016-02-02 17:28:52 +00:00
Dave Syer
5cfe42b9af Fix careless mistake in tests 2016-02-01 13:26:21 +00:00
Dave Syer
fb37883a92 Ensure BootstrapApplicationListener adds property sources on refresh
The fact that PropertySourceBootstrapConfiguration was re-using the
"bootstrap" property source name from the listener was a problem. The
listener has to be able to manage its own temporary property source name.

Fixes gh-83
2016-01-30 10:20:49 +00:00
Dave Syer
f550de7559 Only eagerly initialize refresh scope beans that are not lazy 2016-01-29 13:11:44 +00:00
Dave Syer
12b9bfbe12 Extract file-based property sources during bootstrap
The bootstrap.properties need to stick with the default properties
during the process of initializing the application.properties
otherwise the ordering ends up wrong because of the addLast()
semantics in an Environment merge. To do this is a bit ugly with
the additional constraint that the default properties has to
remain a MapPropertySource (so that other processors can append
to it if needed). So we created a custom extension of
MapPropertySource that also carries all the bootstrap properties
during the phase where the application.properties are being
processed, but unpacks them as soon as possible afterwards
in an ApplicationContextInitializer, preserving the order, but
making the bootstrap.properties available effectively for the
whole of the startup and initializaion phase of the main context.
2016-01-23 10:37:20 +00:00
Dave Syer
b4c2c14d68 Further paring down of leaky proeprty sources in Bootstrap phase
The biggest problem addressed here is one where an
EnvironmentPostProcessor (reasonably) adds entries to the
defaultProperties in the bootstrap context, but then that
property source is not merged with the parent, or is merged
too late (because it only happens when the application context
parent is set). The result would be that things that were activated
during bootstrap would be not be activated in the main context, or
would be activated too late (early enough for beans to bind to but
not for other listeners and post processors to get access to the
additional properties).

See https://github.com/spring-cloud/spring-cloud-sleuth/issues/126
2016-01-22 14:26:54 +00:00
Dave Syer
532cb8efc7 Simplify logic with boot strap property sources a bit
We only need one special name for a property source. In the end it
gets used twice, but this simplifies the logic a bit and ensures that
there is never a PropertySource with that name and things like
spring.application.name=bootstrap in it.
2016-01-22 12:27:56 +00:00
Dave Syer
14d54b1964 Eagerly instantiate @RefreshScope beans on startup
This ensures that any fetaures that require a bean to be instantiated
(for instance @Scheduled) behave the same for @RefreshScope and normal
singletons.

Fixes gh-74
2015-12-31 15:30:30 +00:00
Dave Syer
aaa7288bae Synchronize access to the ObjectFactory in GenericScope
Otherwise multiple instances of a scoped target can be created
if several threads need one at the same time. This isn't always
going to be a problem, but it breaks the singleton semantics, and
might lead to surprising results and/or performance issues if bean
creation is expensive.
2015-12-21 15:45:31 +00:00
Dave Syer
79b11df61f Take care with order of property sources in /refresh endpoint
It's kind of a corner case, but not a very small corner: if a /refresh
leads to a change in a key that was overridden from its default value (e.g.
n a profile-specific config file) then the key is not identified as changed.
The change is still applied.

This commit fixes the key computation and adds a couple of tests.

Fixes gh-73
2015-12-21 14:32:33 +00:00
Dave Syer
016224287f Re-order autoconfig: refresh scope can be used without actuator 2015-12-18 14:59:47 +00:00
Dave Syer
5e29312518 Reverse order of property sources before decrypting
Fixes gh-70
2015-12-18 10:04:27 +00:00
Spencer Gibb
7d86198b17 Migrate SpringClientFactory and FeignClientFactory functions
fixes gh-69
2015-12-17 14:25:15 -07:00
Dave Syer
c2b473adb0 Reverts 5d7f18f so that shutdown hook is owned by main context
Fixes gh-62, fixes gh-63
2015-12-04 14:11:47 +00:00
Dave Syer
96ec2d32ea Switch of shutdown hook in bootstrap
Fixes gh-61
2015-12-02 17:07:26 +00:00