Commit Graph

325 Commits

Author SHA1 Message Date
Andy Wilkinson
a95a7e3d40 Allow restart to be enabled when CL not named AppClassLoader
Previously, the restart initializer that enables restart when
-Dspring.devtools.restart.enabled=true is set had no effect when the
ClassLoader's name did not contain AppClassLoader. This commit updates
RestartApplicationListener to use the correct RestartInitializer when
the system property has forcibly enabled restart.

When restart is enabled a SilentExitException is thrown and it should be
caught and handled by the SilentExitExceptionHandler. When the
application is invoked via one of the loader's LauncherClasses
reflection is used and this exception becomes wrapped in an
InvocationTargetEception. Previously, this wrapping prevented
SilentExitExceptionHandler from handling the exception. This commit
updates the handler to look for an InvocationTargetException with a
SilentExitException target in addition to continuing to look for a
SilentExitException directly.

Fixes gh-24797
2021-01-13 10:12:12 +00:00
Phillip Webb
72d36e0c07 Update copyright year of changed files 2020-12-10 10:46:04 -08:00
dreis2211
faec47d332 Remove System.out.println in DevToolsPropertyDefaultsPostProcessor
See gh-24325
2020-12-03 16:25:03 -08:00
Stephane Nicoll
c86ce27117 Use non deprecated properties to override web resources cache
Closes gh-24203
2020-11-18 17:40:35 +01:00
Andy Wilkinson
6df10842d2 Allow Devtools to be enabled irrespective of the launching ClassLoader
Closes gh-21424
2020-11-12 13:22:40 +00:00
Andy Wilkinson
4c777c6df7 Deprecate classpath logging listener and stop registering by default
Closes gh-23138
2020-11-03 17:21:36 +00:00
Andy Wilkinson
c22e655848 Move spring.resources.* properties to spring.web.resources.*
Closes gh-23917
2020-10-29 16:08:50 +00:00
Andy Wilkinson
9854e3019b Polish 2020-10-27 14:59:10 +00:00
Andy Wilkinson
689d0c8307 Remove skipping of spring-boot-* projects from DevTools restart triggers
Closes gh-23158
2020-10-27 12:09:17 +00:00
Madhura Bhave
0818f27f44 Configure WebSecurity using WebSecurityCustomizer
Replace `WebSecurityConfigurer` and `WebSecurityConfigurerAdapter`
configurations with `WebSecurityCustomizer` or `SecurityFilterChain`
beans.

Closes gh-23421
2020-10-26 23:47:14 -07:00
Andy Wilkinson
a19a565410 Stop registering the default servlet by default
Previously, the default servlet was registered automatically when using
embedded Jetty, Tomcat, or Undertow. However, it is not used by the
majority of applications where Spring MVC's DispatcherServlet will be
the only servlet that's needed. As such configuring the default servlet
was wasting CPU and memory.

This commit changes the default for registering the default servlet to
false. It can be re-enabled by setting
server.servlet.register-default-servlet=true.

Closes gh-22915
2020-09-29 11:52:19 +01:00
Phillip Webb
1ae1436211 Refactor BootstrapRegistry support
Refactor `BootstrapRegistry` support following initial prototype work
with the Spring Cloud team.

This update splits the `BootstrapRegistry` API into `BootstrapRegistry`,
`BootstrapContext` and  `ConfigurableBootstrapContext` interfaces and
moves it to the same package as `SpringApplication`.

A new `Bootstrapper` interface has been introduced that can be added
to the `SpringApplication` to customize the `BootstrapRegistry` before
it's used.

Closes gh-23326
2020-09-17 00:31:00 -07:00
Phillip Webb
8ccf7ee489 Make file detection more resilient across restarts
Retain file snapshot state across devtools restarts to help prevent
detection failures.

Closes gh-19543
2020-08-31 13:44:43 -07:00
Andy Wilkinson
19558ecda7 Merge branch '2.3.x' 2020-08-25 16:51:17 +01:00
Andy Wilkinson
d133f228e2 Increase wait times in DevToolsIntegrationTests
See gh-22909
2020-08-25 16:50:56 +01:00
Phillip Webb
2260657781 Add BootstrapRegistry for long lived instances
Add a simple `BootstrapRegistry` that can be used to store and share
object instances across `EnvironmentPostProcessors`. The registry
can be injected into the constructor of any `EnvironmentPostProcessor`.

Registrations can also perform additional actions when the
`ApplicationContext` has been prepared. For example, they could register
the the bootstrap instances as beans so that they become available to
the application.

See gh-22956
2020-08-20 21:45:02 -07:00
Madhura Bhave
bbbbe8e4d2 Make security auto-configs back off when SecurityFilterChain present
Closes gh-22739
2020-08-14 12:24:25 -07:00
Andy Wilkinson
c9b8a05321 Merge branch '2.3.x' 2020-08-14 15:41:20 +01:00
Andy Wilkinson
3e35fd480f Wait longer for server port and improve diagnostics on timeout
See gh-22909
2020-08-14 15:34:41 +01:00
Andy Wilkinson
147b048a07 Merge branch '2.3.x'
See gh-22909
2020-08-12 13:24:50 +01:00
Andy Wilkinson
2b1bb2f18f Improve diagnostics when remote application does not start as expected
See gh-22909
2020-08-12 13:24:17 +01:00
Andy Wilkinson
5e04e1f4a3 Merge branch '2.3.x'
Closes gh-22888
2020-08-11 14:34:27 +01:00
Andy Wilkinson
1896566bc8 Avoid duplicates with different versions in Devtools' int test deps
Closes gh-22887
2020-08-11 14:33:27 +01:00
Andy Wilkinson
969dd35e45 Upgrade to Mockito 3.4.6
Closes gh-22838
2020-08-10 15:22:03 +01:00
Stephane Nicoll
dac63fc3e5 Polish 2020-08-06 17:35:01 +02:00
Andy Wilkinson
7df49187fa Merge branch '2.3.x'
Closes gh-22738
2020-08-05 09:05:28 +01:00
Andy Wilkinson
94644f3814 Merge branch '2.2.x' into 2.3.x
Closes gh-22737
2020-08-05 09:05:10 +01:00
Andy Wilkinson
2238b0d797 Try to make FileSystemWatcherTests.waitsForQuietPeriod() more robust
Previously, waitsForQuietPeriod would iterate 10 times, touching a new
file and then sleeping for 100ms at it did so. With a quiet period of
200ms, this was intended to result in a single change set containing
10 files. However, the test would fail occasionally as multiple change
sets were detected. The test is multi-threaded and is, therefore, at
the mercy of the scheduler. If the thread that is iterating and
touching the files takes over 200ms to be scheduled – exceeding the
watcher's quiet period – the watcher may detect a change set while the
changes are still being made. Eliminating this possibilty would require
the test to participate in the watcher's synchronization, which would
require some changes to its implementation. Instead, this commit
aims to avoid the problem by sleeping for 1/10 of the time (10ms) and
expecting a single change set of 100 files. The hope is that the much
shorter sleep time will result in the file touching thread being
scheduled well within the 200ms quiet period.

Closes gh-22732
2020-08-05 09:00:49 +01:00
Phillip Webb
36a6ca6e6e Add EnvironmentPostProcessorsFactory
Update `EnvironmentPostProcessorApplicationListener` so that it can
either use values from `spring.factories` or use a factory interface.

Closes gh-22529
2020-07-23 11:43:02 -07:00
Phillip Webb
3352024b1c Provide ConfigFileApplicationListener replacement
Deprecate `ConfigFileApplicationListener` and provide a replacement
mechanism that supports arbitrary config data imports.

This commit updates the following areas:

- Extract `EnvironmentPostProcessor` invocation logic from the
  `ConfigFileApplicationListener` to new dedicated listener. Also
  providing support for `Log` injection.

- Extract `RandomPropertySource` adding logic from the
  `ConfigFileApplicationListener` to a dedicated class.

- Migrate to the recently introduced `DefaultPropertiesPropertySource`
  class when moving the defaultProperties `PropertySource`

- Replace processing logic with a phased approach to ensure that
  profile enablement happens in a distinct phase and that profiles
  can no longer be activated on an ad-hoc basis.

- Provide a more predictable and logical import order for processing
  `application.properties` and `application.yml` files.

- Add support for a `spring.config.import` property which can be used
  to import additional config data. Also provide a pluggable API
  allowing third-parties to resolve and load locations themselves.

- Add `spring.config.activate.on-profile` support which replaces the
  existing `spring.profiles` property.

- Add `spring.config.activate.on-cloud-platform` support which allows
  a config data document to be active only on a given cloud platform.

- Support a `spring.config.use-legacy-processing` property allowing the
  previous processing logic to be used.

Closes gh-22497

Co-authored-by: Madhura Bhave <mbhave@vmware.com>
2020-07-22 21:02:32 -07:00
Andy Wilkinson
7864a7da52 Polish "Remove redundant bitwise operations"
See gh-22212
2020-07-07 10:37:44 +01:00
XenoAmess
de46d4bfd3 Remove redundant bitwise operations
See gh-22212
2020-07-07 10:37:26 +01:00
Andy Wilkinson
27c458ca26 Merge branch '2.3.x'
Closes gh-22160
2020-06-30 10:53:49 +01:00
Andy Wilkinson
f86831da9c Use TCCL at time of access for resource loading
Fixes gh-22119
2020-06-30 10:51:13 +01:00
Andy Wilkinson
ca76b60de2 Merge branch '2.3.x'
Closes gh-22021
2020-06-19 08:23:30 +01:00
Andy Wilkinson
136c9b1af8 Merge branch '2.2.x' into 2.3.x
Closes gh-22020
2020-06-19 08:23:15 +01:00
Andy Wilkinson
41173f7c40 Polish "Use Awaitility instead of Thread.sleep"
See gh-21988
2020-06-19 08:18:01 +01:00
Tomek Szmytka
c13385ea74 Use Awaitility instead of Thread.sleep
See gh-21988
2020-06-19 08:17:53 +01:00
Andy Wilkinson
f3220b16fe Merge branch '2.3.x' 2020-06-18 09:23:40 +01:00
Andy Wilkinson
8f7d71ca11 Merge branch '2.2.x' into 2.3.x 2020-06-18 09:23:21 +01:00
Andy Wilkinson
907b64a5eb Remove redundant stop() calls from LiveReloadServerTests 2020-06-18 09:23:02 +01:00
Andy Wilkinson
07fb4b065d Merge branch '2.3.x'
Closes gh-21940
2020-06-16 10:10:38 +01:00
Andy Wilkinson
0de466e06e Require dependency on s-b-dependencies to use its constraints
Previously, Spring Boot's modules published Gradle Module Metadata
(GMM) the declared a platform dependency on spring-boot-dependencies.
This provided versions for each module's own dependencies but also had
they unwanted side-effect of pulling in spring-boot-dependencies
constraints which would influence the version of other dependencies
declared in the same configuration. This was undesirable as users
should be able to opt in to this level of dependency management, either
by using the dependency management plugin or by using Gradle's built-in
support via a platform dependency on spring-boot-dependencies.

This commit reworks how Spring Boot's build uses
spring-boot-dependencies and spring-boot-parent to provide its own
dependency management. Configurations that aren't seen by consumers are
configured to extend a dependencyManagement configuration that has an
enforced platform dependency on spring-boot-parent. This enforces
spring-boot-parent's version constraints on Spring Boot's build without
making them visible to consumers. To ensure that the versions that
Spring Boot has been built against are visible to consumers, the
Maven publication that produces pom files and GMM for the published
modules is configured to use the resolved versions from the module's
runtime classpath.

Fixes gh-21911
2020-06-16 08:50:21 +01:00
Andy Wilkinson
6e68101b9f Upgrade to Postgresql 42.2.13
Closes gh-21859
2020-06-10 17:04:03 +01:00
Andy Wilkinson
daeca9f332 Restore Boot 2.2's compile-scoped dependencies
Fixes gh-21507
2020-06-03 12:55:11 +01: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
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
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
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