Commit Graph

1343 Commits (1.3.x)

Author SHA1 Message Date
Spring Buildmaster 504d3e97ba Next development version 9 years ago
Phillip Webb ebabc63bbb Refine ContextId NAME_PATTERN
Update the ContextIdApplicationContextInitializer default NAME_PATTERN
to favor the developer defined `${spring.application.name}` value over
the deployer defined `${vcap.application.name}`.

Fixes gh-4926
9 years ago
Phillip Webb fd3e5cf304 Defer disable persistence logic to a listener
Update TomcatEmbeddedServletContainerFactory so that logic to disable
persistent sessions happens after Tomcat's standard Manager creation
logic.

Fixes gh-4543
9 years ago
Phillip Webb cf93f84e87 Polish 9 years ago
Matt Benson 34b1de6c39 Add mainApplicationClass accessor to SpringApplication
Closes gh-4801
9 years ago
Andy Wilkinson 03669002de Check for null context when trying to find an exception mapper
If application context refresh fails, SpringApplication will have a 
null context. Previously, this would result in an NPE when looking for
an ExitCodeExceptionMapper.

This commit updates SpringApplication to gracefully handle the context
being null when looking for an ExitCodeExceptionMapper.

Closes gh-4803
9 years ago
Stephane Nicoll c23af8f54e Support of GenericConverter
This commit makes sure to also include any `GenericConverter` flagged for
inclusion in the conversion service to use to convert configuration keys.

Previously, those were ignored as `Converter` and `GenericConverter` are
two separate interfaces.

Closes gh-4988
9 years ago
Andy Wilkinson 1dd166691d Merge branch '1.2.x' 9 years ago
Andy Wilkinson 5ef6903690 Make EmbeddedVelocityToolboxView work in servlet container deployments
EmbeddedVelocityToolboxView is used with both embedded containers and
when a Spring Boot application is deployed to a servlet container. It
process the ServletContext to intercept calls to getResource so that it
can load Velocity’s toolbox.xml file from within an executable jar.
Previously, when it created the proxy, it didn’t specify the ClassLoader
to use. This resulted in the proxy being created using the ClassLoader
that loaded the Class that is being proxied. This fails when the
application is deployed to a ServletContainer as the ClassLoader that
loaded the ServletContext implementation is the container’s ClassLoader
and it cannot see the classes that are specific to the web application.

This commit updates EmbeddedVelocityToolboxView to specify the
ClassLoader to use when creating the proxy. It specifies its own
ClassLoader thereby ensuring that the proxy creation can load
application-specific classes.

Fixes gh-4967
9 years ago
Stephane Nicoll 46470934d7 Fix log message
Closes gh-4969
9 years ago
Stephane Nicoll c57588ac09 Merge branch '1.2.x' 9 years ago
Stephane Nicoll 2ceadd705b Fix documentation of logging.path and logging.file
See gh-4969
9 years ago
Andy Wilkinson da4504118e Merge branch '1.2.x' 9 years ago
Andy Wilkinson 43ed824f40 Reinstate Tomcat’s old default behaviour for context root redirects
Prior to Tomcat 8.0.30, its default behaviour was for the mapper to
redirect a request for context-root to context-root/. This redirection
was switched off by default in 8.0.30 by default. This has proven
to be problematic and Tomcat 8.0.31 will reinstate the old default.

While we are waiting for Tomcat 8.0.31 to be released, this commit
explicitly sets the default back to what it was in 8.0.29 and earlier
and what it will be in 8.0.31.

Closes gh-4937
9 years ago
Phillip Webb 13db85f84b Add ExitCodeExceptionMapper support
Add ExitCodeExceptionMapper strategy interface which can be used to map
exceptions to exit codes.

Closes gh-4803
9 years ago
Andy Wilkinson 27a81e1463 Complete static final logger changes that were started in ec2f33f9
This commit completes the changes to consistently used static final
fields for Log instances that were started in ec2f33f9. Specifically it:

 - Removes this. when accessing logger fields that are now static
 - Renames some fields from log to logger
 - Makes some logger fields static

See gh-4784
9 years ago
Phillip Webb 152ee95261 Polish 9 years ago
Phillip Webb a20cd2de02 Publish ExitCodeEvent when possible
Update SpringApplication to publish an ExitCodeEvent when a valid exit
code is known.

Fixes gh-4804
9 years ago
Phillip Webb 7397dbaf57 Allow ExitCodeGenerator to be used on Exceptions
Update exit code support to allow the ExitCodeGenerator interface to
be placed on an Exception. Any uncaught exception implementing the
interface and returning a non `0` status will now trigger a System.exit
with the code.

Fixes gh-4803
9 years ago
Phillip Webb d2fed8bb07 Polish 9 years ago
mrumpf 1f5291cd84 Fixed the check whether Log4j2 is available on the classpath
In Spring Boot 1.3.1 the class 'org.apache.logging.log4j.LogManager'
is used to check which logging backend is in use. But this class is
part of the log4j-api.jar and not part of the log4j-core.jar.
That means the check is invalid, as it does not detect the actual
core implementation of Log4j2 correctly.

When you want to redirect Log4j2 logging via SLF4J, a NPE occurs
each time the application is reloaded by the devtools, because the
class Log4j2RestartListener tries to shutdown Log4j2 resources.
This is done by accessing some internal shutdown method via
reflection. The method that is being looked for does not exist
when the log4j-api.jar is available only on the classpath,
resulting in a NPE. This causes the application to stop,
disappearing from the Spring Boot Dashboard in Eclipse

Closes gh-4831
9 years ago
Stephane Nicoll a835912c04 Merge branch '1.2.x' 9 years ago
Stephane Nicoll b94c7c6a1d Guard instantiation of Tomcat's ErrorPage
Closes gh-4839
9 years ago
Johnny Lim c39df05652 Polish test
Closes gh-4837
9 years ago
Stephane Nicoll 3e25d99f4e Add test to validate `log42-spring.xml` location
See gh-4809
9 years ago
Dave Syer d493d3afe7 Make Log4J logging system consistent with the others
when the logname is empty it replaces it with the root logger name.

Fixes gh-4808
9 years ago
Spring Buildmaster 8db59059a5 Next Development Version 9 years ago
Johnny Lim c09a14a128 Fix typos
Closes gh-4806
9 years ago
Phillip Webb 25a7294371 Make ExitCodeGenerators package-private
ExitCodeGenerators is not going to be immediately used by spring-task so
it can remain package-private for now.

See gh-4757
9 years ago
Phillip Webb f96dea7011 Polish 9 years ago
Stephane Nicoll bb736e255b Fix SNAPSHOT version 9 years ago
Andy Wilkinson b79ee145d6 Configure worker for Undertow’s access log to use daemon threads
Previously, the worker used non-daemon threads which meant that they
prevented the JVM from shutting down. Ideally, we’d avoid this problem
by closing the worker and access log receiver as part of stopping
Undertow, however, due to an apparent bug in Undertow [1], it’s not
possible to do so cleanly.

This commit configures the access log worker to use daemon threads so
that they do not prevent the JVM from shutting down. Unfortunately,
this means that the threads will still be running after the context has
been closed but before the JVM shuts down but that appears to be
unavoidable due to the aforementioned Undertow bug.

Closes gh-4793

[1] https://issues.jboss.org/browse/UNDERTOW-597
9 years ago
Phillip Webb ec2064d981 Remove TODO
See gh-4796
9 years ago
Phillip Webb ff2addb321 Fix checkstyle 9 years ago
Phillip Webb 40abd13813 Be defensive about hiding log errors
Ensure that log configuration errors always get reported.
9 years ago
Kirill Vlasov ec2f33f986 Make loggers private static final
Apply consistency across all static loggers.

Closes gh-4784
9 years ago
Kirill Vlasov 786aacf2e9 Use Collections.isEmpty() instead of .size() == 0
Ensure that Collections.isEmpty() is used to check if there are no
elements in a collections. This is more explicit and can be faster than
calling .size().

Closes gh-4783
9 years ago
Dave Syer 471947b400 Be more defensive when instantiating custom ServerProperties
If the user provides their own ServerProperties bean we want to peek
at it to see if they set the port (and only that) when we are deciding
if the actuator context needs to be created. This happens very early
(in a @Condition) so we need to be very defensive. There are already
quite a few checks in place to prevent a ServerProperties bean from
being instantiated unless we really need it, and yet, when it is
we can do more.

This change creates the bean (and the ManagementProperties) in a
throwaway BeanFactory using the same BeanDefinition as the main
context. This ensures that when the main context bean is created
it will be in the "natural" order and binding to the Environment
can take place as normal.

Fixes gh-4631
9 years ago
Jean de Klerk e9eae2cc1e Log exception before sending to listeners
Change SpringApplication exception handling to log details before calling
the SpringApplicationRunListeners. Prior to this commit it wasn't possible
for a listener to shutdown logging.

Fixes gh-4680
Closes gh-4686
9 years ago
Phillip Webb fce75ebaa8 Fix checkstyle error
See gh-4765
See gh-4766
9 years ago
Matt Benson cc40dcebcf Use canonical paths for Undertow document root
Update `UndertowEmbeddedServletContainerFactory` so that the canonical
path is used when setting up the document root. Prior to this commit
Windows machines with `java.io.tmpdir` set to a tilde-compressed path
would cause problems.

Fixes gh-4765
Closes gh-4766
9 years ago
Jean de Klerk 199c88e51c Improve the consistency of the various JsonParser implementations
- Consistent error handling applied to BasicJsonParser,
  GsonJsonParser, JsonSimpleJsonParser and YamlJsonParser
- Add tests in AbstractJsonParserTests to verify consistency
- Rename tests for JsonSimpleJsonParser to match the name of the
  class under test.

Closes gh-4690
9 years ago
Andy Wilkinson e203a689bf Consider relaxed variants of target name when filtering property names
Previously, when ignoreUnknownFields was false and property names were
being filtered based on whether or not they begin with the target name,
relaxed variants of the target name were not considered. This resulted
in different delimiters resulting in a non-match. For example, the
property ENV_FOO_NAME would be filtered out when the target name
was env.foo.

This commit updates PropertiesConfigurationFactory to pass all of the
relaxed variants for the target name to the matcher. For the example
above one of those variants will be env_foo which matches ENV_FOO_NAME
due to the matching delimiter.

PropertiesConfigurationFactory was already creating a RelaxedNames
instance for the target name. The code has been reworked a little to
allow these relaxed names to be reused, thereby avoiding the cost of
computing all of the relaxed variants of the target name a second time.

Closes gh-4775
9 years ago
Phillip Webb 5a7dece144 Formatting 9 years ago
Phillip Webb 19056a1104 Log warning if scanning org or org.springframework
Update ConfigurationWarningsApplicationContextInitializer to also log
warnings if the user is scanning `org` or `org.springframework`.

Fixes gh-4777
9 years ago
Stephane Nicoll 9be4b57182 Add constants for well-known PropertySource names
Closes gh-4776
9 years ago
Stephane Nicoll e9dfb2292e Polish contribution
Closes gh-4753
9 years ago
Anand Shah ad1ae8df91 Add constants for banner location
Closes gh-4665
9 years ago
Phillip Webb 3e7863d4b4 Fix checkstyle issue
See gh-4769
9 years ago
Phillip Webb 447edd2c4e Allow gzip compression without `Content-Length`
Ensure that gzip compression is applied when the `Content-Length` header
is not specified. Prior to this commit Tomcat and Jetty would compress a
response that didn't contain the header, but Undertow would not.

Fixes gh-4769
9 years ago
Eddú Meléndez 1b81d9f0b5 Add support for server.server-header property
Add a `server.server-header` property which can be used to override the
`server` header usually sent back automatically by Tomcat/Jetty or
Undertow.

See https://www.owasp.org/index.php/Securing_tomcat for background.

Fixes gh-4461
Closes gh-4504
9 years ago
Phillip Webb 39077ee56c Extract ExitCodeGenerators class
Extract exit code logic from SpringApplication to a new
`ExitCodeGenerators` class so that it can be reused.

Fixes gh-4757
9 years ago
Ruben Dijkstra 3bd4771130 Protect against Math.abs() with Long.MIN_VALUE
Update RandomValuePropertySource to protect against the random source
returning Long.MIN_VALUE. In such cases the sign bit can't be unset and
prior to this commit the random value stayed negative.

Closes gh-4672
9 years ago
Phillip Webb 0489a3b4de Polish 9 years ago
Phillip Webb f3bcf94fb0 Refine validator cleanup logic
Refine the validator memory optimization so that only directly created
validators are nulled out. Also update the logic to ensure that
`destroy` is also called.

See gh-4734
9 years ago
Dave Syer fae14b409f Check that we own the validator before nulling it out
See gh-4734
9 years ago
Phillip Webb 2d2e4eea82 Merge branch '1.2.x' 9 years ago
Phillip Webb 2694605a4d Polish 9 years ago
Andy Wilkinson 53cc5f060b Merge branch '1.2.x' 9 years ago
Andy Wilkinson b36fe2cbd8 Cache outcome of checking to see if host supports ANSI output
Closes gh-4510
9 years ago
Dave Syer e8632d9feb Null out validator in ContextRefreshedEvent
This is an optimization that recognizes the need for Hibernate
validator to cache reflection data, but also that we don't need it
after the bulk of the work has been done on context refresh.

Fixes gh-4734
9 years ago
Andy Wilkinson bdc395f16e Merge branch '1.2.x' 9 years ago
Andy Wilkinson ae6971a61a Upgrade to Tomcat 8.0.30 and continue to use absolute redirects
Tomcat 8.0.30 has changed to using relative URIs in its redirects
by default. To avoid any problems that this behaviour change may
causes we override the default and configure Tomcat to continue to
use absolute URIs.

Closes gh-4715
9 years ago
Johnny Lim 12a921c200 Polish docs
Closes gh-4709
9 years ago
Andy Wilkinson e9aa7ca9a2 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 00b668b2c5 Only clean up logging system when root application context is closed
Previously, LoggingApplicationListener would clean up the logging
system in response to any application context with which it was
registered being closed. This caused problems when a child context was
closed. Specifically, closing the child context would cause any
SLF4J-based logging systems to unregister the JUL bridge handler
preventing an JUL logging being bridged into Logback or Log4J2.

This commit updates LoggingApplicationListener so that the logging
system is only cleaned up when a root application context is
closed.

Closes gh-4651
9 years ago
Andy Wilkinson 03d29fd68d Update test to cope with asynchronous writing of the access log
Previously, the test that verified that Undertow's access log could be
enabled and was written to the correct file expected the log to be
available as soon as the request to the server had completed. Undertow
writes the access log asynchronously so the test failed intermittently
due to a race between the access log being written and the test
asserting that it exists.

This commit updates the test to wait for up to 10 seconds for the
access log to be available.

See gh-4670
9 years ago
Andy Wilkinson 753341c9ff Add a test for enabling Undertow's access log and verify the file name
See gh-4670
9 years ago
Sebastian Hoß e233ea7f54 Fix undertow access_log file name
Undertow 1.3.2 changed the default access log file suffix from '.log'
to just 'log'. Thus we need to adapt the file name pattern to include
the missing dot.

Closes gh-4670
9 years ago
Vedran Pavic 884cae6f8d Add support for using ${application.title} in startup banners
This commit introduces a new property, application.title, that can
be used in a banner. Its value is resolved from the application
manifest's Implementation-Title attribute.

Closes gh-4603
9 years ago
Andy Wilkinson 8618ec89b1 Ensure that environment post processors are ordered correctly
Previously, ConfigFileApplicationListener would always add itself to the
end of the list of environment post processors loaded via
spring.factories. This meant that its order (highest precedence + 10)
would not be honoured and it would only be in the right place in the
list if any other post processors happened to have a higher precedence.

This commit updates ConfigFileApplicationListener to sort the list of
post processors using AnnotationAwareOrderComparator once its added
itself to the list.

Closes gh-4595
9 years ago
Andy Wilkinson 008f2a8874 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 0214fe4b82 Remove inconsistent synchronization from EmbeddedWebApplicationContext
Previously, EmbeddedWebApplicationContext used synchronized, but did
not do so consistently. It also synchronized on this so its lock was
exposed outside of the class, creating a risk of deadlock if a caller
synchronized incorrectly. Furthermore, not all fields on the class
were sychronized so the class wasn't truly thread-safe.

This commit attempts to rectify some of the problems above. The use
of synchronized has been dropped in favour of using a volatile field
for the embedded servlet container. Whenever this field is accessed,
a local variable is used to "cache" the value thereby preventing a
change on another thread from causing unwanted behaviour such as an
NPE.

Closes gh-4593
9 years ago
Jean de Klerk b00bccb7ca Upgrade liquibase to 3.4.2
Remove 3.4.1 logger workaround (adding package to default service). See
CORE-2436 on the liquibase tracker for more details.

Closes gh-4591
Closes gh-4625
9 years ago
Stephane Nicoll e6588dbf70 Make LOGGING_SYSTEM_BEAN_NAME public
Since the `LoggingSystem` may be retrieved very early during the context
initialization, we should do a lookup by name even if only one instance
of that bean is ultimately expected in the context.

The constant defining the bean name is now public to ease that use case.

Closes gh-4584
9 years ago
Stephane Nicoll d883f647ba Add test coverage for WebApplicationContextUtils
See gh-4370
9 years ago
Stephane Nicoll 9c412232d5 Improve log message with active profiles
Closes gh-4612
9 years ago
Stephane Nicoll 1ff070f6e9 Fix broken build 9 years ago
Dave Syer d6a424f94c Add support for UTF-8 in application.properties
Fixes gh-4622
9 years ago
Stephane Nicoll d9f09e46f8 Cherry-pick 398d06e
Fixed initially in #3725

The target attribute is effectively checked for null beforehand so this
additional defensive check can be removed.

Closes gh-4567
9 years ago
Johnny Lim 8ec00c35bf Polish
Closes gh-4572
9 years ago
Andy Wilkinson ea8107b6a5 Merge branch '1.2.x' 9 years ago
Johnny Lim fde70909ce Add missing else statement
Closes gh-4509
9 years ago
Andy Wilkinson 2fe0819495 Isolate multiple Undertow deployments
Previously, UndertowEmbeddedServletContainerFactory always used
Undertow’s default ServletContainer. This meant that if there were two
UndertowEmbeddedServletContainers created, they would share the same
ServletContainer and the second one that was created would overwrite
the deployment for the first. This resulted in a async request
handling failing as the attempt to look up the deployment for the
first embedded Undertow instance would incorrectly find the deployment
for the second.

This commit fixes the problem by ensuring that each 
UndertowEmbeddedServletContainerFactory uses a separate Undertow
ServletContainer instance.

Closes gh-4329
9 years ago
Spring Buildmaster 3f6f57a80e Next Development Version 9 years ago
Vedran Pavic d2fecd3ad4 Fix bad JSON syntax
Closes gh-4501
9 years ago
Johnny Lim 903cdf3ddd Polish 9 years ago
Johnny Lim 1e4f8fdd8e Polish 9 years ago
Johnny Lim 0a85281a66 Fix typos
Closes gh-4463
9 years ago
Johnny Lim e5b31beb68 Polish
This commit resolves typos and naming inconsistency.

Closes gh-4455
9 years ago
Eddú Meléndez bd709f30c5 Fix springProfile with multi profiles separated by comma and whitespace
Previously springProfile supported multi profiles separated by comma but
it doesn´t work if there are whitespaces. Now, springProfile will read
values cleaning whitespaces.

See gh-4445
9 years ago
Johnny Lim 4d9111606b Polish docs
Closes gh-4446
9 years ago
Phillip Webb 6ae021969b Use TestPropertySourceUtils to convert properties
Fixes gh-4384
9 years ago
Johnny Lim aa432daa3e Rename a test method to use dir instead folder
Closes gh-4434
9 years ago
Phillip Webb 8c0decac94 Clear list after handling uncaught exceptions
See gh-4423
9 years ago
Johnny Lim 4c1398148b Polish docs
Closes gh-4433
9 years ago
Phillip Webb a530221213 Ensure startup failures are only logged once
Update SpringApplication so that startup exceptions are only logged
once. A custom UncaughtExceptionHandler is now used when running in
the main thread to suppress errors that have already been logged.

Fixes gh-4423
9 years ago
Johnny Lim c87370085b Polish 9 years ago
Johnny Lim 83e8bfedb2 Use Ordered.HIGHEST_PRECEDENCE constants
Use Ordered.HIGHEST_PRECEDENCE rather than Integer.MIN_VALUE.

Closes gh-4335
9 years ago
Marcin Grzejszczak 19f141dc59 Add config properties before default properties
Update ConfigFileApplicationListener so that configuration properties
are added before `defaultProperties` if they exist.

Fixes gh-4362
9 years ago