Commit Graph

2214 Commits

Author SHA1 Message Date
Andy Wilkinson 303edac6bb Merge branch '2.3.x' into 2.4.x
Closes gh-26826
2021-06-09 09:13:06 +01:00
Andy Wilkinson d1e1796f76 Consider overridden getRootUri() when getting root URI
Fixes gh-26812
2021-06-09 09:12:37 +01:00
Phillip Webb 4d62e47c5d Merge branch '2.3.x' into 2.4.x 2021-06-08 18:05:12 -07:00
Phillip Webb 9e1c78da99 Update copyright year of changed files 2021-06-08 18:03:46 -07:00
Phillip Webb 7396e1e743 Fix property ordering within '.' and '/config'
Allow groups to be used with standard locations so that order of
profile-specific files is consistent.

Prior to this commit, the default search locations considered for
application properties/yaml files was the following:

	optional:classpath:/
	optional:classpath:/config/
	optional:file:./
	optional:file:./config/
	optional:file:./config/*/

Each of these locations was independent which could cause confusion
if certain combinations were used. For example, if profile-specific
files were added to `classpath:/` and `classpath:/config/` then the
latter would always override the former regardless of the profile
ordering.

This commit updates `StandardConfigDataLocationResolver` so that a
group of locations can be specified for each item. This allows us to
define the following set of search locations which provide more logical
ordering for profile-specific files

	optional:classpath:/;optional:classpath:/config/
	optional:file:./;optional:file:./config/;optional:file:./config/*/

Closes gh-26593
2021-06-06 21:05:54 -07:00
Phillip Webb 0da0d2d469 Prevent nested profile-specific resolution
Update the `ConfigDataEnvironment` so that the `resolveProfileSpecific`
method of `ConfigDataLocationResolver` is no longer called when
resolving imports declared in a profile-specific file.

Fixes gh-26753
2021-06-03 22:24:01 -07:00
Phillip Webb d1b256a169 Prevent indirect standard profile-specific imports
Update `StandardConfigDataLocationResolver` so that profile-specific
imports can only be used when there is no parent import.

Prior to this commit, given the following application.properties file:

	spring.profiles.active=p1,p2
	spring.config.import=other.properties

We would attempt to import `other.properties`, `other-p1.properties`
and `other-p2.properties`. This seems quite confusing and when we really
only need to support profile-specific properties for the initial root
set of locations.

Fixes gh-26752
2021-06-03 22:22:44 -07:00
Madhura Bhave b102fdd392 Merge branch '2.3.x' into 2.4.x
Closes gh-26738
2021-06-02 12:02:11 -07:00
Madhura Bhave 15324956a8 Align int and long in RandomValuePropertySource
This commit aligns int and long so that a random number is generated
by delegating to ints/longs in the JDK's Random API. In the case of a
single bound value, it needs to be greater than 0 because 0 is used as
the lower bound.

Fixes gh-26628
2021-06-02 12:00:25 -07:00
Stephane Nicoll c8959180fe Merge branch '2.3.x' into 2.4.x
Closes gh-26724
2021-06-01 15:38:27 +02:00
Stephane Nicoll 7e4defbcba Properly guard LogbackLoggingSystem
Previously, LoggingSystem#get would chose Logback by the sole presence
of a class in logback-core, with the assumption that logback-classic is
also on the classpath. An app that only had the former would therefore
fail.

This commit updates the condition to check for a class in
logback-classic instead.

Closes gh-26711
2021-06-01 15:35:22 +02:00
Phillip Webb 8661f74f2e Revert "Test optional directories without sub-directories"
This reverts commit 3f858ed8a4
since the test already existed.
2021-05-27 11:48:58 -07:00
Phillip Webb 3f858ed8a4 Test optional directories without sub-directories
Add an additional test to ensure that optional wildcard
directory patterns do not fail.

See gh-26677
2021-05-26 21:31:14 -07:00
izeye 38b9a833bd Fix "Allow optional directories without sub-directories"
Fix the update to `resolvePatternEmptyDirectories` introduced in
commit 01dd68e29e which was incorrectly checking `isOptional`.

See gh-26677
2021-05-26 21:19:05 -07:00
Andy Wilkinson 01dd68e29e Allow optional directories without sub-directories
Update `StandardConfigDataLocationResolver` so that directory resources
are only required when the location is not optional.

Closes gh-26627

Co-authored-by: Phillip Webb <pwebb@vmware.com>
2021-05-25 19:36:50 -07:00
Stephane Nicoll 9ff372c915 Merge branch '2.3.x' into 2.4.x
Closes gh-26653
2021-05-25 10:37:40 +02:00
Stephane Nicoll b5ebf836e3 Document spring.profiles.default
Closes gh-26592
2021-05-25 10:32:59 +02:00
Madhura Bhave 80610fa250 Restore order of additional and active profiles
This commit restores the order of additional and active profiles
so that active profiles now take precedence.

Fixes gh-26189
2021-05-19 13:21:03 -07:00
Andy Wilkinson 64e76badc2 Merge branch '2.3.x' into 2.4.x
Closes gh-26607
2021-05-19 19:03:12 +01:00
Andy Wilkinson b6e860b2d4 Prevent Jetty from delaying shutdown beyond grace period
Fixes gh-22689
2021-05-19 19:02:24 +01:00
Andy Wilkinson 6874c42d3c Merge branch '2.3.x' into 2.4.x
Closes gh-26605
2021-05-19 16:46:09 +01:00
Andy Wilkinson 2a89b11df3 Exclude SmartInitializingSingletones from lazy initialization
Fixes gh-26470
2021-05-19 16:26:48 +01:00
Phillip Webb 0e3ef4071e Allow optional ConfigDataLocationResolver results
Update `ConfigData` so that it signal if is considered optional. This
update allows `ConfigDataLocationResolvers` to return results that
behave in the same way as `optional:` prefixed locations without the
user themselves needing to prefix the location string.

Closes gh-25894
2021-05-17 21:31:58 -07:00
Madhura Bhave c45bb2bd95 Handle empty locations from patterns
Update `StandardConfigDataLocationResolver` to deal with patterns when
resolving empty directories. This update also fixes the handling of
mandatory pattern locations which would previously throw an exception.

The error message returned when a location with a pattern does not
contain any subdirectories has also been improved.

Fixes gh-26468
Fixes gh-26577
Fixes gh-26415
2021-05-17 16:23:46 -07:00
Madhura Bhave cfa26735d2 Merge programmatically set active profiles
Update `Profiles` so that any profiles set programmatically on the
`Environment` are merged with `spring.profiles.active` properties.

Fixes gh-26151

Co-authored-by: Phillip Webb <pwebb@vmware.com>
2021-05-17 13:29:12 -07:00
Andy Wilkinson 4eab9476a6 Polish "Detect use of spring.profiles.include as a YAML list"
See gh-26205
2021-05-17 14:13:29 +01:00
ChangYong 80ad6385f1 Detect use of spring.profiles.include as a YAML list
See gh-26205
2021-05-17 14:04:51 +01:00
Andy Wilkinson 1d5abf5af7 Merge branch '2.3.x' into 2.4.x
Closes gh-26572
2021-05-17 13:49:25 +01:00
Andy Wilkinson eecb7dd101 Remove stale jboss-transaction-spi dependencies
Closes gh-26569
2021-05-17 13:49:16 +01:00
Andy Wilkinson 9f279e0e96 Merge branch '2.3.x' into 2.4.x
Closes gh-26462
2021-05-14 13:45:29 +01:00
Andy Wilkinson 5984d4ee2b Index @ConfigurationProperties so they can be found by scanning
Previously, @ConfigurationProperties was not annotated with @Indexed.
This meant that @ConfigurationPropertiesScan would not be able to
find them when the underlying
ClassPathScanningCandidateComponentProvider is using a
CandidateComponentsIndex.

This commit annotated @ConfigurationProperties with @Indexed so that
they can be found by index-based scanning.

Fixes gh-26459
2021-05-14 13:41:24 +01:00
Phillip Webb 73131e99da Make BufferingApplicationStartup thread safe
Update `BufferingApplicationStartup` to use thread safe data structures.

Prior to this commit, it was possible for calls from different threads
(for example due to request scope beans) to cause a
NoSuchElementException to be thrown.

Closes gh-25792
2021-05-13 23:35:36 -07:00
Madhura Bhave eff024b0ce Polish "Process additional profiles before config files processing"
See gh-25817
2021-05-11 15:04:34 -07:00
nguyensach 97fd9a7c77 Process additional profiles before config files processing
Additional profiles were being processed after config file processing
when legacy processing was used.
This commit also restores the order in which additional profiles are added
when legacy processing is used.
Active profiles take precedence over additional profiles.

See gh-25817
2021-05-11 15:03:36 -07:00
Phillip Webb efad44be43 Refine mandatory location checking logic
Update `ConfigDataEnvironment.checkMandatoryLocations` to use the
actual locations that were imported, including those that were skipped
because the related `ConfigDataResource` had already been imported by a
different location.

Prior to this commit, any location that was skipped because it had
already been imported would throw a `ConfigDataNotFoundException`.

Closes gh-26147

Co-authored-by: Scott Frederick <sfrederick@vmware.com>
Co-authored-by: Madhura Bhave <mbhave@vmware.com>
2021-05-06 19:50:41 -07:00
Phillip Webb fef62f784a Import profile specific files in correct order
Update `StandardConfigDataLoader` to mark profile specific files with
`Option.PROFILE` so that they are added in the correct order. This is
a variation of the same issue described in commit 5774ea3f0c.

Closes gh-26400

Co-authored-by: Scott Frederick <sfrederick@vmware.com>
Co-authored-by: Madhura Bhave <mbhave@vmware.com>
2021-05-06 19:43:40 -07:00
Scott Frederick 922517c0e5 Polish 2021-05-06 19:43:31 -07:00
Scott Frederick dbee0cf9f1 Ignore empty values in config location properties
This commit updates config data property binding to ignore empty
elements in `spring.config.location` and `spring.config.import`
property values when a value is a comma-delimited string
representing a collection.

Fixes gh-26342
2021-05-03 14:52:22 -05:00
Stephane Nicoll 4ccce2a74f Merge branch '2.3.x' into 2.4.x
Closes gh-26322
2021-04-30 13:32:40 +02:00
Stephane Nicoll a6e59b357f Polish "Improve failure analysis with a single bean cycle"
See gh-26292
2021-04-30 13:30:58 +02:00
Roman Zabaluev 044c902a8c Improve failure analysis with a single bean cycle
See gh-26292
2021-04-30 13:18:13 +02:00
Stephane Nicoll 63d486158d Merge branch '2.3.x' into 2.4.x
Closes gh-26317
2021-04-30 08:53:20 +02:00
Stephane Nicoll 3f528bb0eb Mark SpringBootConfiguration as Indexed
Previously, users of the components.index could not use the index in
scenario where Spring Boot needs to locate the SpringBootConfiguration
to use to bootstrap the test context, as AnnotatedClassFinder scans
the classpath for that stereotype specifically and that requires a
dedicated entry for it.

This commit makes sure that a SpringBootConfiguration-annotated type has
a dedicated entry in the components index.

Closes gh-26308
2021-04-30 08:47:45 +02:00
Andy Wilkinson ffc06e1e30 Merge branch '2.3.x' into 2.4.x
Closes gh-26250
2021-04-27 11:51:29 +01:00
Andy Wilkinson 715c4febf9 Update maformed address to one that should fail on CI
Closes gh-26247
2021-04-27 11:50:52 +01:00
Stephane Nicoll 52543b84c1 Fix sourceType for spring.profiles.include
Closes gh-26163
2021-04-20 10:23:42 +02:00
Stephane Nicoll 2bd4ccce8a Document spring.profiles.group in configuration metadata
Closes gh-26127
2021-04-20 10:22:43 +02:00
Andy Wilkinson 0c30a5930d Polish "Use ConfigDataLocationResolvers' class loader to load resolver names"
See gh-26149
2021-04-19 10:23:27 +01:00
Sriram 4268f8da84 Use ConfigDataLocationResolvers' class loader to load resolver names
See gh-26149
2021-04-19 10:06:07 +01:00
Phillip Webb 302d500ee9 Add StandardConfigDataResource.getProfile method
Add a `StandardConfigDataResource.getProfile()` method so that it's
possible to tell the profile used when reading a profile specific
resource.

Fixes gh-25940
2021-04-15 12:01:34 -07:00