Commit Graph

6990 Commits

Author SHA1 Message Date
Andy Wilkinson 87fe0b2ade Use a conventional delegation model in LaunchedURLClassLoader
When an application is run as an executable archive with nested jars,
the application's own classes need to be able to load classes from
within the nested jars. This means that the application's classes need
to be loaded by the same class loader as is used for the nested jars.
When an application is launched with java -jar the contents of the
jar are on the class path of the app class loader, which is the
parent of the LaunchedURLClassLoader that is used to load classes
from within the nested jars. If the root of the jar includes the
application's classes, they would be loaded by the app class loader
and, therefore, would not be able to load classes from within the
nested jars.

Previously, this problem was resolved by LaunchedURLClassLoader being
created with a copy of all of the app class laoder's URLs and by
using an unconventional delegation model that caused it to skip its
parent (the app class loader) and jump straight to its root class
loader. This ensured that the LaunchedURLClassLoader would load both
the application's own classes and those from within any nested jars.
Unfortunately, this unusual delegation model has proved to be
problematic. We have seen and worked around some problems with Java
Agents (see gh-4911 and gh-863), but there are others (see gh-4868)
that cannot be made to work with the current delegation model.

This commit reworks LaunchedURLClassLoader to use a conventional
delegate model with the app class loader as its parent. With this
change in place, the application's own classes need to be hidden
from the app class loader via some other means. This is now achieved
by packaging application classes in BOOT-INF/classes (and, for
symmetry, nested jars are now packaged in BOOT-INF/lib). Both the
JarLauncher and the PropertiesLauncher (which supports the executable
jar layout) have been updated to look for classes and nested jars in
these new locations.

Closes gh-4897
Fixes gh-4868
2016-02-19 14:15:40 +00:00
Andy Wilkinson 9be69f1ac7 Improve JDBC driver dependency management and class name test coverage
Previously, the DatabaseDriver enumeration contained entries for
some databases without having dependency management for the database
driver dependency. This leads to the possibility of a user inadvertently
using the wrong version of a driver where the class names do not match
those listed in the enumeration. A further problem is that we do not
test that the class names listed in the enumeration match the
names of Driver and XADataSource implementations in the database driver.

This commit completes the database driver dependency management so that
dependency management is provided for every driver that is both listed
in DatabaseDriver and available in Maven Central. It also adds tests
for DatabaseDriver that ensures that each class that is listed exists
and implements the required interface (java.sql.Driver or
javax.sql.XADataSource).

Closes gh-4946
2016-02-19 12:41:13 +00:00
Andy Wilkinson ff99bb0730 Set main thread's context class loader when starting Tomcat
When an app is deployed to Tomcat, all of the application's startup
is performed with a WebAppClassLoader being the thread context
class loader. When an app is using embedded Tomcat, the
WebAppClassLoader is created as part of the application starting but
is never set as the thread context class loader. This difference
in TCCL can cause problems. For example, it breaks the use of JNDI
during application startup with embedded Tomcat.

This commit updates the embedded Tomcat servlet container to set
the TCCL to be the WebAppClassLoader once the Tomcat context has
been started. Once Tomcat is stopped, it sets the TCCL back to the
ClassLoader that loaded it.

Closes gh-2308
2016-02-19 11:40:02 +00:00
Andy Wilkinson d6e0b5a165 Use @DirtiesContext to avoid unwanted context caching in the tests
We rarely use the same configuration in multiple test classes, but
Spring’s Test framework caches each context by default. For projects
with large numbers of integration tests, this can lead to tens of
contexts being cached. This increases memory usage, live thread count,
etc for no benefit.

This commit adds @DirtiesContext to the integration tests in
spring-boot, spring-boot-autoconfigure, and spring-boot-actuator so
that the context is closed once the test class has completed.

See gh-5141
2016-02-19 11:20:22 +00:00
Stephane Nicoll 166a27f16c Merge pull request #5128 from christophstrobl/issue/sd-redis-1.7.0-cluster-support
* pr/5128:
  Polish contribution
  Add Redis Cluster support
2016-02-18 15:27:46 +01:00
Stephane Nicoll a95568d3e8 Polish contribution
Closes gh-5128
2016-02-18 15:27:36 +01:00
Christoph Strobl fc22731420 Add Redis Cluster support
Introduce configuration options for "spring.redis.cluster.nodes" and
"spring.redis.cluster.max-redirects". Properties such as "timeout" and
others remain available via "spring.redis.timeout" and do not have to be
configured on the cluster itself.

See gh-5128
2016-02-18 15:27:36 +01:00
Andy Wilkinson d66bc7b1ee Merge branch '1.3.x' 2016-02-18 12:48:10 +00:00
Andy Wilkinson d3074a086c Increase timeout for startup of embedded Cassandra
The integration tests for the Spring Data Cassandra sample application
fail intermittently, apparently due to Cassandra failing to start
within the default timeout period of 10000ms.

In attempt to get the tests to pass reliably, this commit increases
the timeout to 60000ms (1 minute).
2016-02-18 12:46:31 +00:00
Stephane Nicoll 2c8d4421c2 Merge pull request #5167 from mkopylec/master
* pr/5167:
  Session couchbase starter entry
2016-02-18 11:34:02 +01:00
Mariusz Kopylec a048e4bd65 Session couchbase starter entry
Closes gh-5167
2016-02-18 11:33:38 +01:00
Stephane Nicoll c81ba0a951 Merge pull request #5171 from bclozel/gh-4683
* pr/5171:
  Polish contribution
  Add configuration key for GzipResourceResolver
2016-02-18 11:30:11 +01:00
Stephane Nicoll 888270bd03 Polish contribution
Closes gh-5171
2016-02-18 11:30:02 +01:00
Brian Clozel 4ca04abcb2 Add configuration key for GzipResourceResolver
This commit adds a new key that configures a GzipResourceResolver
in the resource handling chain.

Configuring an application with the following will add that resolver,
which checks for gzipped resources in the configured locations:

```
spring.resources.chain.gzipped=true
```

This means that if a resource "style.css" is requested, the
GzipResourceResolver will look for resources named "style.css.gz", which
should be a gzipped variant of the "style.css" file. Note that this
resolver only checks for variants if the client supports the "gzip"
encoding, as defined in the "Accept-Encoding" HTTP request headers.

Fixes #4683
2016-02-18 11:27:15 +01:00
Andy Wilkinson 4189e145bb Polishing
- Remove usages of deprecated APIs
 - Remove redundant version on dependency declaration
2016-02-17 16:53:09 +00:00
Andy Wilkinson 3b068c8bc2 Upgrade to Spring Integration 4.3.0.M1
Closes gh-5163
2016-02-17 16:42:39 +00:00
Andy Wilkinson e0ee46ec61 Upgrade to Spring AMQP 1.6.0.M1
Closes gh-5162
2016-02-17 16:42:39 +00:00
Stephane Nicoll b60e9e5cb9 Expose hints for Maps
This commit fixes the json parser so that hints for maps is also made
available.

Closes gh-5152
2016-02-17 15:25:03 +01:00
Stephane Nicoll d5732afa67 Add missing configuration entry 2016-02-17 11:00:33 +01:00
Stephane Nicoll 0e10dbc269 Polish documentation
Some connection pool specific keys were still advertized in the
documentation.
2016-02-17 10:07:45 +01:00
Stephane Nicoll 348f7ae9aa Merge branch '1.3.x' 2016-02-16 17:07:48 +01:00
Stephane Nicoll 62bc2abac0 Better document JTA properties
Closes gh-5143
2016-02-16 17:07:19 +01:00
Stephane Nicoll 90f0fc6ce3 Harmonize JTA properties
Previously, both Atomikos and Bitronix were bound on the `spring.jta`
namespace which makes very hard to figure out which property belong to
which implementation. Besides, `AtomikosProperties` only exposed public
setter which does not generate any useful meta-data.

This commit moves the external configuration for Atomikos and Bitronix to
`spring.jta.atomikos.properties` and `spring.jta.bitronix.properties`
respectively. It also improves the meta-data support for those two
namespaces.

Closes gh-5165
2016-02-16 16:44:50 +01:00
Stephane Nicoll ff5b05fed9 Override default consistency for Couchbase
Spring Data Couchbase 2.0 sets the default consistency to "update-after"
which is good for performance reason but can be quite confusing. Since
the team has decided to switch to "read-your-own-writes" in 2.1, Spring
Boot already offers the improved default right now.

This commit exposes an additional property that can be used to change
the Couchbase's default consistency.

Closes gh-5159
2016-02-16 14:28:09 +01:00
Stephane Nicoll 81fdc99fb0 Polish doc
See gh-3498
2016-02-16 13:45:48 +01:00
Andy Wilkinson a81cd5df74 Upgrade to Spring REST Docs 1.1.0.M1
Closes gh-5160
2016-02-16 12:25:26 +00:00
Stephane Nicoll 64a5cad09a Improve couchbase support
Expose an `auto-index` property that controls if views and indexes
should be created automatically.

Update the sample so that it uses this new property, lowering the manual
steps to make it working on a vanilla couchbase server.

See gh-3498
2016-02-16 11:42:14 +01:00
Andy Wilkinson ed04a5b12e Merge branch '1.3.x' 2016-02-16 09:48:14 +00:00
Andy Wilkinson fbbead622d Add dependency management for some more of Jetty's modules
Closes gh-5155
2016-02-16 09:47:23 +00:00
Stephane Nicoll 52950717e0 Polish 2016-02-16 09:34:26 +01:00
Stephane Nicoll a43b023217 Merge pull request #3499 from eddumelendez/gh-3498
* pr/3499:
  Polish contribution
  Add Couchbase support
2016-02-16 09:32:07 +01:00
Stephane Nicoll da3b49e024 Polish contribution
Closes gh-3499
2016-02-16 09:31:50 +01:00
Eddú Meléndez 76f1ca4188 Add Couchbase support
Closes gh-3498
2016-02-16 09:31:50 +01:00
Andy Wilkinson ecf11e0230 Merge branch '1.3.x' 2016-02-15 21:46:06 +00:00
Andy Wilkinson d69e0486c1 Allow Thymeleaf's LayoutDialect to be overridden
Closes gh-5151
2016-02-15 21:27:34 +00:00
Oliver Gierke e703997be2 Use new projection capabilities in Spring Data Hopper.
Uses interfaces instead of DTOs to implement projections. Works
around DATAJPA-864 [0].

[0] https://jira.spring.io/browse/DATAJPA-864
2016-02-15 15:19:54 +01:00
Stephane Nicoll b205e02e33 Upgrade to Spring Data Hopper M1
Closes gh-5120
2016-02-15 14:57:08 +01:00
Andy Wilkinson 1c365662b0 Don't leave so many threads lying around in the tests
See gh-5141
2016-02-12 17:39:14 +00:00
Andy Wilkinson ae08934e08 There may only be a single restart during RestarterTests.testRestart()
See gh-4097 and changes in 2522a5f
2016-02-12 16:43:15 +00:00
Stephane Nicoll 85cc885fd1 Merge branch '1.3.x' 2016-02-12 16:26:41 +01:00
Stephane Nicoll b726974bca Allow to easily customize ListenerContainerFactory
Previously, if one wants to create a custom `JmsListenerContainerFactory`
or `RabbitListenerContainerFactory`, a bunch of code from the auto-
configuration must be duplicated.

This commit introduces two services to configure such factory for JMS
and AMQP with the same sensible defaults that were applied by the
auto-configufrations.

Closes gh-5138
2016-02-12 16:16:44 +01:00
Andy Wilkinson 2522a5f9ef Call context.close() rather than shutdown hook in DevTools restart
Previously, when DevTools was restarting the application it would
use reflection to run all of the JVM's shutdown hooks. This was done
to close any SpringApplications' application contexts. Unfortunately,
it had the unwanted side-effect of running other shutdown hooks as
well.

The other shutdown hooks were often written with the, entirely
reasonable, expectation that they would only be called when the JVM
was shutting down. Calling them at another time could leave the
hook's library in an unexpected state. One such example is Log4J2
which was worked around in aaae4aa3 (see gh-4279). Another is the
problem with Eureka (see gh-4097). There's no work around for this
problem, even with reflective hackery, hence the change being made
here.

This commit updates the Restarter so that shutdown hooks are no longer
called during a restart. This removes the chance of a restart having
the unwanted side-effect of leaving a third-party library in a broken
state. RestartApplicationListener now prepares the Restarter with the
root application context, and the Restarter then closes it as part of
the restart. The changes have been tested with an application that
uses a single context and an application with a context hierarchy.

Closes gh-4097
2016-02-12 15:12:01 +00:00
Andy Wilkinson 6e3faecce6 Merge branch '1.3.x' 2016-02-12 13:18:02 +00:00
Andy Wilkinson 1c170b35ea Improve handling of connection failures in remote debug tunnel
Previously, if an application had been started without remote
debugging enabled, an attempt to connect to it via
RemoteSpringApplication and the HTTP tunnel would result in the
application being hammered by connection attempts for 30 seconds.

This commit updates the tunnel server to respond with Service
Unavailable (503) when a connection attempt is made and the JVM
does not have remote debugging enabled. When the client receives a
503 response, it now logs a warning message describing the possible
problem before closing the connection.

The client has also been updated to provide improved diagnostics when
a connection to the tunnel server cannot be established, for example
because the remote URL is incorrect, or the remote application isn't
running.

Lastly, the client has been updated so that it continues to accept
connections when a connection to the server is closed. This allows
the user to correct a problem with the remote application, such as
restarting it with remote debugging enabled, without having to also
restart the process that's running RemoteSpringApplication.

Closes gh-5021
2016-02-12 12:50:58 +00:00
Andy Wilkinson 11c9068d53 Merge branch '1.3.x' 2016-02-12 10:31:02 +00:00
Andy Wilkinson 607dba97f8 Only access parameters in WebRequestTraceFilter when they are included
Previously, WebRequestTraceFilter would call request.getParameterMap()
before deciding whether or not the parameters should be included in
the trace. For a POST request, this had the unwanted side-effect
of always reading the request body.

This commit updates WebRequestTraceFilter so that it checks that
parameters are to be included in the trace before calling
request.getParameterMap()

Closes gh-5089
2016-02-12 10:26:23 +00:00
Andy Wilkinson 0641d9af4f Merge branch '1.3.x' 2016-02-12 10:18:02 +00:00
Andy Wilkinson 815da8b845 Upgrade to Tomcat 8.0.32
Closes gh-5122
2016-02-12 10:17:09 +00:00
Andy Wilkinson 9836d6ef89 Merge branch '1.3.x' 2016-02-12 09:39:19 +00:00
Andy Wilkinson ac5c6f725c Correct the scope of the postgresql dependency in spring-boot-devtools 2016-02-12 09:39:05 +00:00