Commit Graph

1311 Commits

Author SHA1 Message Date
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
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
2015-12-15 13:18:21 +00:00
Phillip Webb
5a7dece144 Formatting 2015-12-15 13:15:35 +00:00
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
2015-12-15 13:13:42 +00:00
Stephane Nicoll
9be4b57182 Add constants for well-known PropertySource names
Closes gh-4776
2015-12-15 11:54:10 +01:00
Stephane Nicoll
e9dfb2292e Polish contribution
Closes gh-4753
2015-12-14 18:13:24 +01:00
Anand Shah
ad1ae8df91 Add constants for banner location
Closes gh-4665
2015-12-14 18:08:29 +01:00
Phillip Webb
3e7863d4b4 Fix checkstyle issue
See gh-4769
2015-12-14 11:55:50 +00:00
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
2015-12-14 11:44:21 +00:00
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
2015-12-12 21:24:29 +00:00
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
2015-12-11 18:10:40 +00:00
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
2015-12-11 15:52:17 +00:00
Phillip Webb
0489a3b4de Polish 2015-12-10 19:43:29 +00:00
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
2015-12-10 19:43:29 +00:00
Dave Syer
fae14b409f Check that we own the validator before nulling it out
See gh-4734
2015-12-10 16:04:31 +00:00
Phillip Webb
2d2e4eea82 Merge branch '1.2.x' 2015-12-10 15:01:29 +00:00
Phillip Webb
2694605a4d Polish 2015-12-10 14:43:00 +00:00
Andy Wilkinson
53cc5f060b Merge branch '1.2.x' 2015-12-10 11:25:00 +00:00
Andy Wilkinson
b36fe2cbd8 Cache outcome of checking to see if host supports ANSI output
Closes gh-4510
2015-12-10 11:15:50 +00:00
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
2015-12-09 17:33:07 +00:00
Andy Wilkinson
bdc395f16e Merge branch '1.2.x' 2015-12-09 11:58:00 +00:00
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
2015-12-09 11:55:07 +00:00
Johnny Lim
12a921c200 Polish docs
Closes gh-4709
2015-12-09 09:49:42 +01:00
Andy Wilkinson
e9aa7ca9a2 Merge branch '1.2.x' 2015-12-03 14:35:21 +00:00
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
2015-12-03 14:01:32 +00:00
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
2015-12-03 13:25:07 +00:00
Andy Wilkinson
753341c9ff Add a test for enabling Undertow's access log and verify the file name
See gh-4670
2015-12-03 12:44:11 +00:00
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
2015-12-03 12:43:58 +00:00
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
2015-12-02 10:09:42 +00:00
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
2015-12-01 15:40:03 +00:00
Andy Wilkinson
008f2a8874 Merge branch '1.2.x' 2015-12-01 15:11:29 +00:00
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
2015-12-01 14:55:53 +00:00
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
2015-11-30 10:33:56 +01:00
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
2015-11-27 15:53:40 +01:00
Stephane Nicoll
d883f647ba Add test coverage for WebApplicationContextUtils
See gh-4370
2015-11-27 15:22:29 +01:00
Stephane Nicoll
9c412232d5 Improve log message with active profiles
Closes gh-4612
2015-11-26 16:25:52 +01:00
Stephane Nicoll
1ff070f6e9 Fix broken build 2015-11-26 16:23:48 +01:00
Dave Syer
d6a424f94c Add support for UTF-8 in application.properties
Fixes gh-4622
2015-11-26 15:09:50 +00:00
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
2015-11-23 10:43:44 +01:00
Johnny Lim
8ec00c35bf Polish
Closes gh-4572
2015-11-21 08:12:21 +01:00
Andy Wilkinson
ea8107b6a5 Merge branch '1.2.x' 2015-11-18 11:55:27 +00:00