Commit Graph

1716 Commits

Author SHA1 Message Date
Phillip Webb a84b7bccf1 Merge branch '2.2.x' 2020-05-27 19:19:51 -07:00
Phillip Webb 14c9804c5c Fix checkstyle issues 2020-05-27 19:19:11 -07:00
Phillip Webb 1c3f147c1e Merge branch '2.2.x'
Closes gh-21598
2020-05-27 16:47:40 -07:00
Phillip Webb af90604030 Merge branch '2.1.x' into 2.2.x
Closes gh-21597
2020-05-27 16:45:08 -07:00
Phillip Webb 587b840666 Restrict use of custom YAML types
Update `YamlJsonParser` and `OriginTrackedYamlLoader` to ensure that
custom types cannot be loaded.

Closes gh-21596
2020-05-27 16:36:46 -07:00
Andy Wilkinson f17f1255a4 Do not change availability on close unless context is active
Previously, an AvailabilityChangeEvent was published when the servlet
and reactive web server application contexts were closed, irrespective
of whether or not the context was active. This caused problems when
the context was not active due to a refresh failure as the event
publication could then trigger bean creation and post-processing that
relied upon beans that had been destroyed when cleaning up after the
refresh failure. The most commonly seen symptom was a missing
importRegistry bean that is required by ImportAwareBeanPostProcessor.

This commit updates the two web server application contexts to only
publish the availability change event if the context is active.

Fixes gh-21588
2020-05-27 20:05:45 +01:00
Stephane Nicoll 4317b29b9a Tolerate change in method format
This commit polishes the assertions of the NoSuchMethodError failure
analyzer as the method format changes according to the JDK.

See gh-21587
2020-05-27 15:25:50 +02:00
Stephane Nicoll 35121f182e Harmonize Period conversion support
Closes gh-21574
2020-05-27 14:48:32 +02:00
Andy Wilkinson 744b4d7c26 Include type hierarchy in NoSuchMethodError failure analysis
Closes gh-21587
2020-05-27 11:00:10 +01:00
Stephane Nicoll b21c09020d Polish "Polish duration support javadoc"
See gh-21579
2020-05-26 18:21:18 +02:00
OrangeDog 1a87fce416 Polish duration support javadoc
See gh-21579
2020-05-26 18:12:11 +02:00
dreis2211 62deec715f Avoid allocations in ConfigFileApplicationListener
See gh-21509
2020-05-20 17:38:17 -07:00
Scott Frederick c5fd09d06d Merge branch '2.2.x'
Closes gh-21522
2020-05-20 13:00:30 -05:00
Scott Frederick 4a812fc29c Fix log name in ServletWebServerApplicationContext
Fixes gh-21354
2020-05-20 12:59:13 -05:00
Andy Wilkinson beb7cb4b81 Preserve property ordering in SpringIterableConfigurationPropertySource
Fixes gh-21470
2020-05-18 15:16:10 +01:00
wonwoo 25723be26f Polish
See gh-21481
2020-05-18 12:22:13 +01:00
Andy Wilkinson d0f16d6fe6 Merge branch '2.2.x'
Closes gh-21450
2020-05-14 12:53:04 +01:00
Andy Wilkinson b78e4dacec Work around file handle leak when Undertow is stopped
There's a bug in Undertow that means it may leak a file handle is
the server is stopped immediately after a response to an SSL request
has been received. The stop processing races with Undertow's SSL
support tidying things up after sending the response. When the stop
processing wins, the tidying up fails with a NullPointerException that
prevents an input stream from being closed. On Windows, the input
stream remaining open prevents JUnit from being able to clean up its
temporary directory.

This commit uses Awaitility to wait for the file that's being served
over SSL to be deleted before stopping the server. On Windows, this
will delay the stop processing from beginning until after the tidy up
that's performed after sending the response has been completed,
hopefully eliminating the race condition that resulted in the input
stream being left open.

Fixes gh-21172
2020-05-14 12:45:37 +01:00
Phillip Webb 038ae93406 Update copyright year of changed files 2020-05-13 16:48:51 -07:00
Phillip Webb 12381467da Polish 2020-05-13 16:48:51 -07:00
Andy Wilkinson 8b6cdbb977 Deregister JDBC drivers when deployed war's ServletContext is destroyed
Closes gh-21221
2020-05-13 17:46:37 +01:00
Andy Wilkinson 4169724b86 Disable test that is flaky due to Reactor Netty problem
See gh-21437
2020-05-13 14:59:05 +01:00
Phillip Webb 0607af870d Improve ConfigurationPropertySource performance
Further improve the performance of `containsDescendantOf` by using
a Map to limit the number of candidates that need checking.

Closes gh-21416
2020-05-12 20:17:06 -07:00
Phillip Webb 4af6e7ff99 Improve ConfigurationPropertySource performance
Attempt to improve the performance of the `ConfigurationPropertySource`
adapters `containsDescendantOf` method. The method now operates on
arrays rather than iterators and reduces the inner for-loop when
possible.

See gh-21416
2020-05-12 16:44:57 -07:00
Andy Wilkinson 4c4097a29b Address flakiness in TomcatServletWebServerFactoryTests 2020-05-12 22:41:56 +01:00
Andy Wilkinson 8cf56069d2 Allow more time for shutdown result callback to be received
5 seconds isn't always sufficient, particularly on CI where the timing
can be quite variable.
2020-05-12 22:25:41 +01:00
Andy Wilkinson 86e6ec04b2 Fix hang caused by race condition in test for reset of kept-alive connection
Previously, a race between the server starting to reject requests
on a kept-alive connection and the request reaching the blocking
servlet could result in a response never being sent.

This commit updates the test to disable blocking once graceful
shutdown with an in-flight request has being. Awaitility is then used
to make a request on an idle kept-alive connection until it fails
due to the connection reset. This may not happen immediately due to
the aforementioned race.
2020-05-12 22:10:23 +01:00
Andy Wilkinson 240898121f Use SmartLifecycle for graceful web server shutdown
Closes gh-21325
2020-05-12 19:59:52 +01:00
Andy Wilkinson c42571ba40 Consolidate Undertow WebServers and simplify their constructors
Closes gh-21391

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-05-12 19:59:52 +01:00
Stephane Nicoll a6efe77a0c Polish "Calculate hashCode only once in ConfigurationPropertyName"
See gh-21394
2020-05-12 13:10:03 +02:00
Stephane Nicoll dd053074f8 Polish "Calculate hashCode only once in ConfigurationPropertyName"
See gh-21394
2020-05-12 10:05:32 +02:00
dreis2211 c9f6a126b7 Calculate hashCode only once in ConfigurationPropertyName
See gh-21394
2020-05-12 10:02:45 +02:00
Scott Frederick 158933c3e5 Improve API of ErrorAttributes and DefaultErrorAttributes
This commit improves the backward-compatibility of the ErrorAttributes
interfaces by providing a default implementation of a new method. It
also encapsulates several parameters that control the inclusion or
exclusion of error attributes into a new ErrorAttributeOptions type to
make it easier and less intrusive to add additional options in the
future. This encapsulation also makes the handling of the
includeException option more similar to other options.

Fixes gh-21324
2020-05-11 15:36:24 -05:00
Phillip Webb 7afd25fc9a Add ConfigurationPropertyCaching support
Add a `ConfigurationPropertyCaching` utility interface that can be
used to control the property source caching.

Prior to this commit, a `ConfigurationPropertySource` that was backed
by a mutable `EnumerablePropertySource` would need to call the
`getPropertyNames()` method each time a property was accessed. Since
this this operation can be expensive, we now provide a way to cache
the results for a specific length of time.

This commit also improves the performance of immutable property sources
by limiting the number of candidates that need to be searched.
Previously, all mapped names would be enumerated. Now, mappings are
grouped by `ConfigurationPropertyName`. This is especially helpful when
the `ConfigurationPropertyName` isn't mapped at all since the hash based
map lookup will be very fast and the resulting mappings will be empty.

Closes gh-20625
2020-05-07 15:22:24 -07:00
Phillip Webb 85e9a73e85 Add hashcode support to ConfigurationPropertyName
Provide a hashcode implementation for `ConfigurationPropertyName` so
that instances can be stored in Map without them all ending up in the
same bucket.

See gh-20625
2020-05-07 15:22:20 -07:00
Phillip Webb 5309912927 Test large property source performance
Add a test to ensure that a large number of property sources that each
contain many items can perform well.

See gh-20625
2020-05-07 15:22:10 -07:00
Phillip Webb 81058cab03 Allow clash in spring.config.name
Remove the recently added slash restriction since Spring Cloud
Config Server needs to support names with slashes.

See gh-21217
2020-05-07 07:56:01 -07:00
Phillip Webb 559c178637 Simplify regex expressions 2020-05-07 07:44:31 -07:00
Madhura Bhave 01404aa27b Merge branch '2.2.x'
Closes gh-21343
2020-05-06 16:00:24 -07:00
Madhura Bhave f29bce657e Harmonize default for server.tomcat.use-relative-redirects
Prior to this commit, the property was a Boolean with a null default.
If it was explicitly set by the user, a context customizer would use
that value to set it on the context. However, if it was not set, the default
wouldn't be tomcat's default but `false` because it was explicitly set to
`false` in `TomcatServletWebServerFactory`. This commit defaults the property
itself to `false` so that the default is more obvious to the user.

Fixes gh-20796
2020-05-06 15:54:27 -07:00
Madhura Bhave be7fe85b55 Polish 2020-05-06 15:35:44 -07:00
Phillip Webb b4963d2463 Fix legacy environment names in isAncestorOf
Fix the `SystemEnvironmentPropertyMapper.isAncestorOf` implementation
to convert names based on their dashed form and to silently ignore
any invalid results.

Closes gh-14479
2020-05-06 11:35:39 -07:00
Andy Wilkinson e03cb94190 Merge branch '2.2.x'
Closes gh-21327
2020-05-06 12:55:08 +01:00
Andy Wilkinson 9ba78db865 Allow Undertow to stop when a request is being handled
Previously, unlike embedded Jetty, Netty, and Tomcat, Undertow would
not stop when one of its worker threads was in use. This meant that a
a long-running or stalled request could prevent the application from
shutting down in response to SIGTERM or SIGINT, and SIGTERM would be
required to get the process to exit.

This commit updates the factories for the reactive and servlet
Undertow web server factories to configure Undertow to use a 0ms
shutdown timeout. This aligns it with the behaviour of Jetty, Netty,
and Tomcat. Tests have been introduced to verify the behaviour across
the reactive and servlet variants of all four supported embedded web
servers.

Fixes gh-21319
2020-05-06 12:23:37 +01:00
Phillip Webb 5ae623c43a Polish 'Add Period converter support'
Polish period converter support, primarily by changing
`PeriodStyle` to parse and print periods that include
more than one unit.

See gh-21136
2020-05-06 00:21:50 -07:00
Grubhart dc4d71f91e Add Period converter support
Add converter support for `javax.time.Period` including:

	String -> Period
	Number -> Period
	Period -> String

Period to Number conversion is not supported since `Period` has no
ability to deduce the number of calendar days in the period.

See gh-21136
2020-05-05 22:31:49 -07:00
Madhura Bhave a8f56b57cb Consider legacy environment names in isAncestorOf
Update the `isAncestorOf` method of SpringConfigurationPropertySources
so that legacy names are considered for the system environment.

Prior to this commit, binding a property such as `my.camelCase.prop`
would detect `MY_CAMELCASE_PROP` but not `MY_CAMEL_CASE_PROP` in
the system environment.

Fixes gh-14479

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-05-05 21:36:11 -07:00
Madhura Bhave 7634901fb3 Return null when getting a logback logger that does not exist
Closes gh-21292
2020-05-05 17:07:51 -07:00
Madhura Bhave f23d0501e4 Merge branch '2.2.x'
Closes gh-21323
2020-05-05 14:14:24 -07:00
Madhura Bhave 43e7ccd620 Detect log4j2-test.* files when using log4J2
Fixes gh-17001
2020-05-05 14:12:34 -07:00
Phillip Webb 365f65d214 Merge branch '2.2.x'
Closes gh-21321
2020-05-05 12:12:54 -07:00
Phillip Webb 98d27db767 Merge branch '2.1.x' into 2.2.x
Closes gh-21320
2020-05-05 12:12:31 -07:00
Phillip Webb df70c42f98 Allow classpath wildcards with Java 11 or above
Update `StaticResourceJars` to catch both `IOException` and
`InvalidPathException` when checking URLs. Prior to this commit only
`IOException` was caught which worked on Java 8 but not Java 11 or
above.

Fixes gh-21312
2020-05-05 12:10:31 -07:00
Phillip Webb 720d23af41 Further restrict configuration wildcard patterns
Extend wildcard restrictions to the `spring.config.name` property. Also
refine exception messages to include the property value.

Closes gh-21217
2020-05-05 10:27:35 -07:00
Andy Wilkinson f6d8c7d23c Simplify ReactiveWebServerApplicationContext.ServerManager
Closes gh-21315
2020-05-05 15:04:09 +01:00
Andy Wilkinson a688ac3f64 Improve testing of ReactiveWebServerApplicationContext
Closes gh-21314
2020-05-05 12:45:24 +01:00
Phillip Webb 9486842bad Merge branch '2.2.x'
Closes gh-21294
2020-05-01 18:31:14 -07:00
Phillip Webb 92ef515fbe Fix @DefaultValue PropertyEditor based conversion
Update `ValueObjectBinder` reattempt conversion if the `@DefaultValue`
contains a single element. Prior to this commit, single element
conversion relied on the `ArrayToObjectConverter` which isn't always
available.

Fixes gh-21264
2020-05-01 18:26:18 -07:00
Phillip Webb 07415e1603 Attempt to fix Windows CI test failure 2020-04-30 18:17:29 -07:00
Phillip Webb 57179c0d3d Add InputStreamSourceToByteArrayConverter
Add an `InputStreamSourceToByteArrayConverter` that can be used to
convert from an `InputStreamSource` (such as a `Resource`) to a
byte array.

Closes gh-21285
2020-04-30 16:40:05 -07:00
Phillip Webb d52bf83ab2 Polish 2020-04-30 16:40:05 -07:00
Madhura Bhave 8ec16bd027 Restrict wildcard pattern support for configuration files
This commit restricts how wildcards can be used in search
locations for property files. If a search location contains
a pattern, there must be only one '*' and the location should
end with a '*/'. For search locations that specify the file
name, the pattern should end with '*/<filename>'.

The list of files read from wildcard locations are now sorted
alphabetically according to the absolute path of the file.

Closes gh-21217
2020-04-30 14:17:44 -07:00
Scott Frederick a30740f8d2 Separate server properties for message and errors
Prior to this commit, there was a property server.error.include-details
that allowed configuration of the message and errors attributes in a
server error response.

This commit separates the control of the message and errors attributes
into two separate properties named server.error.include-message and
server.error.include-binding-errors. When the message attribute is
excluded from a servlet response, the value is changed from a
hard-coded text value to an empty value.

Fixes gh-20505
2020-04-29 17:56:47 -05:00
Brian Clozel 692a8c47cc Rename property for registering default Servlet
As a follow-up for gh-21214, this commit renames the property to:

`"server.servlet.register-default-servlet=false"`

Closes gh-21214
2020-04-29 18:42:50 +02:00
Brian Clozel c7c01f8ab4 Add property for registering default Servlet
This commit adds a new configuration property for configuring the
registration of the default Servlet in Servlet containers.

`"server.servlet.default-servlet.registered=false"`

The default of this property is still `true`, as it's been the case in
previous releases.

Closes gh-21214
2020-04-29 18:02:33 +02:00
Phillip Webb ad1248e4ec Replace "folder" with "directory"
Consistently use the term "directory" instead of "folder"

Closes gh-21218
2020-04-28 19:20:24 -07:00
Brian Clozel dac62476a0 Merge branch '2.2.x'
Closes gh-21208
2020-04-28 11:33:50 +02:00
Brian Clozel a63ab468a3 Upgrade to RSocket 1.0.0-RC7
This commit upgrades to RSocket 1.0.0-RC7.
This new RC brings API changes we have to adapt to. As of this commit,
we're introducing a new `RSocketServerCustomizer` which replaces the now
deprecated `ServerRSocketFactoryProcessor`.

Closes gh-21046
2020-04-28 11:09:37 +02:00
Phillip Webb 6fe30a8a7e Merge branch '2.2.x'
Closes gh-21175
2020-04-27 16:20:36 -07:00
Phillip Webb 36b082e8c1 Merge branch '2.1.x' into 2.2.x
Closes gh-21174
2020-04-27 16:18:55 -07:00
Phillip Webb e2705b2cfd Throw exception if classpath*: is used
Update `ConfigFileApplicationListener` to throw a better exception if
`classpath*:` is used as a location.

Closes gh-21168
2020-04-27 13:42:40 -07:00
Stephane Nicoll 4165863859 Polish contribution
See gh-21130
2020-04-27 10:41:02 +02:00
richard1230 a989879dbc Polish
See gh-21130
2020-04-27 10:38:40 +02:00
Brian Clozel 8f84147f37 Fix deprecations after Reactor Netty upgrade 2020-04-26 22:10:39 +02:00
dreis2211 54f319acd5 Remove unused method
See gh-21117
2020-04-25 09:07:13 +02:00
dreis2211 5eb5bf0a2d Polish
See gh-21009
2020-04-25 08:54:47 +02:00
Stephane Nicoll 85e9f713b0 Update copyright year of changed files
See gh-21007
2020-04-25 08:50:51 +02:00
Johnny Lim 29717423a3 Remove this keyword on member method invocations
See gh-21007
2020-04-25 08:49:44 +02:00
Mikael c06edbe6f4 Polish ApplicationHome
See gh-20992
2020-04-25 08:44:37 +02:00
Andy Wilkinson dc75ca3942 Avoid capturing TCCL when creating DefaultResourceLoaders
Previously, DefaultResourceLoader instances were created using the
default constructor. This causes the resource loader to capture the
TCCL that was in place at that time. This can lead to a class loader
leak if the resource loader is referenced directly or indirectly from
a static field of a class loaded by a different class loader.

This commit updates the creation of DefaultResourceLoader instances
in main code so that the resource load will use the class loader of
the creating class. In almost all cases this will be the same class
loader as was the thread context class loader that was being captured
so the change in behavior is minimal. Crucially, it will still address
the situation where the TCCL was different.

Note the DevTools' ApplicationContextResourceLoader has been updated
to explicitly use the TCCL. This ensures that it uses the restart
class loader which is required for DevTools to function correctly.

Fixes gh-20900
2020-04-24 13:29:29 +01:00
Andy Wilkinson d53be18582 Deprecate support for Bitronix
Closes gh-20823
2020-04-24 11:37:44 +01:00
Phillip Webb db28c0c65c Backport "Attempt to fix CI" 2020-04-23 16:35:01 -07:00
Phillip Webb 4de69c380d Attempt to fix CI 2020-04-23 15:55:10 -07:00
Phillip Webb 49345025ac Merge branch '2.2.x'
Closes gh-21105
2020-04-23 14:44:08 -07:00
Phillip Webb 93f7e2b6ba Limit when PortInUseException is thrown
Refactor `PortInUseException` logic to a single place and refine when
the exception is thrown.

Prior to this commit, we assumed that a `BindException` was only thrown
when the port was in use. In fact, it's possible that the exception
could be thrown because the requested address "could not be assigned".

We now only throw a `PortInUserException` if the `BindException` message
includes the phrase "in use".

Fixes gh-21101
2020-04-23 14:42:30 -07:00
Stephane Nicoll ddcd1bc7bb Remove metadata for configuration keys that were removed in 2.0
Closes gh-19706
2020-04-23 16:14:13 +02:00
Stephane Nicoll 6c02daf2bc Merge branch '2.2.x'
Closes gh-21098
2020-04-23 14:12:37 +02:00
Stephane Nicoll 311952730e Merge branch '2.1.x' into 2.2.x
Closes gh-21097
2020-04-23 14:07:31 +02:00
Stephane Nicoll 291165f060 Order additional metadata according to lexicographic order
Closes gh-21095
2020-04-23 13:58:49 +02:00
Phillip Webb bf41da5322 Update copyright year of changed files 2020-04-21 18:12:27 -07:00
Phillip Webb 03a9738f3b Merge branch '2.2.x'
Closes gh-21053
2020-04-20 17:57:57 -07:00
Phillip Webb 7d68c7c4c4 Merge branch '2.1.x' into 2.2.x
Closes gh-21052
2020-04-20 17:55:33 -07:00
Phillip Webb a2fdf23e41 Don't throw NettyWebServer on permission errors
Update `NettyWebServer` so that the `PortInUseException` is not thrown
for permission denied errors.

Fixes gh-19807
2020-04-20 17:54:13 -07:00
Phillip Webb c7611112f7 Include cause when throwing PortInUseException
Update classes that throw `PortInUseException` so that they also
include the cause. Prior to this commit the cause was not included
which could make diagnosing the real cause difficult.

See gh-19807
2020-04-20 17:54:10 -07:00
Madhura Bhave 5d56d652fb Merge branch '2.2.x'
Closes gh-21050
2020-04-20 17:10:16 -07:00
Madhura Bhave 4e0fdbee17 Process additional locations when non-default location configured
Fixes gh-20745
2020-04-20 17:08:54 -07:00
Madhura Bhave 2cac264624 Merge branch '2.2.x'
Closes gh-21049
2020-04-20 15:58:45 -07:00
Madhura Bhave af6d538781 Add support for initializing nested object when nothing bound
When using constructor binding, if no properties are bound to
a nested property, the top-level instance will be created with a
null value for the nested property.
This commit introduces support for an empty `@DefaultValue` which
indicates that an instance of the nested property must be created
even if nothing is bound to it. It honors any `@DefaultValue`
annotations that the nested property might have in its constructor.

Closes gh-18917
2020-04-20 15:39:55 -07:00
Phillip Webb de8915432a Allow square bracket notation profiles properties
Update `ConfigFileApplicationListener` so that `spring.profiles.active`
and `spring.profiles.include` can use the square bracket list notation.

Prior to this commit, only comma-separated lists could be used for
those values.

Closes gh-21006
2020-04-17 17:34:14 -07:00
Phillip Webb e3b8478621 Polish 2020-04-17 16:12:11 -07:00