Commit Graph

1038 Commits

Author SHA1 Message Date
Dave Syer
67483bb73c Only use Converters which are @ConfigurationPropertiesBinder qualified
Users sometimes create beans of type Converter and don't expect that to
automatically trigger a cascade of early initialization. This change adds
a qualifier to the Converters that are used by @ConfigurationProperties,
so they can be isolated (and simple).

Fixes gh-2669
2015-08-26 17:27:35 +01:00
Andy Wilkinson
a0870c1c4a Ignore binding failures for env vars and system properties
1.3.0.M4 tightened up the configuration property binding such that
ignoreUnknownFields = false now works as intended. Unfortunately, this
has led to some complaints as applications that worked with 1.2.x have
stopped working. For example, a SERVER_HOME environment variable does
not cause a failure in 1.2.x despite there being no home property on
ServerProperties but will now fail in 1.3.0.M4.

This commit updates RelaxedDataBinder to ignore binding failures for
properties that come from a source outside of the application’s control,
namely environment variables and system properties.

Closes gh-3775
2015-08-26 17:23:27 +01:00
Andy Wilkinson
2373e0fe66 Polishing
Remove stale test class
2015-08-26 16:08:09 +01:00
Andy Wilkinson
003268fb4e Add support for @WebFilter, @WebListener, @WebServlet
This commit adds a new annotation, @ServletComponentScan, that can be
used to enable scanning for @WebFilter, @WebListener, and @WebServlet
annotated classes. Registration beans will be automatically created for
any classes that are found, with the configuration derived from the
annotation.
2015-08-26 15:58:52 +01:00
izeye
e2119d3329 Fix typos
Closes gh-3809
2015-08-23 09:24:00 +02:00
Andy Wilkinson
6bd6bc9e10 Include information about a property’s origin in binding failures
This commit enhances RelaxedDataBinder to include information about the
origin of a property (its original name before any prefix was removed
and its source) when it encounters an unwritable property. For example,
launching an application with a SERVER_HOME environment variable
configured will produce the following failure message:

Failed to bind 'SERVER_HOME' from 'systemEnvironment' to 'HOME' property
on 'org.springframework.boot.autoconfigure.web.ServerProperties'

Closes gh-3778
2015-08-20 21:15:00 +01:00
Stephane Nicoll
53251a9f9c Add suffix dot on prefix only if necessary
Closes gh-3787
2015-08-20 10:43:12 +02:00
Martin Lippert
678f36cfef configure JRE that is different from compiler target level 2015-08-19 17:00:38 +01:00
Stephane Nicoll
7c0c953f81 Add value alias for SpringApplicationConfiguration
Given that Spring Boot uses java config accross the board, a new `value`
attribute is now aliased to the existing `classes` attribute such that
one could write the following:

@SpringApplicationConfiguration(MyConfig.class)
public class MyTest {}

Closes gh-3635
2015-08-19 17:09:34 +02:00
Andy Wilkinson
e370b592d6 Introduce defined extension point for modifying the environment
The commit introduces a new extension point, EnvironmentPostProcessor,
that can be implemented by classes that want to modify the
environment. Implementations of EnvironmentPostProcessor are loaded
via spring.factories and called in response to the
ApplicationEnvironmentPreparedEvent. Application listeners that wish
to work with the post-processed environment can continue to listen
to ApplicationEnvironmentPreparedEvent and order themselves to
run after EnvironmentPostProcessingApplicationListener.

Existing ApplicationListeners that modify the environment have,
where possible, been updated to implement EnvironmentPostProcessor
instead.

Closes gh-3737
2015-08-17 20:03:16 +01:00
Andy Wilkinson
fbe2e470f0 Ignore case when filtering out properties based on target name
Previously, PropertiesConfigurationFactory would only create a
DefaultPropertyNamePatternsMatcher that ignored case if it was
ignoring unknown fields. If the binding had a target name and
unknown fields were not being ignored the matcher would consider the
case when finding matches. This meant that SERVER_PORT would not being
to ServerProperties.port as SERVER did not match the target name,
server.

This commit updates PropertiesConfigurationFactory to use a
case-ignoring DefaultPropertyNamePatternsMatcher when binding with
a target name. The tests have also been updated to test binding both
with and without ignoring case and using either Properties or
PropertySources. The above-described matching is only performed
against PropertySources and the bug only occurred when using a target
name, making it important to test all combinations.

Closes gh-3745
2015-08-13 12:51:52 +01:00
Stephane Nicoll
398d06e326 Remove useless code
The target attribute is effectively checked for null beforehand so this
additional defensive check can be removed.

Closes gh-3725
2015-08-12 11:13:03 +02:00
Dave Syer
68af0a73ec Clarify documentation in a few areas
Fixes gh-3527
2015-08-10 11:50:48 +01:00
Dave Syer
ce512a18f3 Add test to support binding nested properties
See gh-3539
2015-08-10 11:22:47 +01:00
Stephane Nicoll
20c1c617ef Polish
See gh-3684
2015-08-06 13:30:35 +02:00
Stephane Nicoll
eae9682117 Avoid package tangle 2015-08-06 13:20:10 +02:00
Andy Wilkinson
9fcc860908 Polish contribution
Closes gh-3643
2015-08-06 12:06:39 +01:00
Joao Pedro Evangelista
7568af1710 Add auto-configuration of HttpPutContentFormFilter
Closes gh-3652
2015-08-06 12:06:28 +01:00
Andy Wilkinson
ffe2e9b66b Clarify javadoc of SpringApplication.configureProfiles
Closes gh-2671
2015-08-06 11:47:27 +01:00
Andy Wilkinson
1a11ed20ba Provide a property to configure conversion word used to log exceptions
This commit adds a new property, logging.exception-conversion-word,
that can be used to configure the conversion word that is used when
logging exceptions. The default value, %rEx, will log exceptions
with the root cause first and include class packaging information in
the stack trace. The new property is supported when using either
Logback or Log4J2.

Closes gh-3684
2015-08-06 11:37:54 +01:00
Phillip Webb
8d92236eea Polish 2015-08-05 12:09:23 -07:00
Andy Wilkinson
b396d0d291 Update logging defaults to show class packaging info and log cause first
This commit updates the default logging configuration for both Logback
and Log4J 2 to include class packaging information when logging
exceptions and to log the root cause first.

Closes gh-3398
Closes gh-3399
2015-08-05 17:20:10 +01:00
Vladimir Tsanev
632d78b6fb Prettify Log4J 2's default output
This commit updates the default output produced when using Log2J 2 to
be similar to the output produced by Logback. It introduces a new
converter for throwables that adds some whitespace around stacktraces
and a color converter that produces ANSI-colored output when enabled
via spring.output.ansi.enabled.

Closes gh-3548
2015-08-05 15:09:27 +01:00
Stephane Nicoll
65efd1725f Add before modes support for @IntegrationTest
Spring Framework 4.2 introduced support for before modes in
`@DirtiesContext` Make sure that `@IntegrationTest` also support
these new modes.

Closes gh-3642
2015-08-05 15:35:47 +02:00
izeye
7dc9bddf9a Fix typos
Closes gh-3666
2015-08-05 14:35:32 +02:00
Phillip Webb
12b876fbfa Reduce PropertySource access when binding
Update `PropertiesConfigurationFactory` so that when possible fewer
calls are made to the underlying `PropertySource`. The
`PropertySourcesPropertyValues` class now accepts a matcher which is
used to limit the properties that should be adapted. The factory will
create a matcher based on the standard relaxed binding rules.

Fixes gh-3402
See gh-3515
2015-08-04 16:45:38 -07:00
Phillip Webb
a10bfc153d Restore LoggingSystem 1.2.x compatibility
Restore and deprecate the previous `initialize` method to allow a
migration path.

Fixes gh-3591
2015-08-04 15:23:36 -07:00
Stephane Nicoll
ad6fb55958 Add relaxed names for enum test
Add an extra test that demonstrate the use of relaxed binding for Enum
when it is used as a map key.

See gh-2465
2015-08-04 14:48:38 +02:00
Stephane Nicoll
f4723efaed Fix typo 2015-08-04 14:30:09 +02:00
Phillip Webb
8e114e3e2a Merge branch '1.2.x' 2015-08-03 11:09:40 -07:00
Phillip Webb
2c0ec1b428 Polish 2015-08-03 11:09:33 -07:00
Phillip Webb
199a3c1535 Fix type in DefaultPropertyNamePatternsMatcher 2015-08-03 11:03:48 -07:00
Phillip Webb
891dd5a0f6 Polish 2015-08-03 11:03:48 -07:00
Andy Wilkinson
5c1f700c3a Merge branch '1.2.x' 2015-08-03 16:23:54 +01:00
Andy Wilkinson
838e0ef33e Polish contribution
- Extract the logic that coerces the string into a LogLevel into a
  separate method.
- Add a test that verifies that false is mapped to LogLevel.OFF

Closes gh-3628
2015-08-03 16:23:36 +01:00
shanman190
cbd37b583f Make it easier to use YAML configuration to turn off a logger
A level named off is used to disable logging for a particular logger.
YAML interprets off as false, leading to a failed attempt to get the
LogLevel for FALSE. A workaround is to quote the level, i.e. use "off"
rather than off.

This commit updates LoggingApplicationListener to coerce the string
false back to the level off.

Closes gh-3631
See gh-3628
2015-08-03 16:21:26 +01:00
Stephane Nicoll
fac04c1228 Add test
#3386 was actually fixed as part of #2387. Add the test that used to
reproduce the issue.
2015-08-03 15:03:19 +02:00
Stephane Nicoll
cd53297fed Add missing logging.pattern meta-data
See gh-3405
2015-08-03 09:22:30 +02:00
Andy Wilkinson
255764f1a0 Ensure that custom Liquibase logger is always used
Liquibase 3.4.0 contains a bug that causes the initialization of its
ServiceLocator to pollute its map of loggers with a DefaultLogger for
the logger named "liquibase". Liquibase 3.4.1 contains a change that
improves the situation, but does not address is completely. Creating a
CustomResolverServiceLocator, as we do, still causes the map of
loggers to be polluted due to logging that's performed in
ClassLoaderResourceAccessor.getResourcesAsStream.

The commit address the problem by upgrading to Liquibase 3.4.1 and
adding the package containing our custom logger to the default service
locator before we register our custom service locator. This ensures
that the logging that's performed during the creation of our custom
service locator will still use our custom logger.

Closes gh-3470
Closes gh-3616
2015-07-29 10:15:29 +01:00
izeye
ee6fc8d917 Fix typos
Closes gh-3608
2015-07-28 08:54:47 +02:00
Stephane Nicoll
42e230192f Polish 2015-07-24 07:19:53 +02:00
Stephane Nicoll
4596844b90 Merge branch '1.2.x' 2015-07-23 11:37:29 +02:00
Stephane Nicoll
fbfbec1177 Use custom validator on supported classes only
Previously, a customer was set regardless of the fact that it is
supported on the target bean. DataBinder has an actual assertion check
that would fail in such a case.

We now associate the custom validator only if it supports the target
bean.

Fixes gh-3581
2015-07-23 11:37:01 +02:00
Andy Wilkinson
ea85e0d0b0 Merge branch '1.2.x' 2015-07-22 17:55:17 +01:00
Andy Wilkinson
a43cd18ac9 Avoid changing root logger level when setting level of unconfigured logger
Previously getLoggerConfig(loggerName) was used to retrieve the
LoggerConfig object on which the level was to be set. As described in the
method’s javadoc it will “remove tokens from the package name as
necessary or return the root LoggerConfig if no other matches were found”.
This is problematic as, if there’s no configuration for the logger whose
level is being configured, the level will be applied to a logger from an
outer package or to the root logger.

This commit updates Log4J2LoggingSystem to use the configuration’s map of
LoggerConfigs, rather than calling getLoggerConfig. In the event of the
level being set on an unconfigured logger, this will produce a null
LoggerConfig. When a null LoggerConfig is encountered, a new one is
created with the appropriate level. If the config already exists, its
level is set as it was before.

The code that was accessing the root logger using a magic null value
(which was then coerced into the root logger’s name (an empty string))
has also been updated to make it clearer that they are purposefully
dealing with the root logger.

Closes gh-3550
2015-07-22 17:50:07 +01:00
Phillip Webb
6f6f898739 Polish 2015-07-20 10:22:10 -07:00
Dave Syer
c181a2d157 Add simple performance test for properties binding 2015-07-20 13:09:23 +01:00
Lucas Saldanha
1fc66b434e Polish JsonParserFactory javadoc
Closes gh-3545
2015-07-19 08:54:28 +02:00
Phillip Webb
e9d252e05c Add @DeprecatedConfigurationProperties annotation
Add a new @DeprecatedConfigurationProperties annotation which can be
used by the `ConfigurationMetadataAnnotationProcessor` to generating
meta-data deprecated blocks.

Fixes gh-3543
2015-07-17 14:14:37 -07:00
Phillip Webb
08d1f6daf5 Allow persistent servlet sessions across restarts
Update Tomcat, Jetty and Undertow to serialize session data when the
application is stopped and load it again when the application restarts.

Persistent session are opt-in; either by setting `persistentSession`
on the ConfigurableEmbeddedServletContainer or by using the property
`server.session.persistent=true`.

Fixes gh-2490
2015-07-16 17:29:20 -07:00