Commit Graph

163 Commits (d9d26cba1a01d0cc555a044fae62078e6188cc08)

Author SHA1 Message Date
Andy Wilkinson 7512687cba Upgrade to Spring Session 1.1.0.RC1
Closes gh-5161
9 years ago
Andy Wilkinson 4189e145bb Polishing
- Remove usages of deprecated APIs
 - Remove redundant version on dependency declaration
9 years ago
Andy Wilkinson ae08934e08 There may only be a single restart during RestarterTests.testRestart()
See gh-4097 and changes in 2522a5f
9 years ago
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
9 years ago
Andy Wilkinson 6e3faecce6 Merge branch '1.3.x' 9 years ago
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
9 years ago
Andy Wilkinson 9836d6ef89 Merge branch '1.3.x' 9 years ago
Andy Wilkinson ac5c6f725c Correct the scope of the postgresql dependency in spring-boot-devtools 9 years ago
Andy Wilkinson 3894ff84e3 Merge branch '1.3.x' 9 years ago
Andy Wilkinson 31aa5ad8dd Remove redundant public modifier 9 years ago
Andy Wilkinson f3aa236e92 Merge branch '1.3.x' 9 years ago
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
9 years ago
Phillip Webb 7f9358f4d8 Use AssertJ in spring-boot-devtools
See gh-5083
9 years ago
Phillip Webb 516afcd2ca Polish 9 years ago
Phillip Webb fbaf209240 Move master to 1.4.0.BUILD-SNAPSHOT 9 years ago
Andy Wilkinson 4c1bb38878 Fix broken locking in Restarter.initialize
Closes gh-4955
9 years ago
Spring Buildmaster 504d3e97ba Next development version 9 years ago
Andy Wilkinson 77e350acc0 Polish contribution 9 years ago
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
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
Spring Buildmaster 8db59059a5 Next Development Version 9 years ago
Kirill Vlasov ec2f33f986 Make loggers private static final
Apply consistency across all static loggers.

Closes gh-4784
9 years ago
mnhock ea016f5442 Remove redundant toString() call
Closes gh-4706
9 years ago
Phillip Webb 0489a3b4de Polish 9 years ago
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
9 years ago
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
9 years ago
Andy Wilkinson 256cad8980 Fix inconsistent synchronization in HttpTunnelServer.ServerThread
Previously, ServerThread.lastHttpRequestTime was written while
synchronized on this.httpConnections but was read without
synchronization. This could lead to a read of the field producing the
wrong value and cause premature connection timeout.

This commit moves the call to checkNotDisconnected into a block that
sychronizes on this.httpConnections, thereby ensuring that
lastHttpRequestTime can be read safely.

Closes gh-4668
9 years ago
Johnny Lim 8ec00c35bf Polish
Closes gh-4572
9 years ago
Johnny Lim efff4a0051 Polish
Closes gh-4554
9 years ago
Spring Buildmaster 3f6f57a80e Next Development Version 9 years ago
Johnny Lim 903cdf3ddd Polish 9 years ago
Johnny Lim 1e4f8fdd8e Polish 9 years ago
Phillip Webb 3e8cafaf97 Add support for `spring-devtools.properties`
Allow `META-INF/spring-devtools.properties` files to be used by
application developers to declare is specific jars should be included
or excluded from the RestartClassLoader.

A typical example where this might be used is a company that develops
it's own set of internal JARs that are used by developers but not
usually imported into their IDE.

See gh-3316
9 years ago
Phillip Webb 1204559815 Refine agent reloader detection
Fixes gh-4366
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
Phillip Webb 6c2ea4648f Polish 9 years ago
Andy Wilkinson 549f873941 Update RestarterTests to expect listener to be notified at least once 9 years ago
Andy Wilkinson aaae4aa3a1 Prevent restarts from switching off Log4J2-based logging
During a restart, the Restarter runs all registered shutdown hooks. This
breaks Log4J2 as it leaves it in a shutdown state that leaves logging
switched off such that no output it produced when the application starts
up again.

This commit introduces a new RestartListener abstraction.
RestartListeners are notified prior to the application being restarted.
A Log4J2-specific implementation is provided that prepares Log4J2 for
restart by removing any shutdown callbacks from its shutdown callback
registry. This prevents the restart from shutting down Log4J2, ensuring
that it still functions when the application restarts.

Closes gh-4279
9 years ago
Andy Wilkinson 833aac2b26 Drive EnvironmentPostProcessors from ConfigFileApplicationListener
Previously, ConfigFileApplicationListener was listed in spring.factories
as both an EnvironmentPostProcessor and an ApplicationListener. This
was problematic as ConfigFileApplicationListener is stateful and listing
it twice lead to two separate instances with separate state.

This commit restore ConfigFileApplicationListener to only being an
ApplicationListener. The driving of EnvironmentPostProcessors that was
performed by EnvironmentPostProcessingApplicationListener is now
performed by ConfigFileApplicationListener which adds itself as an
EnvironmentPostProcessor. This ensures that there’s only a single
instance of ConfigFileApplicationListener, allowing its state to be
managed correctly.

Closes gh-4258
9 years ago
Andy Wilkinson 0adf037410 Consider custom server.context-path when configuring dev tools endpoints
Previously, the auto-configuration of DevTools’ debug, restart, and
health handlers assumed that the server was running on its default
context path and, if server.context-path was set to a non-default value,
the handlers would not work as expected.

This commit updates the auto-configuration of the three handlers to 
consider the server’s context path when configuring their URIs. Now,
when a custom server context path is used, no further configuration is
required other than the inclusion of that context path when providing
the remote URL as an argument to RemoteSpringApplication.

Closes gh-4301
9 years ago
Stephane Nicoll 40c2c6db08 Clean remote url if necessary
Make sure that the remote URL does not contain a trailing slash.

Closes gh-4297
9 years ago
Phillip Webb fe42ced7ab Fix checkstyle 9 years ago
Johnny Lim 300387d995 Replace Base64Encoder with Base64Utils
Replace the custom Base64Encoder class with Spring's Base64Utils which
since 4.2 can encode bytes using Java 8's encoder, commons-digest or
Java 6's JAX-B encoder.

Closes gh-4189
9 years ago
Phillip Webb 634bb770b2 Organize imports with new settings
See gh-4234
9 years ago
Phillip Webb 5150e051c0 Allow remote restart to work with nested JARs
Update remote restart support so that JARs multi-module projects work.

Fixes gh-4040
9 years ago
Phillip Webb 6333426cbf Reformat package-info.java files with Eclipse Mars 9 years ago
Phillip Webb 04074fece1 Merge branch '1.2.x' 9 years ago
Andy Wilkinson 46c397007c Avoid ClassCastExceptions in DevTools when using Spring HATEOAS
Spring HATEOAS’s DummyInvocationUtils, that is used by
ControllerLinkBuilder, uses Objenesis. By default, Objenesis caches
the instances that it creates and uses the class name as the cache key.
This is problematic when DevTools’ restart support is enabled as the
class loader changes with each restart and ClassCastExceptions occur
due to Objenesis returning a cached instance that was created by an
old restart class loader.

This commit works around the problem described above by auto-configuring
a bean that uses reflection to replace DummyInvocationUtils’ default
Objenesis instance with one that has caching disabled.

Closes gh-3784
9 years ago
Phillip Webb c9fb9916b8 Reformat code using Eclipse Mars 9 years ago
Andy Wilkinson 377107c4ff Correct timeout logic when awaiting exception in LiveReloadServerTests 9 years ago
Andy Wilkinson b7ecccf0a3 Fix race condition in LiveReloadServerTests.clientClose 9 years ago
Andy Wilkinson 60d508cda2 Fix FileSystemWatcherTests.sourceFolderMustExist on Windows 9 years ago
Phillip Webb c3b7764b72 Polish 9 years ago
Phillip Webb fe8e8df701 Fix failing LocalDevToolsAutoConfigurationTests
Looks like a file was missed from the commit.

See gh-3851
9 years ago
Andy Wilkinson 315e63b017 Allow default DevTools properties to be overridden
Previously the default DevTools property source was added in first place
to the environment’s property sources in an unordered environment
post-processor. This made it difficult to override them.

This commit updates the post-processor to be ordered with lowest
precedence and to add the property source in last place. This should
allow any other property sources and to override the defaults.

Closes gh-3851
9 years ago
Andy Wilkinson 434d46f583 Add support for using RemoteSpringApplication behind a proxy
This commit adds two new properties, spring.devtools.remote.proxy.host
and spring.devtools.remote.proxy.port that can be used to configure
RemoteSpringApplication to connect to the remote application through
an HTTP proxy.

Closes gh-3968
9 years ago
Phillip Webb db0212b834 Allow spring-boot-devtools to work with JRebel
Update devtools to detect JRebel and disable application restarts. Other
features (such as LiveReload) can still be used.

Fixes gh-3095
9 years ago
Andy Wilkinson 1f4dc77715 Improve error message when a non-directory is added to FileSystemWatcher
Previously, if a file or non-existent directory was added to
FileSystemWatcher, it would fail with the message “Folder must not be a
file”. While it suggests that the folder needs to be a directory, it
doesn’t make it clear that it also needs to exist. It also doesn’t
tell the user which folder caused the problem.

This commit updates the message to make it clear that the folder must
exist and must be a directory, and the include the name of the
problematic folder in the error message.

Closes gh-3918
9 years ago
Phillip Webb 49583c0aa3 Limit spring.factories in RemoteSpringApplication
Update RemoteSpringApplication so that initializers and listeners are
prescribed and not loaded from spring.factories.

Fixes gh-3925
9 years ago
Craig Andrews 84da5a26a7 Add `git.properties` to default devtools excludes
Update `DevToolsProperties` to exclude `git.properties` files.

Prior to this commit any application configured to write `git.properties`
could trigger unexpected application restarts. The problem is particularly
prevalent when using Eclipse M2E in combination with the
`git-commit-id-plugin`.

Closes gh-3938
9 years ago
Andy Wilkinson 6c59e75874 Update tests to align with changes made in 8094076
See gh-3900
9 years ago
Andy Wilkinson 80940764f6 Do not trigger a restart when a test class is changed
Previously, dev tools would restart the application when any .class
file changed. This included test classes. This commit updates the
default excludes to ignore any classes with a name that ends in 
Test.class or Tests.class.

Closes gh-3900
9 years ago
Phillip Webb e674d751de Polish Javadoc 9 years ago
Phillip Webb e07df7e4c6 Remove redundant modifiers 9 years ago
Phillip Webb 6e29ee4557 Polish 9 years ago
Phillip Webb 67402405db Reformat code 9 years ago
Phillip Webb 2615990ffb Organize imports 9 years ago
Andy Wilkinson efee06fd9b Only configure remove devtools security if Spring Security is enabled
Previously, RemoteDevToolsAutoConfiguration would try to configure
Spring Security if it was on the classpath. This led to a failure if
Spring Security was on the classpath but its auto-configuration was
disabled.

This commit updates the auto-configuration to be conditional on the
presence of Spring Security’s ObjectPostProcessor bean.

See gh-3889
9 years ago
Andy Wilkinson e2862390ee Allow anonymous access to devtools remote server
Previously, if an app had Spring Security on the classpath the remote
devtools server would be secured using basic authentication. This
prevented RemoteSpringApplication from uploading changes to the server
as they would be rejected with a 401.

This commit updates RemoteDevToolsAutoConfiguration to allow anonymous
access to the remote server. CSRF protection is also disabled so that
POST requests without a CSRF token will be accepted.

Closes gh-3889
9 years ago
Phillip Webb 4aa2fed48b Revert "configure JRE that is different from compiler target level"
This reverts commit 678f36cfef.
9 years ago
Phillip Webb 6193b640a4 Polish 9 years ago
Huang YunKun 4e410681aa Disable resource cache when DevTools is enabled
Closes gh-3794
Closes gh-3739
9 years ago
Martin Lippert 678f36cfef configure JRE that is different from compiler target level 9 years ago
Stephane Nicoll 7c0c953f81 Add value alias for SpringApplicationConfiguration
Given that Spring Boot uses java config accross the board, a new `value`
attribute is now aliased to the existing `classes` attribute such that
one could write the following:

@SpringApplicationConfiguration(MyConfig.class)
public class MyTest {}

Closes gh-3635
9 years ago
Stephane Nicoll 3c91781bee Add additional exclude property
The default value of `spring.devtools.restart.exclude` is quite long and
any override requires to copy/paste it to add additional exclusions. To
avoid that, a new `spring.devtools.restart.additional-exclude` property
has been added.

Both properties are now used to compute the full list of exclusions that
is used by PatternClassPathRestartStrategy.

Closes gh-3774
9 years ago
Stephane Nicoll 0d7ee8a2df Fix default value of restarter meta-data
Closes gh-3773
9 years ago
Andy Wilkinson 8067a53682 Prevent run failures in tests from polluting LoggerContext 9 years ago
Andy Wilkinson 9e88dced88 Update devtools to customise environment before app context is refreshed
Prior to this commit, the devtools used bean factory post processors to
configure the environment with custom, development-time properties. This
meant that the environment was configured as part of the application
context being refreshed. Crucially, this happened after any property
conditions were evaluated making it impossible for the devtools to
change the default auto-configuration behaviour for a bean or
configuration class that was conditional on a property.

This commit moves the configuration of the environment into an
ApplicationListener that listens for the
ApplicationEnvironmentPreparedEvent which is published as soon as the
Environment has been prepared and before the application context is
refreshed.

Closes gh-3726
9 years ago
Andy Wilkinson 4a25bae143 Allow additional paths that trigger a reload/restart to be configured
Previously, only folders on the classpath would be watched and used
to trigger a restart/reload of the application. This commit adds a
new property spring.devtools.restart.additional-paths that can be
used to configure additional paths that should be watched for
changes. When a change occurs in one of those paths a restart or
reload will be triggered, depending on the full restart exclude
patterns configured via the existing spring.devtools.restart.exclude
property.

Closes gh-3469
9 years ago
Andy Wilkinson 2a5a32b603 Add auto-configuration for H2’s web console
Three conditions must be met for the console to be enabled:

 - H2 is on the classpath
 - The application is a web application
 - spring.h2.console.enabled is set to true

If spring-boot-devtools is on the classpath, spring.h2.console.enabled
will be set to true automatically. Without the dev tools, the enabled
property will have to be set to true in application.properties.

By default, the console is available at /h2-console. This can be
configured via the spring.h2.console.path property. The value of this
property must begin with a '/'.

When Spring Security is on the classpath the console will be secured
based on the user's security.* configuration. When the console is
secured, CSRF protection is disabled and frame options is set to
SAMEORIGIN for its path. Both settings are required in order for the
console to function.

Closes gh-766
9 years ago
izeye ee6fc8d917 Fix typos
Closes gh-3608
9 years ago
Stephane Nicoll 42e230192f Polish 9 years ago
Phillip Webb d2133687b0 Use persistent servlet session with DevTools
Set `server.session.persistent=true` when running DevTools to ensure
persistent sessions are used.

Fixes gh-3530
9 years ago
izeye f4589e7cc3 Fix typos
Closes gh-3504
9 years ago
Stephane Nicoll 97634e85ac Remove unnecessary keyword 9 years ago
izeye 7e49a02356 Fix Restarter.setEnabled() to use parameter
Closes gh-3370
10 years ago
Phillip Webb 35379f627a Polish 10 years ago
izeye e98b2a1a33 Remove System.out.println()
Closes gh-3395
10 years ago
izeye b4f636b33f Fix typo
Closes gh-3411
10 years ago
izeye dccb0b7736 Fix typo
Fixes gh-3357
10 years ago
izeye df33830fb6 Polish
Closes gh-3346
10 years ago
izeye 0dc096f905 Fix typo
Closes gh-3333
10 years ago
Phillip Webb 7879743b9f Polish 10 years ago
izeye 286c98d716 Use `bytes.length` in Base64Encoder loop
Update Base64Encoder to use `bytes.length` instead of `encoded.length`
when lopping over the bytes.

Fixes gh-3314
10 years ago
izeye 98ce54c4c3 Fix typo in test methods' names 10 years ago
Phillip Webb 61fc4f3f12 Polish copyright headers 10 years ago
Phillip Webb d3007fae94 Polish formatting 10 years ago
Andrew Landsverk 487ab1a60a Prevent restart when META-INF/maven/** changes
These files are modified by Eclipse for some reason when you change files
like Thymeleaf HTML files. `META-INF/maven/**` has been added to the
default exclusion.

Closes gh-3295
Closes gh-3297
10 years ago
Phillip Webb 099db11754 Don't quit application on restart failures
Update `Restarter` to support a `FailureHandler` strategy that can be
used to determine how to deal with errors. The
`LocalDevToolsAutoConfiguration` now uses a strategy that doesn't quit
the application, but instead continues to wait for further file changes.

This helps make restart much more usable in situations where you
accidentally break code.

Fixes gh-3210
10 years ago
Phillip Webb 24fc94461b Polish 10 years ago