Commit Graph

245 Commits

Author SHA1 Message Date
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
Andy Wilkinson 4c1bb38878 Fix broken locking in Restarter.initialize
Closes gh-4955
2016-01-22 15:21:00 +00: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
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
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
2015-12-03 10:57:14 +00:00
Johnny Lim 8ec00c35bf Polish
Closes gh-4572
2015-11-21 08:12:21 +01:00
Johnny Lim efff4a0051 Polish
Closes gh-4554
2015-11-20 11:02:08 +01:00
Johnny Lim 903cdf3ddd Polish 2015-11-13 21:45:43 -08:00
Johnny Lim 1e4f8fdd8e Polish 2015-11-13 18:06:31 -08:00
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
2015-11-13 10:32:44 -08:00
Phillip Webb 1204559815 Refine agent reloader detection
Fixes gh-4366
2015-11-11 21:33:54 -08:00
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
2015-11-10 23:02:13 -08:00
Phillip Webb 6c2ea4648f Polish 2015-11-03 20:36:20 -08:00
Andy Wilkinson 549f873941 Update RestarterTests to expect listener to be notified at least once 2015-10-29 15:59:12 +00:00
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
2015-10-29 14:40:19 +00:00
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
2015-10-28 18:58:19 +00:00
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
2015-10-28 17:22:57 +00:00
Stephane Nicoll 40c2c6db08 Clean remote url if necessary
Make sure that the remote URL does not contain a trailing slash.

Closes gh-4297
2015-10-26 10:28:27 +01:00
Phillip Webb fe42ced7ab Fix checkstyle 2015-10-20 17:35:49 -07:00
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
2015-10-20 16:12:56 -07:00
Phillip Webb 634bb770b2 Organize imports with new settings
See gh-4234
2015-10-19 12:58:34 -07:00
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
2015-10-14 01:31:10 -07:00
Phillip Webb 6333426cbf Reformat package-info.java files with Eclipse Mars 2015-10-09 13:54:25 -07:00
Phillip Webb 04074fece1 Merge branch '1.2.x' 2015-10-09 13:39:09 -07:00
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
2015-10-08 18:53:25 +01:00
Phillip Webb c9fb9916b8 Reformat code using Eclipse Mars 2015-10-07 23:37:10 -07:00
Andy Wilkinson 377107c4ff Correct timeout logic when awaiting exception in LiveReloadServerTests 2015-10-07 13:55:18 +01:00
Andy Wilkinson b7ecccf0a3 Fix race condition in LiveReloadServerTests.clientClose 2015-10-07 13:39:59 +01:00
Andy Wilkinson 60d508cda2 Fix FileSystemWatcherTests.sourceFolderMustExist on Windows 2015-10-05 17:32:07 +01:00
Phillip Webb c3b7764b72 Polish 2015-10-02 11:25:56 -07:00
Phillip Webb fe8e8df701 Fix failing LocalDevToolsAutoConfigurationTests
Looks like a file was missed from the commit.

See gh-3851
2015-10-02 09:44:59 -07:00
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
2015-10-02 16:38:45 +01:00
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
2015-10-02 10:37:32 +01:00
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
2015-09-30 15:48:20 -07:00
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
2015-09-30 10:54:51 +01:00
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
2015-09-28 14:33:38 -07:00
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
2015-09-23 23:56:43 -07:00
Andy Wilkinson 6c59e75874 Update tests to align with changes made in 8094076
See gh-3900
2015-09-21 16:55:20 +01:00
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
2015-09-21 16:22:47 +01:00
Phillip Webb e674d751de Polish Javadoc 2015-09-08 17:01:36 -07:00
Phillip Webb e07df7e4c6 Remove redundant modifiers 2015-09-08 17:01:30 -07:00
Phillip Webb 6e29ee4557 Polish 2015-09-08 16:04:30 -07:00
Phillip Webb 67402405db Reformat code 2015-09-08 14:56:40 -07:00
Phillip Webb 2615990ffb Organize imports 2015-09-08 14:40:35 -07:00
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
2015-09-03 17:48:43 +01:00
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
2015-09-03 17:36:22 +01:00
Phillip Webb 6193b640a4 Polish 2015-09-02 23:44:19 -07:00
Huang YunKun 4e410681aa Disable resource cache when DevTools is enabled
Closes gh-3794
Closes gh-3739
2015-08-24 10:53:03 +02:00
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
2015-08-19 17:09:34 +02:00
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
2015-08-19 14:08:05 +02:00
Stephane Nicoll 0d7ee8a2df Fix default value of restarter meta-data
Closes gh-3773
2015-08-19 11:59:05 +02:00
Andy Wilkinson 8067a53682 Prevent run failures in tests from polluting LoggerContext 2015-08-17 20:37:00 +01:00
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
2015-08-17 20:03:48 +01:00
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
2015-08-05 12:43:09 +01:00
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
2015-08-05 10:54:03 +01:00
izeye ee6fc8d917 Fix typos
Closes gh-3608
2015-07-28 08:54:47 +02:00
Stephane Nicoll 42e230192f Polish 2015-07-24 07:19:53 +02:00
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
2015-07-16 17:29:20 -07:00
izeye f4589e7cc3 Fix typos
Closes gh-3504
2015-07-15 15:45:02 +02:00
Stephane Nicoll 97634e85ac Remove unnecessary keyword 2015-07-09 14:33:01 +02:00
izeye 7e49a02356 Fix Restarter.setEnabled() to use parameter
Closes gh-3370
2015-07-06 14:47:08 -07:00
Phillip Webb 35379f627a Polish 2015-07-05 22:34:36 -07:00
izeye e98b2a1a33 Remove System.out.println()
Closes gh-3395
2015-07-03 18:26:14 -07:00
izeye b4f636b33f Fix typo
Closes gh-3411
2015-07-03 02:19:47 -07:00
izeye dccb0b7736 Fix typo
Fixes gh-3357
2015-06-30 00:43:00 -07:00
izeye df33830fb6 Polish
Closes gh-3346
2015-06-29 06:15:09 -07:00
izeye 0dc096f905 Fix typo
Closes gh-3333
2015-06-26 08:21:04 +02:00
Phillip Webb 7879743b9f Polish 2015-06-25 12:00:48 -07:00
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
2015-06-24 21:08:10 -07:00
izeye 98ce54c4c3 Fix typo in test methods' names 2015-06-24 20:36:01 -07:00
Phillip Webb 61fc4f3f12 Polish copyright headers 2015-06-23 10:22:14 -07:00
Phillip Webb d3007fae94 Polish formatting 2015-06-23 09:54:21 -07:00
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
2015-06-23 14:05:25 +02:00
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
2015-06-11 21:46:21 -07:00
Phillip Webb 24fc94461b Polish 2015-06-11 10:44:52 -07:00
Stephane Nicoll fcb45a4bb7 Polish devtools documentation
See gh-3088
2015-06-11 09:33:09 +02:00
Phillip Webb f0bba46d45 Tweak devtools restart exclusion patterns 2015-06-10 22:06:03 -07:00
Phillip Webb 88c693c6e1 Provide a way to disable the Restarter
Allow the Restarter to be disabled via a System property.

Fixes gh-3173
2015-06-10 13:10:00 -07:00
Stephane Nicoll 6bc4df5690 Fix meta-data for spring.devtools.remote
See gh-3086
2015-06-09 14:01:56 +02:00
Phillip Webb c4dc381a21 Attempt to fix failing build 2015-06-09 00:03:23 -07:00
Phillip Webb 9929e39124 Allow devtools properties in `user.home`
Support loading a `.spring-boot-devtools.properties` file from the
users home folder. The property file can be used to customize settings
that make sense on a per-user basis, but might not want to be checked
into the project.

Fixes gh-3151
2015-06-08 23:46:24 -07:00
Phillip Webb d0349879c3 Allow custom restart pollInterval and quietPeriod
Allow the pollInterval and the quietPeriod of the filewatcher to be
configured.

Fixes gh-3139
2015-06-08 22:51:50 -07:00
Phillip Webb 7bcd6567ba Allow reload to use a trigger file
Update `FileSystemWatcher` to support the concept of a "trigger file"
which could be written by an IDE when a reload needs to occur.

Fixes gh-3157
2015-06-08 22:14:48 -07:00
Phillip Webb 25f74cbaef Clear caches on initial restart
Tweak `Restarter` to clear caches on the initial restart.

See gh-3082
2015-06-05 12:56:03 -07:00
Eddú Meléndez baca62a6c0 Fix typos 2015-06-05 16:59:51 +02:00
Phillip Webb 83300b35bf Set additional template cache devtools properties
Update DevToolsPropertyDefaultsPostProcessor to set the following
additional template cache properties to `false`:

	spring.freemarker.cache
	spring.groovy.template.cache
	spring.velocity.cache
	spring.mustache.cache

Fixes gh-3125
2015-06-04 17:27:39 -07:00
Dave Syer b47af19920 Stop file watcher as soon as a change is detected
The FileWatcher sometimes generates multiple events for a single change
and if there is a slow shutdown hook the second one can come in before
the context is closed, leaving it in a tricky state. This change
attempts to stop the file watcher as soon as it detects a change
(the stop() method is called in the listener, which normally happens in
the same thread as the scan).

Fixes gh-3097
2015-06-04 17:23:41 -07:00
Phillip Webb 983484f429 Rename spring-boot-developer-tools -> devtools
Fixes gh-3099
2015-06-04 13:50:56 -07:00