Commit Graph

137 Commits

Author SHA1 Message Date
Phillip Webb 8514064d5c Tweak FileSystemWatcherTests timing for Windows 2016-04-10 23:28:37 -07:00
Phillip Webb 6d23ce2ada Polish 2016-04-10 21:27:32 -07:00
Phillip Webb 6550bb4cf1 Polish 2016-04-07 12:20:10 -07:00
Andy Wilkinson 140e86bb97 Merge branch '1.3.x' 2016-04-07 17:51:17 +01:00
Andy Wilkinson 5e0ba6ea2e Consider jar's Class-Path attribute when getting changeable URLs
To overcome command length limits on Windows, IntelliJ IDEA may launch
an application with a single jar on the classpath that contains that
application's actual classpath in the Class-Path attribute of its
manifest. This would prevent DevTools restarts from working as it
only considered the single jar's URL when identifying changeable URLs
and ignored the URLs added to the classpath via the jar's manifest.

This commit updates ChangeableUrls when it is created from a
URLClassLoader to consider the Class-Path manifest attribute of any
jars in the class loader's URLs. This allows the full classpath to
be considered when identifying URLs that are changeable and that
need to be monitored for restart triggering.

Closes gh-5127
2016-04-07 17:44:38 +01:00
Andy Wilkinson 571973a51a Merge branch '1.3.x' 2016-04-06 11:43:52 +01:00
Johnny Lim ec83d97443 Remove a duplicate test
Closes gh-5615
2016-04-06 11:43:21 +01:00
Phillip Webb b398b3319c Rename @SpringApplicationTest -> @SpringBootTest
Rename @SpringApplicationTest to SpringBootTest and
@SpringApplicationContextLoader to @SpringBootContextLoader.

Fixes gh-5562
2016-04-04 22:36:58 -07:00
Andy Wilkinson 33f0ea3480 Rework SpringApplicationTest to support web modes
Rework the new testing support so that @SpringApplicationTest can be
used for standard integration tests, web integration tests with a
mock Servlet environment and web integration tests with an embedded
servlet container. This means that it a replacement for 1.3's
@IntegrationTest and @WebIntegrationTest and allows all
SpringApplication testing to be configured using a common annotation.

The old @IntegrationTest and @WebIntegrationTest along with their
supporting classes have been reinstated to their previous form (while
remaining deprecated). This should ensure that they continue to work
in 1.4 exactly as they did in 1.3 giving users a smooth path to
@SpringApplicationTest.

See gh-5477
2016-03-31 21:35:10 -07:00
Phillip Webb 893a6c32f3 Upgrade to checkstyle 6.17
Fixes gh-5547
2016-03-31 13:14:53 -07:00
Phillip Webb 0829a1bde8 Drop superfluous annotations
Update internal tests to drop annotations that can now
be inferred.

Fixes gh-5470
2016-03-23 22:19:36 -07:00
Phillip Webb c28f552883 Migrate SpringJUnit4ClassRunner to SpringRunner
Replace all existing SpringJUnit4ClassRunner references with the new
SpringRunner alias.

Fixes gh-5292
2016-03-23 22:18:18 -07:00
Phillip Webb 2f815a907a Migrate existing tests from deprecated package
Update the existing tests to use the relocated `spring-boot-test`
classes. Restructuring was achieved using the following command:

find . -type f -name '*.java' -exec sed -i '' \
-e s/org.springframework.boot.test.ConfigFileApplicationContextInitializer/\
org.springframework.boot.test.context.ConfigFileApplicationContextInitializer/g \
-e s/org.springframework.boot.test.EnvironmentTestUtils/\
org.springframework.boot.test.util.EnvironmentTestUtils/g \
-e s/org.springframework.boot.test.IntegrationTest/\
org.springframework.boot.test.context.IntegrationTest/g \
-e s/org.springframework.boot.test.IntegrationTestPropertiesListener/\
org.springframework.boot.test.context.IntegrationTestPropertiesListener/g \
-e s/org.springframework.boot.test.OutputCapture/\
org.springframework.boot.test.rule.OutputCapture/g \
-e s/org.springframework.boot.test.SpringApplicationConfiguration/\
org.springframework.boot.test.context.SpringApplicationConfiguration/g \
-e s/org.springframework.boot.test.SpringApplicationContextLoader/\
org.springframework.boot.test.context.SpringApplicationContextLoader/g \
-e s/org.springframework.boot.test.SpringBootMockServletContext/\
org.springframework.boot.test.mock.web.SpringBootMockServletContext/g \
-e s/org.springframework.boot.test.TestRestTemplate/\
org.springframework.boot.test.web.client.TestRestTemplate/g \
-e s/org.springframework.boot.test.WebIntegrationTest/\
org.springframework.boot.test.context.web.WebIntegrationTest/g {} \;

See gh-5293
2016-03-23 22:17:50 -07:00
Phillip Webb 644ae2c21a Merge branch '1.3.x' 2016-03-08 09:51:57 -08:00
Phillip Webb 5e722dae6a Polish 2016-03-08 09:37:13 -08:00
Andy Wilkinson 5009933788 Move to constructor injection in simple configuration classes
This commit updates "simple" configuration classes to use constructor
injection. Simple means that there are no optional dependencies
(@Autowired(required=false) is not used), and none of the dependencies
use generics.

Configuration classes that are not simple will be updated in a second
pass once https://jira.spring.io/browse/SPR-14015 has been fixed.

See gh-5306
2016-03-04 12:27:29 +00:00
Andy Wilkinson 367a4ed219 Merge branch '1.3.x' 2016-03-02 10:59:18 +00:00
Andy Wilkinson 40ffe4169b Improve DevTools non-embedded in-memory DB shutdown handling
Shutdown handling has been improved so that it will run after any
EntityManagerFactory beans have been closed. This ensures that Hibernate
can, if configured to do so, drop its schema during restart processing.
Without this change, a benign exception could be logged if the database
was shutdown before Hibernate.

Closes gh-5305
2016-03-02 10:55:29 +00:00
Andy Wilkinson cd6cacfb4f Merge branch '1.3.x' 2016-02-29 11:42:01 +00:00
Andy Wilkinson 7a4e061de5 Make DevTools DataSource auto-config back off without DataSourceProperties
Previously, if DataSourceAutoConfiguration had been explicitly excluded,
DevToolsDataSourceAutoConfiguration would cause refresh to fail due to
a missing DataSourceProperties bean. This commit corrects the condition
so that the auto-configuration is conditional on a DataSource bean and
a DataSourceProperties bean rather than only being conditional on one or
the other.

Closes gh-5269
2016-02-29 11:37:17 +00:00
Spring Buildmaster 225d877ab9 Next Development Version 2016-02-26 01:06:16 -08:00
Andy Wilkinson 44ddfcc7fa Upgrade copyright headers of all files changed in 2016 2016-02-25 12:09:42 +00:00
Andy Wilkinson 6075682e64 Polishing
- Code formatting
 - Javadoc warnings
 - Deprecation warnings
2016-02-24 17:05:54 +00:00
Phillip Webb 89b7704977 Extract spring-boot-test.jar
Relocate the `org.springframework.boot.test` package from the
`spring-boot.jar` to `spring-boot-test.jar`.

Fixes gh-5184
2016-02-19 19:28:37 -08:00
Andy Wilkinson 7512687cba Upgrade to Spring Session 1.1.0.RC1
Closes gh-5161
2016-02-19 16:19:52 +00: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 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
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 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
Andy Wilkinson 3894ff84e3 Merge branch '1.3.x' 2016-02-11 16:28:28 +00:00
Andy Wilkinson 31aa5ad8dd Remove redundant public modifier 2016-02-11 16:28:15 +00:00
Andy Wilkinson f3aa236e92 Merge branch '1.3.x' 2016-02-11 16:01:29 +00:00
Andy Wilkinson a8f4708ffb Shut down in-memory database when DevTools restarts the context
Previously an in-memory database that wasn’t pooled (an
EmbeddedDatabase) would be shutdown when the context restarted, but
an in-memory database wrapped in a connection pool was not. This meant
that the former would be be wiped clean after each restart, whereas the
latter would not. In addition to being inconsistent, this also
caused problems with schema.sql and data.sql scripts when using
DevTools. If you were using an in-memory database wrapped in a
connection pool, a failure may occur during a restart as the scripts
were not being run against in clean database.

This commit adds an auto-configured bean to DevTools that, when the
context is being closed, will execute “SHUTDOWN” if it identifies that
the DataSource is not an EmbeddedDatabase and is for an in-memory
database.

Closes gh-4699
2016-02-11 16:01:07 +00:00
Phillip Webb 7f9358f4d8 Use AssertJ in spring-boot-devtools
See gh-5083
2016-02-06 15:51:25 -08:00
Phillip Webb 516afcd2ca Polish 2016-02-06 15:02:12 -08:00
Phillip Webb fbaf209240 Move master to 1.4.0.BUILD-SNAPSHOT 2016-01-24 10:45:24 -08:00
Andy Wilkinson 4c1bb38878 Fix broken locking in Restarter.initialize
Closes gh-4955
2016-01-22 15:21:00 +00:00
Spring Buildmaster 504d3e97ba Next development version 2016-01-21 18:41:30 -08:00
Andy Wilkinson 77e350acc0 Polish contribution 2016-01-18 15:39:40 +00:00
Vladimir Tsanev 3e291ff04f Allow DevTools to find and configure Spring Session 1.1's RedisTemplate
Previously, when Spring Session 1.1.0.M1 and DevTools were declared as
dependencies the application failed to start, because
sessionRedisTemplate could not be resolved.

This commit relaxes the dependency for sessionRedisTemplate in
restartCompatibleRedisSerializerConfigurer from
RedisTemplate<String, ExpiringSession> to RedisTemplate<?, ?> and uses
the bean name in a @Qualifer to ensure that the right RedisTemplate
bean gets injected.

Fixes gh-4895
Closes gh-4896
2016-01-18 15:36:04 +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
Spring Buildmaster 8db59059a5 Next Development Version 2015-12-18 05:43:02 -08: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
mnhock ea016f5442 Remove redundant toString() call
Closes gh-4706
2015-12-11 13:43:30 +00:00
Phillip Webb 0489a3b4de Polish 2015-12-10 19:43:29 +00:00
Andy Wilkinson df9308c645 HttpTunnelServer should only check for disconnect after first connection
Previously, ServerThread would check for a disconnect as soon as it
had been started. This raced with it handling its first connection. If
the check for disconnect won the race it would incorrectly determine
that the disconnect timeout had been reached and wouldn’t respond to
the connection.

This commit updates ServerThread so that it only checks the disconnect
timeout once it’s handled at least one connection.

Closes gh-4668
2015-12-04 16:00:25 +00:00
Andy Wilkinson e4342075ab Fix class loading problem with DevTools and Spring Session with Redis
Previously, when a session attribute that had been stored in Redis was
being deserialized, the app class loader would be used. This would
result in a ClassCastException if the attribute was an instance of a
class visible to the restart class loader.

This commit auto-configures Spring Session’s RedisTemplate to use a
custom deserializer that uses the restart class loader when
deserializing session attributes.

Closes gh-3805
2015-12-04 11:58:52 +00:00