Reformat code using Eclipse Mars
This commit is contained in:
@@ -38,8 +38,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class RemoteUrlPropertyExtractor implements
|
||||
ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
|
||||
class RemoteUrlPropertyExtractor
|
||||
implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
|
||||
|
||||
private static final String NON_OPTION_ARGS = CommandLinePropertySource.DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME;
|
||||
|
||||
|
||||
@@ -117,8 +117,8 @@ public class DevToolsProperties {
|
||||
allExclude.addAll(StringUtils.commaDelimitedListToSet(this.exclude));
|
||||
}
|
||||
if (StringUtils.hasText(this.additionalExclude)) {
|
||||
allExclude.addAll(StringUtils
|
||||
.commaDelimitedListToSet(this.additionalExclude));
|
||||
allExclude.addAll(
|
||||
StringUtils.commaDelimitedListToSet(this.additionalExclude));
|
||||
}
|
||||
return allExclude.toArray(new String[allExclude.size()]);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ class FileWatchingFailureHandler implements FailureHandler {
|
||||
failure.printStackTrace();
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
FileSystemWatcher watcher = this.fileSystemWatcherFactory.getFileSystemWatcher();
|
||||
watcher.addSourceFolders(new ClassPathFolders(Restarter.getInstance()
|
||||
.getInitialUrls()));
|
||||
watcher.addSourceFolders(
|
||||
new ClassPathFolders(Restarter.getInstance().getInitialUrls()));
|
||||
watcher.addListener(new Listener(latch));
|
||||
watcher.start();
|
||||
try {
|
||||
|
||||
@@ -122,8 +122,8 @@ public class LocalDevToolsAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ClassPathRestartStrategy classPathRestartStrategy() {
|
||||
return new PatternClassPathRestartStrategy(this.properties.getRestart()
|
||||
.getAllExclude());
|
||||
return new PatternClassPathRestartStrategy(
|
||||
this.properties.getRestart().getAllExclude());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -54,8 +54,8 @@ public class OptionalLiveReloadServer {
|
||||
if (!this.server.isStarted()) {
|
||||
this.server.start();
|
||||
}
|
||||
logger.info("LiveReload server is running on port "
|
||||
+ this.server.getPort());
|
||||
logger.info(
|
||||
"LiveReload server is running on port " + this.server.getPort());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.warn("Unable to start LiveReload server");
|
||||
|
||||
@@ -86,7 +86,8 @@ public class RemoteDevToolsAutoConfiguration {
|
||||
@Bean
|
||||
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
|
||||
Handler handler = new HttpStatusHandler();
|
||||
return new UrlHandlerMapper(this.properties.getRemote().getContextPath(), handler);
|
||||
return new UrlHandlerMapper(this.properties.getRemote().getContextPath(),
|
||||
handler);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -152,8 +153,8 @@ public class RemoteDevToolsAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "remoteDebugHttpTunnelServer")
|
||||
public HttpTunnelServer remoteDebugHttpTunnelServer() {
|
||||
return new HttpTunnelServer(new SocketTargetServerConnection(
|
||||
new RemoteDebugPortProvider()));
|
||||
return new HttpTunnelServer(
|
||||
new SocketTargetServerConnection(new RemoteDebugPortProvider()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -169,8 +170,8 @@ public class RemoteDevToolsAutoConfiguration {
|
||||
}
|
||||
|
||||
@Order(SecurityProperties.IGNORED_ORDER + 2)
|
||||
static class RemoteRestartWebSecurityConfigurer extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
static class RemoteRestartWebSecurityConfigurer
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private DevToolsProperties properties;
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.springframework.util.Assert;
|
||||
* @since 1.3.0
|
||||
* @see ClassPathFileChangeListener
|
||||
*/
|
||||
public class ClassPathFileSystemWatcher implements InitializingBean, DisposableBean,
|
||||
ApplicationContextAware {
|
||||
public class ClassPathFileSystemWatcher
|
||||
implements InitializingBean, DisposableBean, ApplicationContextAware {
|
||||
|
||||
private final FileSystemWatcher fileSystemWatcher;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.core.env.PropertySource;
|
||||
public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostProcessor {
|
||||
|
||||
private static final Map<String, Object> PROPERTIES;
|
||||
|
||||
static {
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put("spring.thymeleaf.cache", "false");
|
||||
|
||||
@@ -114,8 +114,8 @@ public class FileSystemWatcher {
|
||||
*/
|
||||
public synchronized void addSourceFolder(File folder) {
|
||||
Assert.notNull(folder, "Folder must not be null");
|
||||
Assert.isTrue(folder.isDirectory(), "Folder '" + folder + "' must exist and must"
|
||||
+ " be a directory");
|
||||
Assert.isTrue(folder.isDirectory(),
|
||||
"Folder '" + folder + "' must exist and must" + " be a directory");
|
||||
checkNotStarted();
|
||||
this.folders.put(folder, null);
|
||||
}
|
||||
|
||||
@@ -74,11 +74,12 @@ class FolderSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
public ChangedFiles getChangedFiles(FolderSnapshot snapshot, FileFilter triggerFilter) {
|
||||
public ChangedFiles getChangedFiles(FolderSnapshot snapshot,
|
||||
FileFilter triggerFilter) {
|
||||
Assert.notNull(snapshot, "Snapshot must not be null");
|
||||
File folder = this.folder;
|
||||
Assert.isTrue(snapshot.folder.equals(folder), "Snapshot source folder must be '"
|
||||
+ folder + "'");
|
||||
Assert.isTrue(snapshot.folder.equals(folder),
|
||||
"Snapshot source folder must be '" + folder + "'");
|
||||
Set<ChangedFile> changes = new LinkedHashSet<ChangedFile>();
|
||||
Map<File, FileSnapshot> previousFiles = getFilesMap();
|
||||
for (FileSnapshot currentFile : snapshot.files) {
|
||||
@@ -88,8 +89,8 @@ class FolderSnapshot {
|
||||
changes.add(new ChangedFile(folder, currentFile.getFile(), Type.ADD));
|
||||
}
|
||||
else if (!previousFile.equals(currentFile)) {
|
||||
changes.add(new ChangedFile(folder, currentFile.getFile(),
|
||||
Type.MODIFY));
|
||||
changes.add(
|
||||
new ChangedFile(folder, currentFile.getFile(), Type.MODIFY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ class Connection {
|
||||
|
||||
private static Log logger = LogFactory.getLog(Connection.class);
|
||||
|
||||
private static final Pattern WEBSOCKET_KEY_PATTERN = Pattern.compile(
|
||||
"^Sec-WebSocket-Key:(.*)$", Pattern.MULTILINE);
|
||||
private static final Pattern WEBSOCKET_KEY_PATTERN = Pattern
|
||||
.compile("^Sec-WebSocket-Key:(.*)$", Pattern.MULTILINE);
|
||||
|
||||
public final static String WEBSOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
@@ -89,8 +89,8 @@ class Connection {
|
||||
private void runWebSocket(String header) throws Exception {
|
||||
String accept = getWebsocketAcceptResponse();
|
||||
this.outputStream.writeHeaders("HTTP/1.1 101 Switching Protocols",
|
||||
"Upgrade: websocket", "Connection: Upgrade", "Sec-WebSocket-Accept: "
|
||||
+ accept);
|
||||
"Upgrade: websocket", "Connection: Upgrade",
|
||||
"Sec-WebSocket-Accept: " + accept);
|
||||
new Frame("{\"command\":\"hello\",\"protocols\":"
|
||||
+ "[\"http://livereload.com/protocols/official-7\"],"
|
||||
+ "\"serverName\":\"spring-boot\"}").write(this.outputStream);
|
||||
|
||||
@@ -52,10 +52,11 @@ import org.springframework.util.FileCopyUtils;
|
||||
* @author Phillip Webb
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class ClassPathChangeUploader implements
|
||||
ApplicationListener<ClassPathChangedEvent> {
|
||||
public class ClassPathChangeUploader
|
||||
implements ApplicationListener<ClassPathChangedEvent> {
|
||||
|
||||
private static final Map<ChangedFile.Type, ClassLoaderFile.Kind> TYPE_MAPPINGS;
|
||||
|
||||
static {
|
||||
Map<ChangedFile.Type, ClassLoaderFile.Kind> map = new HashMap<ChangedFile.Type, ClassLoaderFile.Kind>();
|
||||
map.put(ChangedFile.Type.ADD, ClassLoaderFile.Kind.ADDED);
|
||||
@@ -108,8 +109,8 @@ public class ClassPathChangeUploader implements
|
||||
|
||||
private void logUpload(ClassLoaderFiles classLoaderFiles) {
|
||||
int size = classLoaderFiles.size();
|
||||
logger.info("Uploaded " + size + " class "
|
||||
+ (size == 1 ? "resource" : "resources"));
|
||||
logger.info(
|
||||
"Uploaded " + size + " class " + (size == 1 ? "resource" : "resources"));
|
||||
}
|
||||
|
||||
private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException {
|
||||
@@ -133,10 +134,11 @@ public class ClassPathChangeUploader implements
|
||||
return files;
|
||||
}
|
||||
|
||||
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile) throws IOException {
|
||||
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
|
||||
throws IOException {
|
||||
ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
|
||||
byte[] bytes = (kind == Kind.DELETED ? null : FileCopyUtils
|
||||
.copyToByteArray(changedFile.getFile()));
|
||||
byte[] bytes = (kind == Kind.DELETED ? null
|
||||
: FileCopyUtils.copyToByteArray(changedFile.getFile()));
|
||||
long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis()
|
||||
: changedFile.getFile().lastModified());
|
||||
return new ClassLoaderFile(kind, lastModified, bytes);
|
||||
|
||||
@@ -97,8 +97,8 @@ public class RemoteClientConfiguration {
|
||||
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
Proxy proxy = this.properties.getRemote().getProxy();
|
||||
if (proxy.getHost() != null && proxy.getPort() != null) {
|
||||
requestFactory.setProxy(new java.net.Proxy(Type.HTTP, new InetSocketAddress(
|
||||
proxy.getHost(), proxy.getPort())));
|
||||
requestFactory.setProxy(new java.net.Proxy(Type.HTTP,
|
||||
new InetSocketAddress(proxy.getHost(), proxy.getPort())));
|
||||
}
|
||||
return new InterceptingClientHttpRequestFactory(requestFactory, interceptors);
|
||||
}
|
||||
@@ -157,8 +157,8 @@ public class RemoteClientConfiguration {
|
||||
@EventListener
|
||||
public void onClassPathChanged(ClassPathChangedEvent event) {
|
||||
String url = this.remoteUrl + this.properties.getRemote().getContextPath();
|
||||
this.executor.execute(new DelayedLiveReloadTrigger(
|
||||
optionalLiveReloadServer(), this.clientHttpRequestFactory, url));
|
||||
this.executor.execute(new DelayedLiveReloadTrigger(optionalLiveReloadServer(),
|
||||
this.clientHttpRequestFactory, url));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -221,8 +221,8 @@ public class RemoteClientConfiguration {
|
||||
|
||||
@Bean
|
||||
public ClassPathRestartStrategy classPathRestartStrategy() {
|
||||
return new PatternClassPathRestartStrategy(this.properties.getRestart()
|
||||
.getAllExclude());
|
||||
return new PatternClassPathRestartStrategy(
|
||||
this.properties.getRestart().getAllExclude());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.Set;
|
||||
public class DefaultRestartInitializer implements RestartInitializer {
|
||||
|
||||
private static final Set<String> SKIPPED_STACK_ELEMENTS;
|
||||
|
||||
static {
|
||||
Set<String> skipped = new LinkedHashSet<String>();
|
||||
skipped.add("org.junit.runners.");
|
||||
@@ -60,9 +61,8 @@ public class DefaultRestartInitializer implements RestartInitializer {
|
||||
* @return {@code true} if the thread is a main invocation
|
||||
*/
|
||||
protected boolean isMain(Thread thread) {
|
||||
return thread.getName().equals("main")
|
||||
&& thread.getContextClassLoader().getClass().getName()
|
||||
.contains("AppClassLoader");
|
||||
return thread.getName().equals("main") && thread.getContextClassLoader()
|
||||
.getClass().getName().contains("AppClassLoader");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +87,9 @@ public class DefaultRestartInitializer implements RestartInitializer {
|
||||
* @return the URLs
|
||||
*/
|
||||
protected URL[] getUrls(Thread thread) {
|
||||
return ChangeableUrls.fromUrlClassLoader(
|
||||
(URLClassLoader) thread.getContextClassLoader()).toArray();
|
||||
return ChangeableUrls
|
||||
.fromUrlClassLoader((URLClassLoader) thread.getContextClassLoader())
|
||||
.toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.springframework.core.Ordered;
|
||||
* @since 1.3.0
|
||||
* @see Restarter
|
||||
*/
|
||||
public class RestartApplicationListener implements ApplicationListener<ApplicationEvent>,
|
||||
Ordered {
|
||||
public class RestartApplicationListener
|
||||
implements ApplicationListener<ApplicationEvent>, Ordered {
|
||||
|
||||
private int order = HIGHEST_PRECEDENCE;
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
* @author Phillip Webb
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class RestartScopeInitializer implements
|
||||
ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
public class RestartScopeInitializer
|
||||
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
|
||||
@@ -282,8 +282,8 @@ public class Restarter {
|
||||
ClassLoader classLoader = new RestartClassLoader(parent, urls, updatedFiles,
|
||||
this.logger);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Starting application " + this.mainClassName
|
||||
+ " with URLs " + Arrays.asList(urls));
|
||||
this.logger.debug("Starting application " + this.mainClassName + " with URLs "
|
||||
+ Arrays.asList(urls));
|
||||
}
|
||||
return relaunch(classLoader);
|
||||
}
|
||||
@@ -374,8 +374,8 @@ public class Restarter {
|
||||
Map<?, ?> map = ((Map<?, ?>) instance);
|
||||
for (Iterator<?> iterator = map.keySet().iterator(); iterator.hasNext();) {
|
||||
Object value = iterator.next();
|
||||
if (value instanceof Class
|
||||
&& ((Class<?>) value).getClassLoader() instanceof RestartClassLoader) {
|
||||
if (value instanceof Class && ((Class<?>) value)
|
||||
.getClassLoader() instanceof RestartClassLoader) {
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,8 @@ public class RestartClassLoader extends URLClassLoader implements SmartClassLoad
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
public Class<?> loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException {
|
||||
String path = name.replace('.', '/').concat(".class");
|
||||
ClassLoaderFile file = this.updatedFiles.getFile(path);
|
||||
if (file != null && file.getKind() == Kind.DELETED) {
|
||||
|
||||
@@ -70,7 +70,8 @@ public class HttpRestartServer {
|
||||
throws IOException {
|
||||
try {
|
||||
Assert.state(request.getHeaders().getContentLength() > 0, "No content");
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(request.getBody());
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(
|
||||
request.getBody());
|
||||
ClassLoaderFiles files = (ClassLoaderFiles) objectInputStream.readObject();
|
||||
objectInputStream.close();
|
||||
this.server.updateAndRestart(files);
|
||||
|
||||
@@ -95,7 +95,8 @@ public class RestartServer {
|
||||
restart(urls, files);
|
||||
}
|
||||
|
||||
private boolean updateFileSystem(URL url, String name, ClassLoaderFile classLoaderFile) {
|
||||
private boolean updateFileSystem(URL url, String name,
|
||||
ClassLoaderFile classLoaderFile) {
|
||||
if (!isFolderUrl(url.toString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ public class HttpTunnelConnection implements TunnelConnection {
|
||||
throw new IllegalArgumentException("Malformed URL '" + url + "'");
|
||||
}
|
||||
this.requestFactory = requestFactory;
|
||||
this.executor = (executor == null ? Executors
|
||||
.newCachedThreadPool(new TunnelThreadFactory()) : executor);
|
||||
this.executor = (executor == null
|
||||
? Executors.newCachedThreadPool(new TunnelThreadFactory()) : executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,8 +141,8 @@ public class HttpTunnelConnection implements TunnelConnection {
|
||||
public int write(ByteBuffer src) throws IOException {
|
||||
int size = src.remaining();
|
||||
if (size > 0) {
|
||||
openNewConnection(new HttpTunnelPayload(
|
||||
this.requestSeq.incrementAndGet(), src));
|
||||
openNewConnection(
|
||||
new HttpTunnelPayload(this.requestSeq.incrementAndGet(), src));
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -154,8 +154,8 @@ public class TunnelClient implements SmartInitializingSingleton {
|
||||
|
||||
private void handleConnection(SocketChannel socketChannel) throws Exception {
|
||||
Closeable closeable = new SocketCloseable(socketChannel);
|
||||
WritableByteChannel outputChannel = TunnelClient.this.tunnelConnection.open(
|
||||
socketChannel, closeable);
|
||||
WritableByteChannel outputChannel = TunnelClient.this.tunnelConnection
|
||||
.open(socketChannel, closeable);
|
||||
TunnelClient.this.listeners.fireOpenEvent(socketChannel);
|
||||
try {
|
||||
logger.trace("Accepted connection to tunnel client from "
|
||||
|
||||
@@ -37,11 +37,11 @@ import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A server that can be used to tunnel TCP traffic over HTTP. Similar in design to the <a
|
||||
* href="http://xmpp.org/extensions/xep-0124.html">Bidirectional-streams Over Synchronous
|
||||
* HTTP (BOSH)</a> XMPP extension protocol, the server uses long polling with HTTP
|
||||
* requests held open until a response is available. A typical traffic pattern would be as
|
||||
* follows:
|
||||
* A server that can be used to tunnel TCP traffic over HTTP. Similar in design to the
|
||||
* <a href="http://xmpp.org/extensions/xep-0124.html">Bidirectional-streams Over
|
||||
* Synchronous HTTP (BOSH)</a> XMPP extension protocol, the server uses long polling with
|
||||
* HTTP requests held open until a response is available. A typical traffic pattern would
|
||||
* be as follows:
|
||||
*
|
||||
* <pre>
|
||||
* [ CLIENT ] [ SERVER ]
|
||||
@@ -193,7 +193,8 @@ public class HttpTunnelServer {
|
||||
* @param disconnectTimeout the disconnect timeout in milliseconds
|
||||
*/
|
||||
public void setDisconnectTimeout(long disconnectTimeout) {
|
||||
Assert.isTrue(disconnectTimeout > 0, "DisconnectTimeout must be a positive value");
|
||||
Assert.isTrue(disconnectTimeout > 0,
|
||||
"DisconnectTimeout must be a positive value");
|
||||
this.disconnectTimeout = disconnectTimeout;
|
||||
}
|
||||
|
||||
@@ -277,7 +278,8 @@ public class HttpTunnelServer {
|
||||
Iterator<HttpConnection> iterator = this.httpConnections.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
HttpConnection httpConnection = iterator.next();
|
||||
if (httpConnection.isOlderThan(HttpTunnelServer.this.longPollTimeout)) {
|
||||
if (httpConnection
|
||||
.isOlderThan(HttpTunnelServer.this.longPollTimeout)) {
|
||||
httpConnection.respond(HttpStatus.NO_CONTENT);
|
||||
iterator.remove();
|
||||
}
|
||||
@@ -324,8 +326,8 @@ public class HttpTunnelServer {
|
||||
}
|
||||
synchronized (this.httpConnections) {
|
||||
while (this.httpConnections.size() > 1) {
|
||||
this.httpConnections.removeFirst().respond(
|
||||
HttpStatus.TOO_MANY_REQUESTS);
|
||||
this.httpConnections.removeFirst()
|
||||
.respond(HttpStatus.TOO_MANY_REQUESTS);
|
||||
}
|
||||
this.lastHttpRequestTime = System.currentTimeMillis();
|
||||
this.httpConnections.addLast(httpConnection);
|
||||
@@ -439,8 +441,8 @@ public class HttpTunnelServer {
|
||||
* @return if the request is a signal to disconnect
|
||||
*/
|
||||
public boolean isDisconnectRequest() {
|
||||
return DISCONNECT_MEDIA_TYPE.equals(this.request.getHeaders()
|
||||
.getContentType());
|
||||
return DISCONNECT_MEDIA_TYPE
|
||||
.equals(this.request.getHeaders().getContentType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,15 +45,16 @@ public class RemoteDebugPortProvider implements PortProvider {
|
||||
@UsesUnsafeJava
|
||||
@SuppressWarnings("restriction")
|
||||
private static int getRemoteDebugPort() {
|
||||
String property = sun.misc.VMSupport.getAgentProperties().getProperty(
|
||||
JDWP_ADDRESS_PROPERTY);
|
||||
String property = sun.misc.VMSupport.getAgentProperties()
|
||||
.getProperty(JDWP_ADDRESS_PROPERTY);
|
||||
try {
|
||||
if (property != null && property.contains(":")) {
|
||||
return Integer.valueOf(property.split(":")[1]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.trace("Unable to get JDWP port from property value '" + property + "'");
|
||||
logger.trace(
|
||||
"Unable to get JDWP port from property value '" + property + "'");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ public class SocketTargetServerConnection implements TargetServerConnection {
|
||||
|
||||
TimeoutAwareChannel(SocketChannel socketChannel) throws IOException {
|
||||
this.socketChannel = socketChannel;
|
||||
this.readChannel = Channels.newChannel(socketChannel.socket()
|
||||
.getInputStream());
|
||||
this.readChannel = Channels
|
||||
.newChannel(socketChannel.socket().getInputStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,8 +34,7 @@ public class DevToolsPropertiesTests {
|
||||
public void additionalExcludeKeepsDefaults() {
|
||||
DevToolsProperties.Restart restart = this.devToolsProperties.getRestart();
|
||||
restart.setAdditionalExclude("foo/**,bar/**");
|
||||
assertThat(
|
||||
restart.getAllExclude(),
|
||||
assertThat(restart.getAllExclude(),
|
||||
arrayContaining("META-INF/maven/**", "META-INF/resources/**",
|
||||
"resources/**", "static/**", "public/**", "templates/**",
|
||||
"**/*Test.class", "**/*Tests.class", "git.properties", "foo/**",
|
||||
@@ -55,7 +54,8 @@ public class DevToolsPropertiesTests {
|
||||
DevToolsProperties.Restart restart = this.devToolsProperties.getRestart();
|
||||
restart.setExclude("biz/**");
|
||||
restart.setAdditionalExclude("foo/**,bar/**");
|
||||
assertThat(restart.getAllExclude(), arrayContaining("biz/**", "foo/**", "bar/**"));
|
||||
assertThat(restart.getAllExclude(),
|
||||
arrayContaining("biz/**", "foo/**", "bar/**"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -227,8 +227,8 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
Object watcher = ReflectionTestUtils.getField(classPathWatcher,
|
||||
"fileSystemWatcher");
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<File, Object> folders = (Map<File, Object>) ReflectionTestUtils.getField(
|
||||
watcher, "folders");
|
||||
Map<File, Object> folders = (Map<File, Object>) ReflectionTestUtils
|
||||
.getField(watcher, "folders");
|
||||
assertThat(folders.size(), is(equalTo(2)));
|
||||
assertThat(folders, hasKey(new File("src/main/java").getAbsoluteFile()));
|
||||
assertThat(folders, hasKey(new File("src/test/java").getAbsoluteFile()));
|
||||
|
||||
@@ -209,13 +209,14 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
public HttpTunnelServer remoteDebugHttpTunnelServer() {
|
||||
return new MockHttpTunnelServer(new SocketTargetServerConnection(
|
||||
new RemoteDebugPortProvider()));
|
||||
return new MockHttpTunnelServer(
|
||||
new SocketTargetServerConnection(new RemoteDebugPortProvider()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HttpRestartServer remoteRestartHttpRestartServer() {
|
||||
SourceFolderUrlFilter sourceFolderUrlFilter = mock(SourceFolderUrlFilter.class);
|
||||
SourceFolderUrlFilter sourceFolderUrlFilter = mock(
|
||||
SourceFolderUrlFilter.class);
|
||||
return new MockHttpRestartServer(sourceFolderUrlFilter);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ public class ClassPathFileChangeListenerTests {
|
||||
public void restartStrategyMustNotBeNull() throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("RestartStrategy must not be null");
|
||||
new ClassPathFileChangeListener(this.eventPublisher, null, this.fileSystemWatcher);
|
||||
new ClassPathFileChangeListener(this.eventPublisher, null,
|
||||
this.fileSystemWatcher);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -99,8 +99,8 @@ public class ClassPathFileSystemWatcherTests {
|
||||
public ClassPathFileSystemWatcher watcher() {
|
||||
FileSystemWatcher watcher = new FileSystemWatcher(false, 100, 10);
|
||||
URL[] urls = this.environemnt.getProperty("urls", URL[].class);
|
||||
return new ClassPathFileSystemWatcher(new MockFileSystemWatcherFactory(
|
||||
watcher), restartStrategy(), urls);
|
||||
return new ClassPathFileSystemWatcher(
|
||||
new MockFileSystemWatcherFactory(watcher), restartStrategy(), urls);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -137,7 +137,8 @@ public class ClassPathFileSystemWatcherTests {
|
||||
|
||||
}
|
||||
|
||||
private static class MockFileSystemWatcherFactory implements FileSystemWatcherFactory {
|
||||
private static class MockFileSystemWatcherFactory
|
||||
implements FileSystemWatcherFactory {
|
||||
|
||||
private final FileSystemWatcher watcher;
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ public class PatternClassPathRestartStrategyTests {
|
||||
|
||||
@Test
|
||||
public void testChange() {
|
||||
ClassPathRestartStrategy strategy = createStrategy("**/*Test.class,**/*Tests.class");
|
||||
ClassPathRestartStrategy strategy = createStrategy(
|
||||
"**/*Test.class,**/*Tests.class");
|
||||
assertRestartRequired(strategy, "com/example/ExampleTests.class", false);
|
||||
assertRestartRequired(strategy, "com/example/ExampleTest.class", false);
|
||||
assertRestartRequired(strategy, "com/example/Example.class", true);
|
||||
|
||||
@@ -55,8 +55,8 @@ public class DevToolsHomePropertiesPostProcessorTests {
|
||||
public void loadsHomeProperties() throws Exception {
|
||||
Properties properties = new Properties();
|
||||
properties.put("abc", "def");
|
||||
OutputStream out = new FileOutputStream(new File(this.home,
|
||||
".spring-boot-devtools.properties"));
|
||||
OutputStream out = new FileOutputStream(
|
||||
new File(this.home, ".spring-boot-devtools.properties"));
|
||||
properties.store(out, null);
|
||||
out.close();
|
||||
ConfigurableEnvironment environment = new MockEnvironment();
|
||||
@@ -73,8 +73,8 @@ public class DevToolsHomePropertiesPostProcessorTests {
|
||||
assertThat(environment.getProperty("abc"), nullValue());
|
||||
}
|
||||
|
||||
private class MockDevToolHomePropertiesPostProcessor extends
|
||||
DevToolsHomePropertiesPostProcessor {
|
||||
private class MockDevToolHomePropertiesPostProcessor
|
||||
extends DevToolsHomePropertiesPostProcessor {
|
||||
|
||||
@Override
|
||||
protected File getHomeFolder() {
|
||||
|
||||
@@ -113,8 +113,8 @@ public class FileSystemWatcherTests {
|
||||
File folder = new File("does/not/exist");
|
||||
assertThat(folder.exists(), is(false));
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Folder '" + folder
|
||||
+ "' must exist and must be a directory");
|
||||
this.thrown.expectMessage(
|
||||
"Folder '" + folder + "' must exist and must be a directory");
|
||||
this.watcher.addSourceFolder(folder);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ public class FolderSnapshotTests {
|
||||
public void getChangedFilesSnapshotMustBeTheSameSourceFolder() throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Snapshot source folder must be '" + this.folder + "'");
|
||||
this.initialSnapshot.getChangedFiles(new FolderSnapshot(
|
||||
createTestFolderStructure()), null);
|
||||
this.initialSnapshot
|
||||
.getChangedFiles(new FolderSnapshot(createTestFolderStructure()), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -138,8 +138,8 @@ public class ClassPathChangeUploaderTests {
|
||||
return file;
|
||||
}
|
||||
|
||||
private ClassLoaderFiles deserialize(byte[] bytes) throws IOException,
|
||||
ClassNotFoundException {
|
||||
private ClassLoaderFiles deserialize(byte[] bytes)
|
||||
throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(
|
||||
new ByteArrayInputStream(bytes));
|
||||
return (ClassLoaderFiles) objectInputStream.readObject();
|
||||
|
||||
@@ -75,8 +75,8 @@ public class DelayedLiveReloadTriggerTests {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
given(this.errorRequest.execute()).willReturn(this.errorResponse);
|
||||
given(this.okRequest.execute()).willReturn(this.okResponse);
|
||||
given(this.errorResponse.getStatusCode()).willReturn(
|
||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
given(this.errorResponse.getStatusCode())
|
||||
.willReturn(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
given(this.okResponse.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
this.trigger = new DelayedLiveReloadTrigger(this.liveReloadServer,
|
||||
this.requestFactory, URL);
|
||||
@@ -112,8 +112,9 @@ public class DelayedLiveReloadTriggerTests {
|
||||
|
||||
@Test
|
||||
public void triggerReloadOnStatus() throws Exception {
|
||||
given(this.requestFactory.createRequest(new URI(URL), HttpMethod.GET)).willThrow(
|
||||
new IOException()).willReturn(this.errorRequest, this.okRequest);
|
||||
given(this.requestFactory.createRequest(new URI(URL), HttpMethod.GET))
|
||||
.willThrow(new IOException())
|
||||
.willReturn(this.errorRequest, this.okRequest);
|
||||
long startTime = System.currentTimeMillis();
|
||||
this.trigger.setTimings(10, 200, 30000);
|
||||
this.trigger.run();
|
||||
@@ -123,8 +124,8 @@ public class DelayedLiveReloadTriggerTests {
|
||||
|
||||
@Test
|
||||
public void timeout() throws Exception {
|
||||
given(this.requestFactory.createRequest(new URI(URL), HttpMethod.GET)).willThrow(
|
||||
new IOException());
|
||||
given(this.requestFactory.createRequest(new URI(URL), HttpMethod.GET))
|
||||
.willThrow(new IOException());
|
||||
this.trigger.setTimings(10, 0, 10);
|
||||
this.trigger.run();
|
||||
verify(this.liveReloadServer, never()).triggerReload();
|
||||
|
||||
@@ -91,8 +91,8 @@ public class DispatcherTests {
|
||||
|
||||
@Test
|
||||
public void accessManagerVetoRequest() throws Exception {
|
||||
given(this.accessManager.isAllowed(any(ServerHttpRequest.class))).willReturn(
|
||||
false);
|
||||
given(this.accessManager.isAllowed(any(ServerHttpRequest.class)))
|
||||
.willReturn(false);
|
||||
HandlerMapper mapper = mock(HandlerMapper.class);
|
||||
Handler handler = mock(Handler.class);
|
||||
given(mapper.getHandler(any(ServerHttpRequest.class))).willReturn(handler);
|
||||
|
||||
@@ -57,10 +57,10 @@ public class ChangeableUrlsTests {
|
||||
|
||||
@Test
|
||||
public void skipsUrls() throws Exception {
|
||||
ChangeableUrls urls = ChangeableUrls
|
||||
.fromUrls(makeUrl("spring-boot"), makeUrl("spring-boot-autoconfigure"),
|
||||
makeUrl("spring-boot-actuator"), makeUrl("spring-boot-starter"),
|
||||
makeUrl("spring-boot-starter-some-thing"));
|
||||
ChangeableUrls urls = ChangeableUrls.fromUrls(makeUrl("spring-boot"),
|
||||
makeUrl("spring-boot-autoconfigure"), makeUrl("spring-boot-actuator"),
|
||||
makeUrl("spring-boot-starter"),
|
||||
makeUrl("spring-boot-starter-some-thing"));
|
||||
assertThat(urls.size(), equalTo(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ public class DefaultRestartInitializerTests {
|
||||
@Test
|
||||
public void threadNotUsingAppClassLoader() throws Exception {
|
||||
MockRestartInitializer initializer = new MockRestartInitializer(false);
|
||||
ClassLoader classLoader = new MockLauncherClassLoader(getClass().getClassLoader());
|
||||
ClassLoader classLoader = new MockLauncherClassLoader(
|
||||
getClass().getClassLoader());
|
||||
Thread thread = new Thread();
|
||||
thread.setName("main");
|
||||
thread.setContextClassLoader(classLoader);
|
||||
|
||||
@@ -62,8 +62,8 @@ public class MainMethodTests {
|
||||
}
|
||||
}).test();
|
||||
assertThat(method.getMethod(), equalTo(this.actualMain));
|
||||
assertThat(method.getDeclaringClassName(), equalTo(this.actualMain
|
||||
.getDeclaringClass().getName()));
|
||||
assertThat(method.getDeclaringClassName(),
|
||||
equalTo(this.actualMain.getDeclaringClass().getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -68,7 +68,8 @@ public class MockRestarter implements TestRule {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
String name = (String) invocation.getArguments()[0];
|
||||
ObjectFactory factory = (ObjectFactory) invocation.getArguments()[1];
|
||||
ObjectFactory factory = (ObjectFactory) invocation
|
||||
.getArguments()[1];
|
||||
Object attribute = MockRestarter.this.attributes.get(name);
|
||||
if (attribute == null) {
|
||||
attribute = factory.getObject();
|
||||
|
||||
@@ -85,7 +85,8 @@ public class RestartApplicationListenerTests {
|
||||
Restarter.clearInstance();
|
||||
RestartApplicationListener listener = new RestartApplicationListener();
|
||||
SpringApplication application = new SpringApplication();
|
||||
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
|
||||
ConfigurableApplicationContext context = mock(
|
||||
ConfigurableApplicationContext.class);
|
||||
listener.onApplicationEvent(new ApplicationStartedEvent(application, ARGS));
|
||||
assertThat(Restarter.getInstance(), not(nullValue()));
|
||||
assertThat(Restarter.getInstance().isFinished(), equalTo(false));
|
||||
@@ -94,8 +95,8 @@ public class RestartApplicationListenerTests {
|
||||
context, new RuntimeException()));
|
||||
}
|
||||
else {
|
||||
listener.onApplicationEvent(new ApplicationReadyEvent(application, ARGS,
|
||||
context));
|
||||
listener.onApplicationEvent(
|
||||
new ApplicationReadyEvent(application, ARGS, context));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@ public class RestartScopeInitializerTests {
|
||||
|
||||
}
|
||||
|
||||
public static class ScopeTestBean implements
|
||||
ApplicationListener<ContextRefreshedEvent> {
|
||||
public static class ScopeTestBean
|
||||
implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
public ScopeTestBean() {
|
||||
createCount.incrementAndGet();
|
||||
|
||||
@@ -129,8 +129,8 @@ public class ClassLoaderFilesTests {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(bos);
|
||||
oos.writeObject(this.files);
|
||||
oos.close();
|
||||
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
|
||||
bos.toByteArray()));
|
||||
ObjectInputStream ois = new ObjectInputStream(
|
||||
new ByteArrayInputStream(bos.toByteArray()));
|
||||
ClassLoaderFiles readObject = (ClassLoaderFiles) ois.readObject();
|
||||
assertThat(readObject.getFile("myfile"), notNullValue());
|
||||
}
|
||||
|
||||
@@ -112,29 +112,30 @@ public class RestartClassLoaderTests {
|
||||
|
||||
@Test
|
||||
public void getResourceFromReloadableUrl() throws Exception {
|
||||
String content = readString(this.reloadClassLoader
|
||||
.getResourceAsStream(PACKAGE_PATH + "/Sample.txt"));
|
||||
String content = readString(
|
||||
this.reloadClassLoader.getResourceAsStream(PACKAGE_PATH + "/Sample.txt"));
|
||||
assertThat(content, startsWith("fromchild"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getResourceFromParent() throws Exception {
|
||||
String content = readString(this.reloadClassLoader
|
||||
.getResourceAsStream(PACKAGE_PATH + "/Parent.txt"));
|
||||
String content = readString(
|
||||
this.reloadClassLoader.getResourceAsStream(PACKAGE_PATH + "/Parent.txt"));
|
||||
assertThat(content, startsWith("fromparent"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getResourcesFiltersDuplicates() throws Exception {
|
||||
List<URL> resources = toList(this.reloadClassLoader.getResources(PACKAGE_PATH
|
||||
+ "/Sample.txt"));
|
||||
List<URL> resources = toList(
|
||||
this.reloadClassLoader.getResources(PACKAGE_PATH + "/Sample.txt"));
|
||||
assertThat(resources.size(), equalTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadClassFromReloadableUrl() throws Exception {
|
||||
Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".Sample");
|
||||
assertThat(loaded.getClassLoader(), equalTo((ClassLoader) this.reloadClassLoader));
|
||||
assertThat(loaded.getClassLoader(),
|
||||
equalTo((ClassLoader) this.reloadClassLoader));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -203,11 +204,12 @@ public class RestartClassLoaderTests {
|
||||
@Test
|
||||
public void getAddedClass() throws Exception {
|
||||
String name = PACKAGE_PATH + "/SampleParent.class";
|
||||
byte[] bytes = FileCopyUtils.copyToByteArray(getClass().getResourceAsStream(
|
||||
"SampleParent.class"));
|
||||
byte[] bytes = FileCopyUtils
|
||||
.copyToByteArray(getClass().getResourceAsStream("SampleParent.class"));
|
||||
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.ADDED, bytes));
|
||||
Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".SampleParent");
|
||||
assertThat(loaded.getClassLoader(), equalTo((ClassLoader) this.reloadClassLoader));
|
||||
assertThat(loaded.getClassLoader(),
|
||||
equalTo((ClassLoader) this.reloadClassLoader));
|
||||
}
|
||||
|
||||
private String readString(InputStream in) throws IOException {
|
||||
|
||||
@@ -37,6 +37,7 @@ public class DefaultSourceFolderUrlFilterTests {
|
||||
private static final String SOURCE_ROOT = "/Users/me/code/some-root/";
|
||||
|
||||
private static final List<String> COMMON_POSTFIXES;
|
||||
|
||||
static {
|
||||
List<String> postfixes = new ArrayList<String>();
|
||||
postfixes.add(".jar");
|
||||
@@ -92,9 +93,10 @@ public class DefaultSourceFolderUrlFilterTests {
|
||||
urls.add(new URL("file:/some/path/" + name));
|
||||
urls.add(new URL("file:/some/path/" + name + "!/"));
|
||||
for (String postfix : COMMON_POSTFIXES) {
|
||||
urls.add(new URL("jar:file:/some/path/lib-module" + postfix + "!/lib/" + name));
|
||||
urls.add(new URL("jar:file:/some/path/lib-module" + postfix + "!/lib/" + name
|
||||
+ "!/"));
|
||||
urls.add(new URL(
|
||||
"jar:file:/some/path/lib-module" + postfix + "!/lib/" + name));
|
||||
urls.add(new URL(
|
||||
"jar:file:/some/path/lib-module" + postfix + "!/lib/" + name + "!/"));
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
@@ -105,13 +105,13 @@ public class MockClientHttpRequestFactory implements ClientHttpRequestFactory {
|
||||
}
|
||||
|
||||
public ClientHttpResponse asHttpResponse(AtomicLong seq) {
|
||||
MockClientHttpResponse httpResponse = new MockClientHttpResponse(
|
||||
this.payload, this.status);
|
||||
MockClientHttpResponse httpResponse = new MockClientHttpResponse(this.payload,
|
||||
this.status);
|
||||
waitForDelay();
|
||||
if (this.payload != null) {
|
||||
httpResponse.getHeaders().setContentLength(this.payload.length);
|
||||
httpResponse.getHeaders().setContentType(
|
||||
MediaType.APPLICATION_OCTET_STREAM);
|
||||
httpResponse.getHeaders()
|
||||
.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
httpResponse.getHeaders().add("x-seq",
|
||||
Long.toString(seq.incrementAndGet()));
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ public class HttpTunnelPayloadTests {
|
||||
|
||||
@Test
|
||||
public void getPayloadData() throws Exception {
|
||||
ReadableByteChannel channel = Channels.newChannel(new ByteArrayInputStream(
|
||||
"hello".getBytes()));
|
||||
ReadableByteChannel channel = Channels
|
||||
.newChannel(new ByteArrayInputStream("hello".getBytes()));
|
||||
ByteBuffer payloadData = HttpTunnelPayload.getPayloadData(channel);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
WritableByteChannel writeChannel = Channels.newChannel(out);
|
||||
|
||||
@@ -304,11 +304,11 @@ public class HttpTunnelServerTests {
|
||||
testHttpConnectionNonAsync(100);
|
||||
}
|
||||
|
||||
private void testHttpConnectionNonAsync(long sleepBeforeResponse) throws IOException,
|
||||
InterruptedException {
|
||||
private void testHttpConnectionNonAsync(long sleepBeforeResponse)
|
||||
throws IOException, InterruptedException {
|
||||
ServerHttpRequest request = mock(ServerHttpRequest.class);
|
||||
given(request.getAsyncRequestControl(this.response)).willThrow(
|
||||
new IllegalArgumentException());
|
||||
given(request.getAsyncRequestControl(this.response))
|
||||
.willThrow(new IllegalArgumentException());
|
||||
final HttpConnection connection = new HttpConnection(request, this.response);
|
||||
final AtomicBoolean responded = new AtomicBoolean();
|
||||
Thread connectionThread = new Thread() {
|
||||
|
||||
Reference in New Issue
Block a user