Commit Graph

68 Commits

Author SHA1 Message Date
Dave Syer
91f60b3f4c Be more selective with the property sources in a context refresh
We need to tread a very fine line. Ideally the process of refreshing
the Environment builds it back exactly as happened on startup.
In particular we probably don't want to have things like
application.properties already there when we start the process.

This change replaces the more liberal copy of all property sources
only a select few (actually only one), paremeterized as a constant.
2017-11-03 14:01:29 +00:00
Spencer Gibb
707787dc13 Adds test for bootstrap context parent closing 2017-10-30 19:13:36 -04:00
Dave Syer
942df8ed45 Remove lombok from spring-cloud-context 2017-10-24 08:49:10 +01:00
Dave Syer
1add1067df Fix ordering of property sources on refresh
If there were *no* bootstrapProperties (i.e. properties added by
PropertySourceLocators) on startup, and then in a refresh event
some new sources were picked up, they would have been added to the
end, instead of the beginning of the list.

Fixes https://github.com/spring-cloud/spring-cloud-config/issues/815
2017-10-19 13:41:05 +01:00
Dave Syer
ccf613c29c Make method accessible in GenericScope proxy target
Otherwise app crashes on first access of scoped proxy.

Fixes gh-261
2017-10-11 08:12:32 -04:00
Dave Syer
c28ca5de91 Add extra concurrency test for refresh scope
The test passes (would have failed in parent commit)
because a lock is taken in the scoped proxy itself, not
in the target.
2017-10-04 14:14:45 +01:00
Biju Kunjummen
5aaafb19af Replaces deprecated o.s.b.a.PropertyPlaceholderAutoConfiguration 2017-08-21 20:35:45 -07:00
Biju Kunjummen
a6b7f70b8e Show better message for missing config keystore props (#232)
* Show better message for missing config keystore props

* Removes unused ExpectedException

Fixes #230
2017-08-04 15:53:35 -04:00
Johannes Edmeier
94a42737ec Fix empty keys in EnvironmentChangedEvent on resetting the Environment (#229)
When the Environment is resetted the EnvironmentChangedEvent always
contains an empty keySet, since the live view of the cleared map was
used. This commit fixes this.
2017-07-25 11:58:15 -04:00
Spencer Gibb
c75673110b formatting 2017-06-30 17:47:08 -06:00
Fabio Matos
2e81db24cf Disables endpoint creation (#208)
Fixes gh-117
2017-06-30 19:38:03 -04:00
Spencer Gibb
922608651a fix test path 2017-05-01 09:27:37 -06:00
Spencer Gibb
b40ceef356 RefreshEventListener no longer depends on RefreshEndpoint.
Instead it depends on ContextRefresher with actually does the work.

This allows applications to use the listener even if they don't depend
on actuator.

fixes gh-171
2017-04-03 20:13:11 -06:00
Spencer Gibb
78d10fc223 Use relaxed property resolver in KeyCondition
Allows users to define properties like encrypt.key-store.password=letmein

fixes gh-191

(cherry picked from commit 7744b63)
2017-04-03 19:52:17 -06:00
Spencer Gibb
1eddbc125b fix compile errors in tests 2017-03-15 12:08:04 -06:00
Dave Syer
45b0c078eb Merge branch '1.1.x' 2017-03-15 12:18:14 +00:00
Dave Syer
ba281228f6 Apply bootstrap initializers to all contexts in a hierarchy
The fix for gh-153 was sensible, but has now exposed another issue
which is that the bootstrap initializers, whilst they are now only
created once, actually only get applied to the parent context
in a hierarchy.

Most of the time this doesn't matter because the child contexts all
benefit from environment changes and additional beans added
to the parent. If the children are supposed to actually have
different environments, though, there is a problem. So this change
locates the existing bootstrap context and applies it to each
new context created separately.

Unfortunately we have to use reflection to do that for now because
there is no way to discover the parent with a public API before
the context is refreshed.

See gh-190
2017-03-15 12:16:32 +00:00
Dave Syer
70d601df84 Register a BeanDefinition manually instead of using @Bean
For RefreshScope this stops Spring from moaning about the @Bean
method with a WARN log (which is benign but hard to get rid of
and confusing for users).

See gh-401
2017-03-15 12:15:51 +00:00
Spencer Gibb
1865bc6306 polish 2017-03-01 10:43:01 -07:00
Biju Kunjummen
4e0d2e520f Fixes possible infinite loop
Fixes edge case of an infinite loop in decrypting properties in a hierarchy of application contexts.


fixes gh-178
2017-03-01 12:41:00 -05:00
Dave Syer
d2ab1c6de9 Merge branch '1.1.x' 2017-02-24 09:42:36 +00:00
Dave Syer
331e790026 Ensure there is a single bootstrap parent context
Only one neds to be created, and once it is in place in the hierarchy
it should be usable by all the child contexts that get added.

Fixes gh-153
2017-02-24 09:38:30 +00:00
Spencer Gibb
dcaef01b27 Update to boot 1.5 test classes 2017-02-21 08:19:24 -07:00
Dave Syer
d5a63c988d Merge branch '1.1.x' 2017-02-21 10:18:29 +00:00
Dave Syer
8347c5741c Extract target from @ConfigurationProperties proxy
Fixes gh-175 (more of a workaround really and gh-177 is still open
to track further changes).
2017-02-21 10:01:05 +00:00
Spencer Gibb
a86356327c fix tests for boot 1.4.x 2017-02-14 14:23:27 -07:00
Spencer Gibb
5b8ae3a96a Make sure bootstrap sources are ordered before use.
Make call to sort() before setting on builder.sources().

fixes gh-176

(cherry picked from commit 6dc35d1)
2017-02-14 14:18:48 -07:00
Spencer Gibb
6dc35d1edc Make sure bootstrap sources are ordered before use.
Make call to sort() before setting on builder.sources().

fixes gh-176
2017-02-14 14:17:11 -07:00
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
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
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
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
Venil Noronha
b92016b260 Moved RefreshEndpoint logic to ContextRefresher.
Fixes gh-101
2016-04-01 15:03:30 -06: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
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
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
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