Reformat code using Eclipse Mars

This commit is contained in:
Phillip Webb
2015-10-07 23:37:10 -07:00
parent e473364e4e
commit c9fb9916b8
408 changed files with 2831 additions and 2652 deletions

View File

@@ -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;

View File

@@ -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()]);
}

View File

@@ -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 {

View File

@@ -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

View File

@@ -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");

View File

@@ -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;

View File

@@ -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;

View File

@@ -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");

View File

@@ -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);
}

View File

@@ -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));
}
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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();
}

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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 "

View File

@@ -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());
}
/**

View File

@@ -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;
}

View File

@@ -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