Commit Graph

1301 Commits

Author SHA1 Message Date
Andy Wilkinson
295dc65b78 Fix LoggingSystem tests following System property changes 2016-02-11 19:38:47 +00:00
Andy Wilkinson
7787321db4 Polishing 2016-02-11 18:02:04 +00:00
Andy Wilkinson
ddfadce94d Set all documented system properties in LoggingApplicationListener
Closes gh-5073
2016-02-11 17:52:16 +00:00
Stephane Nicoll
594c8910c5 Clarify precedence of property sources
When the `locations` attribute is set for a given bean annotated with
`@ConfigurationProperties`, the configuration at these specified
locations take precedence over any other property sources. This means
that such values can't be overridden by a system property or a command
line switch for instance.

This commit clarifies this rules in the documentation.

Closes gh-5111
2016-02-11 14:49:11 +01:00
Andy Wilkinson
29c7b93640 Update SpringApplicationBuilder to pass args to parent when it's run
Closes gh-5103
2016-02-08 16:02:03 +00:00
Andy Wilkinson
c0a2c88da1 Stop referring to optional classes in BeanDefinitionLoader’s signature
Previously, BeanDefinitionLoader declared a field of type
GroovyBeanDefinitionReader which is a GroovyObject subclass. This is
problematic as BeanDefinitionLoader is always loaded but Groovy is an
optional dependency. Even on a JVM where class verification is performed
lazily, this can still cause problems if something reflectively tries
to access the class’s declared fields. On a JVM where classes are
verified at load time, it would be impossible to start a Spring Boot
application without having Groovy on the classpath.

This commit changes the field to be a BeanDefinitionReader, removing
the indirect reference to GroovyObject form BeanDefinitionLoader’s
signature. The reader is downcast to a GroovyBeanDefinitionReader in the
body of a method body that will only be invoked when Groovy is on the
classpath.

Closes gh-5040
2016-02-04 13:52:13 +00:00
Phillip Webb
43a5b77256 Ensure logback is reset after test
Update SpringBootJoranConfiguratorTests to ensure that logback
is left in a sane state. Prior to this commit, running all tests
in eclipse would fail due to ErrorPageFilterTests expecting
specific log output.
2016-02-03 20:56:45 -08:00
Johnny Lim
9a31e02806 Polish
Closes gh-5013
2016-01-24 19:13:01 +01:00
Spring Buildmaster
504d3e97ba Next development version 2016-01-21 18:41:30 -08:00
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
2016-01-21 15:31:33 -08:00
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
2016-01-21 15:13:37 -08:00
Phillip Webb
cf93f84e87 Polish 2016-01-21 14:15:49 -08:00
Matt Benson
34b1de6c39 Add mainApplicationClass accessor to SpringApplication
Closes gh-4801
2016-01-21 10:26:43 +00:00
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
2016-01-21 10:22:16 +00:00
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
2016-01-21 10:20:26 +01:00
Andy Wilkinson
1dd166691d Merge branch '1.2.x' 2016-01-19 10:37:10 +00:00
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
2016-01-19 10:37:02 +00:00
Stephane Nicoll
46470934d7 Fix log message
Closes gh-4969
2016-01-19 09:38:25 +01:00
Stephane Nicoll
c57588ac09 Merge branch '1.2.x' 2016-01-19 09:35:10 +01:00
Stephane Nicoll
2ceadd705b Fix documentation of logging.path and logging.file
See gh-4969
2016-01-19 09:33:05 +01:00
Andy Wilkinson
da4504118e Merge branch '1.2.x' 2016-01-18 15:19:57 +00:00
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
2016-01-18 15:19:43 +00:00
Phillip Webb
13db85f84b Add ExitCodeExceptionMapper support
Add ExitCodeExceptionMapper strategy interface which can be used to map
exceptions to exit codes.

Closes gh-4803
2016-01-14 11:55:40 +00:00
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
2016-01-13 16:22:35 +00:00
Phillip Webb
152ee95261 Polish 2016-01-13 14:47:21 +00:00
Phillip Webb
a20cd2de02 Publish ExitCodeEvent when possible
Update SpringApplication to publish an ExitCodeEvent when a valid exit
code is known.

Fixes gh-4804
2016-01-13 13:14:40 +00:00
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
2016-01-13 12:31:37 +00:00
Phillip Webb
d2fed8bb07 Polish 2016-01-13 11:58:42 +00:00
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
2016-01-12 16:14:11 +01:00
Stephane Nicoll
a835912c04 Merge branch '1.2.x' 2015-12-28 14:35:49 +01:00
Stephane Nicoll
b94c7c6a1d Guard instantiation of Tomcat's ErrorPage
Closes gh-4839
2015-12-28 14:35:35 +01:00
Johnny Lim
c39df05652 Polish test
Closes gh-4837
2015-12-24 07:43:48 +01:00
Stephane Nicoll
3e25d99f4e Add test to validate log42-spring.xml location
See gh-4809
2015-12-21 09:13:58 +01:00
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
2015-12-18 14:46:11 +00:00
Spring Buildmaster
8db59059a5 Next Development Version 2015-12-18 05:43:02 -08:00
Johnny Lim
c09a14a128 Fix typos
Closes gh-4806
2015-12-18 12:58:35 +01:00
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
2015-12-17 18:16:49 +00:00
Phillip Webb
f96dea7011 Polish 2015-12-17 13:52:47 +00:00
Stephane Nicoll
bb736e255b Fix SNAPSHOT version 2015-12-17 14:15:14 +01:00
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
2015-12-17 11:30:34 +00:00
Phillip Webb
ec2064d981 Remove TODO
See gh-4796
2015-12-17 09:51:33 +00:00
Phillip Webb
ff2addb321 Fix checkstyle 2015-12-16 22:54:01 +00:00
Phillip Webb
40abd13813 Be defensive about hiding log errors
Ensure that log configuration errors always get reported.
2015-12-16 22:25:13 +00:00
Kirill Vlasov
ec2f33f986 Make loggers private static final
Apply consistency across all static loggers.

Closes gh-4784
2015-12-16 21:02:53 +00:00
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
2015-12-16 20:59:33 +00:00
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
2015-12-16 17:48:28 +00:00
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
2015-12-16 10:33:57 +00:00
Phillip Webb
fce75ebaa8 Fix checkstyle error
See gh-4765
See gh-4766
2015-12-15 15:09:58 +00:00
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
2015-12-15 14:56:23 +00:00
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
2015-12-15 14:06:00 +00:00