Previously, the spring bash script added . to the classpath but the
Windows spring.bat script did not. This commit aligns the classpath
of the two scripts by removing . from the classpath in the bash
script.
Fixes gh-19910
Allow `BeanDefinitionLoader` to load classes that don't have public
constructors. The constraint was first introduced in d82c50804f to
solve an issue with anonymous Groovy classes but causes particular
problems with `@SpringBootTest`.
See gh-20929
Update `LaunchedURLClassLoader` so that packages defined from exploded
archive folders have manifest attributes applied to them. Prior to this
calling `package.getImplementationTitle()` would only return the a
manifiest attribute when running non-exploded.
The root cause of this issue is the way that `URLClassLoader` handles
the different URL types. For URLs that reference a jar the manifest is
available. For URLs that reference a folder it isn't. When running
exploded we use a URL that references to the `BOOT-INF/classes` folder
directly. To fix the issue we now attempt to detect when `definePackage`
is being called directly, and replace `null` entries with actual
manifest values.
Fixes gh-21705
Update `SpringBootServletInitializer` to use the `ServletContext` that
was provided to the initial `onStartup` call rather than the
one from the `ServletContextEvent`. This allows the `getClassLoader()`
call to complete without throwing an `UnsupportedOperationException`.
Fixes gh-21684
This commit improves the error messages returned by the Spring Boot
build plugins when a 5xx status code is returned from the Docker
API while attempting to build an image. If the error response has
contents containing a JSON structure with a "message" key, the value
associated with that key will be included in the exception message
and in the build plugin output error.
Fixes gh-21515
Update `SpringConfigurationPropertySource` so that wrapped random
property sources can be used. It's assumed that wrapped random
sources will use the name of the source as the prefix.
Closes gh-21595
Previously, if the Spring Boot build plugins got a connection error
when attempting to communicate with a Docker daemon (for example,
when the daemon isn't running), the error message made it appear that
the daemon returned an HTTP error code. This commit makes a connection
error distinct from an HTTP error response code to make it easier for
the user to diagnose the root cause of the problem.
Fixes gh-21554
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
Previously, the productionRuntimeClasspath configuration was created
without any attributes. This caused problems with multi-project
dependency resolution as there was insufficient information for Gradle
to determine which variant of a dependency should be used by the
productionRuntimeClasspath configuration.
This commit updates the configuration to have three attributes, each
configured with the same values as those of Gradle's own
runtimeClasspathConfiguration.
Fixes gh-21549
This commit mentions the `management.health.probes.enabled`
configuration property in the Kubernetes Probes section of the Actuator
chapter.
Enabling this property is required if we need to expose Kubernetes
Probes in a non-Kubernetes environment.
Fixes gh-21505
Prior to this commit, Spring Boot would auto-configure Spring MVC and
would keep the default `UrlPathHelper` configuration.
Since Spring Boot is in charge of configuring the `DispatcherServlet`
and its mapping, it is in a position to optimally configure the
`UrlPathHelper` depending on the chosen mapping.
This commit sets the `alwaysUseFullPath` property of `UrlPathHelper` if
the Servlet mapping is `"/"`. This is more efficient since this
configuration requires less processing of the request path.
Closes gh-21499
This commit adds the support for static and templated welcome pages with
Spring WebFlux. The implementation is backed by a `RouterFunction`
that's serving a static `index.html` file or rendering an `index` view.
Closes gh-9785
Prior to this commit, a default tag of 'latest' was used when no tag
was included in the builder image name used when building an image in
the Maven and Gradle plugins, but the tag for the run image was left
empty if it was not provided. This resulted in errors when pulling
the run image from an image repository. This commit applies the
same tag defaulting logic to the run image name.
Fixes gh-21532
This commit updates the MavenPublishingConventions to use HTTPS to
link to the Apache license. The configuration of NoHTTP has also
been reworked so that it will correctly find usch uses of http://
URLs.
Closes gh-21459
Prior to this commit, the published Maven POMs would not pass the Maven
Central mandatory checks.
This commit adds the missing project name and description metadata for
most artifacts. The Spring Boot Gradle plugin artifact was also missing
this information and this is now added in the plugin metadata itself.
This is also updating the project page URL which is now hosted directly
on spring.io.
Fixes gh-21457
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
Update `EndpointDiscoverer` so that `@Endpoint` and `@EndpointExtension`
beans are created as late as possible.
Prior to this commit, endpoint beans and extension beans would be
created during the discovery phase which could cause early bean
initialization. The problem was especially nasty when using an embedded
servlet container since `ServletEndpointRegistrar` is loaded as the
container is initialized. This would trigger discovery and load all
endpoint beans, including the health endpoint, and all health indicator
beans.
Fixes gh-20714
Restore the `getUseRelativeRedirects` method with a `Boolean` object
result and introduce `isUseRelativeRedirects` for the primitive boolean
variant.
See gh-20796
Gradle's metadata for a platform does not provide a way to define
exclusions in the same way that can be done in <dependencyManagement>
in a Mavne bom. This means that Gradle 6 users lose the exclusions
that are defined in the pom as Gradle 6 will use the metadata rather
than the pom.
Until such a time as Gradle's metadata supports the configuration of
such exclusions we can avoid the problem by disabling the metadata's
publication.
Fixes gh-21350
This commit expands the migration check to all deprecated properties,
not only the ones that have been effectively removed. This provides more
information upfront, including keys that still work in the current
release but will need to be renamed sooner than later anyway.
Closes gh-21425
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
Prior to this commit, if a DOCKER_HOST environment variable was present
when attempting to communicate with a Docker daemon, it was assumed
that the value of that variable was an address that could be used to
create an HTTP connection to a remote daemon. In some cases, the value
of the variable is the path to a local socket file, which would cause
the HTTP connection to fail.
This commit adds additional validation of the value of the DOCKER_HOST
environment variable to determine whether it is a remote address or
a local socket file and create the appropriate connection type.
Fixes gh-21173
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.
Prior to this commit, details about an exception would get dropped when
the management context was separate from the application context and
an actuator endpoint threw a binding exception.
This commit adds some logic to capture the exception so the management
context error handlers can add the appropriate attributes to the error
response.
Fixes gh-21036
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
Update `SpringBootContextLoader` to both add `spring.profiles.active`
properties and to directly call `Environment.setActiveProfiles`.
The additional `setActiveProfiles` call prevents `AbstractEnvironment`
from accidentally loading `spring.profiles.active` properties directly
when `doGetActiveProfiles` is called.
Directly setting active profiles has only become necessary since we
started adding properties using the square bracket notation. Previously
we added a comma-separated list which would be picked up by both the
`AbstractEnvironment` and the `ConfigurationFileApplicationListener`.
Closes gh-21302
Prior to this commit, the build tool plugins set the environment
variable BP_JAVA_VERSION when invoking the CNB builder to set the
version of the JDK/JRE that the builder should use in the created
image.
With CNB API 0.3, the convention changed the name of this environment
variable to BP_JVM_VERSION. This commit updates the build tool
plugins to match the newer convention.
See gh-21273
This commit modifies the buildpack platform invocation logic used by
the build plugins to invoke the single creator lifecycle introduced in
the CNB API 0.3, instead of invoking discrete lifecycle phases
separately. It also removes support for CNB API 0.2.
Fixes gh-21273
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
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
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
Fix the `SystemEnvironmentPropertyMapper.isAncestorOf` implementation
to convert names based on their dashed form and to silently ignore
any invalid results.
Closes gh-14479
The warnings will be addressed by gh-20759. CreateBootStartScripts
must be excluded from the classes that are validated by the
ValidatePlugins task. It is invalid, but only for Gradle 6.4. gh-20759
will cause it to only be used with Gradle 6.3 and earlier.
See gh-21329
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
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
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>
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
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
Add an `InputStreamSourceToByteArrayConverter` that can be used to
convert from an `InputStreamSource` (such as a `Resource`) to a
byte array.
Closes gh-21285
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
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
This commit introduces a CookieSerializerCustomizer callback that
allows the customization of the auto-configured
DefaultCookieSerializer bean. This is particularly useful for
configuring cookie serializer's capabilities, such as SameSite, that
are not supported by the Servlet API and therefore not exposed via
server.servlet.session.cookie.* properties.
See gh-20961
This commit changes the default builder image from
`cloudfoundry/cnb:bionic-platform-api-0.2` to
`gcr.io/paketo-buildpacks/builder:base-platform-api-0.3`. It also
uses a `paketo-buildpacks/builder` image instead of a
`cloudfoundry/cnb` image to test compatibility with lifecycle v2
and uses paketo naming instead of cloudfoundry when mocking builder
interactions.
Some adjustments to lifecycle phases were also made to align more
closely with the pack CLI.
Fixes gh-21066
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
This commit updates HazelcastHealthIndicator and
HazelcastCacheMeterBinderProvider so that they work with
Hazelcast 4 while retaining compatibility with Hazelcast 3. Reflection
is used when necessary.
This commit also adds a smoke test that validates those features are
working when Hazelcast 4 is on the classpath.
Closes gh-21169
Extend WebFlux and WebMvc properties with timeFormat and
dateTimeFormat properties to allow users to customize format of
LocalTime and LocalDateTime instances.
See gh-18772
Previously, only root auto-configuration classes could be excluded
eagerly via an AutoConfigurationImportFilter. Any configuration class
loaded as a result of processing a particular auto-configuration were
parsed and checked as usual.
This commit makes use of the `getExclusionFilter` callback to expand
this filter to all candidates that are considered. The annotation
processor has also be expanded to generate metadata for non-root
configuration classes.
Closes gh-12157
Prior to this commit, there was a cycle between `StatusAggregator` and
`SimpleStatusAggregator`, which caused a static initialization bug -
depending on which class (the implementation or its interface) was
loaded first.
This commit turns the static field of the `StatusAggregator` interface
into a static method to avoid this problem.
Fixes gh-21211