Cleanup and format code

This commit is contained in:
Phillip Webb
2017-03-06 16:44:31 -08:00
parent c7b46e4d1c
commit d8f827d224
649 changed files with 1922 additions and 2003 deletions

View File

@@ -65,13 +65,13 @@ public final class RemoteSpringApplication {
}
private Collection<ApplicationContextInitializer<?>> getInitializers() {
List<ApplicationContextInitializer<?>> initializers = new ArrayList<ApplicationContextInitializer<?>>();
List<ApplicationContextInitializer<?>> initializers = new ArrayList<>();
initializers.add(new RestartScopeInitializer());
return initializers;
}
private Collection<ApplicationListener<?>> getListeners() {
List<ApplicationListener<?>> listeners = new ArrayList<ApplicationListener<?>>();
List<ApplicationListener<?>> listeners = new ArrayList<>();
listeners.add(new AnsiOutputApplicationListener());
listeners.add(new ConfigFileApplicationListener());
listeners.add(new ClasspathLoggingApplicationListener());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ public class DevToolsDataSourceAutoConfiguration {
static final class NonEmbeddedInMemoryDatabaseShutdownExecutor
implements DisposableBean {
private static final Set<String> IN_MEMORY_DRIVER_CLASS_NAMES = new HashSet<String>(
private static final Set<String> IN_MEMORY_DRIVER_CLASS_NAMES = new HashSet<>(
Arrays.asList("org.apache.derby.jdbc.EmbeddedDriver", "org.h2.Driver",
"org.h2.jdbcx.JdbcDataSource", "org.hsqldb.jdbcDriver",
"org.hsqldb.jdbc.JDBCDriver",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -101,7 +101,7 @@ public class DevToolsProperties {
/**
* Additional paths to watch for changes.
*/
private List<File> additionalPaths = new ArrayList<File>();
private List<File> additionalPaths = new ArrayList<>();
public boolean isEnabled() {
return this.enabled;
@@ -112,7 +112,7 @@ public class DevToolsProperties {
}
public String[] getAllExclude() {
List<String> allExclude = new ArrayList<String>();
List<String> allExclude = new ArrayList<>();
if (StringUtils.hasText(this.exclude)) {
allExclude.addAll(StringUtils.commaDelimitedListToSet(this.exclude));
}

View File

@@ -95,9 +95,11 @@ public class RemoteDevToolsAutoConfiguration {
@Bean
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
Handler handler = new HttpStatusHandler();
return new UrlHandlerMapper((this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
+ this.properties.getRemote().getContextPath(), handler);
return new UrlHandlerMapper(
(this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
+ this.properties.getRemote().getContextPath(),
handler);
}
@Bean

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public class ClassPathFolders implements Iterable<File> {
private static final Log logger = LogFactory.getLog(ClassPathFolders.class);
private final List<File> folders = new ArrayList<File>();
private final List<File> folders = new ArrayList<>();
public ClassPathFolders(URL[] urls) {
if (urls != null) {

View File

@@ -45,7 +45,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
private static final Map<String, Object> PROPERTIES;
static {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.thymeleaf.cache", "false");
properties.put("spring.freemarker.cache", "false");
properties.put("spring.groovy.template.cache", "false");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public class FileSystemWatcher {
private static final long DEFAULT_QUIET_PERIOD = 400;
private final List<FileChangeListener> listeners = new ArrayList<FileChangeListener>();
private final List<FileChangeListener> listeners = new ArrayList<>();
private final boolean daemon;
@@ -55,7 +55,7 @@ public class FileSystemWatcher {
private final AtomicInteger remainingScans = new AtomicInteger(-1);
private final Map<File, FolderSnapshot> folders = new HashMap<File, FolderSnapshot>();
private final Map<File, FolderSnapshot> folders = new HashMap<>();
private Thread watchThread;
@@ -152,12 +152,11 @@ public class FileSystemWatcher {
synchronized (this.monitor) {
saveInitialSnapshots();
if (this.watchThread == null) {
Map<File, FolderSnapshot> localFolders = new HashMap<File, FolderSnapshot>();
Map<File, FolderSnapshot> localFolders = new HashMap<>();
localFolders.putAll(this.folders);
this.watchThread = new Thread(new Watcher(this.remainingScans,
new ArrayList<FileChangeListener>(this.listeners),
this.triggerFilter, this.pollInterval, this.quietPeriod,
localFolders));
new ArrayList<>(this.listeners), this.triggerFilter,
this.pollInterval, this.quietPeriod, localFolders));
this.watchThread.setName("File Watcher");
this.watchThread.setDaemon(this.daemon);
this.watchThread.start();
@@ -276,7 +275,7 @@ public class FileSystemWatcher {
}
private Map<File, FolderSnapshot> getCurrentSnapshots() {
Map<File, FolderSnapshot> snapshots = new LinkedHashMap<File, FolderSnapshot>();
Map<File, FolderSnapshot> snapshots = new LinkedHashMap<>();
for (File folder : this.folders.keySet()) {
snapshots.put(folder, new FolderSnapshot(folder));
}
@@ -284,8 +283,8 @@ public class FileSystemWatcher {
}
private void updateSnapshots(Collection<FolderSnapshot> snapshots) {
Map<File, FolderSnapshot> updated = new LinkedHashMap<File, FolderSnapshot>();
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
Map<File, FolderSnapshot> updated = new LinkedHashMap<>();
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
for (FolderSnapshot snapshot : snapshots) {
FolderSnapshot previous = this.folders.get(snapshot.getFolder());
updated.put(snapshot.getFolder(), snapshot);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
class FolderSnapshot {
private static final Set<String> DOT_FOLDERS = Collections
.unmodifiableSet(new HashSet<String>(Arrays.asList(".", "..")));
.unmodifiableSet(new HashSet<>(Arrays.asList(".", "..")));
private final File folder;
@@ -55,7 +55,7 @@ class FolderSnapshot {
Assert.isTrue(folder.isDirectory(), "Folder must not be a file");
this.folder = folder;
this.time = new Date();
Set<FileSnapshot> files = new LinkedHashSet<FileSnapshot>();
Set<FileSnapshot> files = new LinkedHashSet<>();
collectFiles(folder, files);
this.files = Collections.unmodifiableSet(files);
}
@@ -80,7 +80,7 @@ class FolderSnapshot {
File folder = this.folder;
Assert.isTrue(snapshot.folder.equals(folder),
"Snapshot source folder must be '" + folder + "'");
Set<ChangedFile> changes = new LinkedHashSet<ChangedFile>();
Set<ChangedFile> changes = new LinkedHashSet<>();
Map<File, FileSnapshot> previousFiles = getFilesMap();
for (FileSnapshot currentFile : snapshot.files) {
if (acceptChangedFile(triggerFilter, currentFile)) {
@@ -107,7 +107,7 @@ class FolderSnapshot {
}
private Map<File, FileSnapshot> getFilesMap() {
Map<File, FileSnapshot> files = new LinkedHashMap<File, FileSnapshot>();
Map<File, FileSnapshot> files = new LinkedHashMap<>();
for (FileSnapshot file : this.files) {
files.put(file.getFile(), file);
}
@@ -141,7 +141,7 @@ class FolderSnapshot {
if (filter == null) {
return source;
}
Set<FileSnapshot> filtered = new LinkedHashSet<FileSnapshot>();
Set<FileSnapshot> filtered = new LinkedHashSet<>();
for (FileSnapshot file : source) {
if (filter.accept(file.getFile())) {
filtered.add(file);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public class LiveReloadServer {
private final ExecutorService executor = Executors
.newCachedThreadPool(new WorkerThreadFactory());
private final List<Connection> connections = new ArrayList<Connection>();
private final List<Connection> connections = new ArrayList<>();
private final Object monitor = new Object();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class ClassPathChangeUploader
private static final Map<ChangedFile.Type, ClassLoaderFile.Kind> TYPE_MAPPINGS;
static {
Map<ChangedFile.Type, ClassLoaderFile.Kind> map = new HashMap<ChangedFile.Type, ClassLoaderFile.Kind>();
Map<ChangedFile.Type, ClassLoaderFile.Kind> map = new HashMap<>();
map.put(ChangedFile.Type.ADD, ClassLoaderFile.Kind.ADDED);
map.put(ChangedFile.Type.DELETE, ClassLoaderFile.Kind.DELETED);
map.put(ChangedFile.Type.MODIFY, ClassLoaderFile.Kind.MODIFIED);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class Dispatcher {
Assert.notNull(accessManager, "AccessManager must not be null");
Assert.notNull(mappers, "Mappers must not be null");
this.accessManager = accessManager;
this.mappers = new ArrayList<HandlerMapper>(mappers);
this.mappers = new ArrayList<>(mappers);
AnnotationAwareOrderComparator.sort(this.mappers);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public abstract class AgentReloader {
private static final Set<String> AGENT_CLASSES;
static {
Set<String> agentClasses = new LinkedHashSet<String>();
Set<String> agentClasses = new LinkedHashSet<>();
agentClasses.add("org.zeroturnaround.javarebel.Integration");
agentClasses.add("org.zeroturnaround.javarebel.ReloaderFactory");
AGENT_CLASSES = Collections.unmodifiableSet(agentClasses);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ final class ChangeableUrls implements Iterable<URL> {
private ChangeableUrls(URL... urls) {
DevToolsSettings settings = DevToolsSettings.get();
List<URL> reloadableUrls = new ArrayList<URL>(urls.length);
List<URL> reloadableUrls = new ArrayList<>(urls.length);
for (URL url : urls) {
if ((settings.isRestartInclude(url) || isFolderUrl(url.toString()))
&& !settings.isRestartExclude(url)) {
@@ -90,7 +90,7 @@ final class ChangeableUrls implements Iterable<URL> {
}
public static ChangeableUrls fromUrlClassLoader(URLClassLoader classLoader) {
List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();
for (URL url : classLoader.getURLs()) {
urls.add(url);
urls.addAll(getUrlsFromClassPathOfJarManifestIfPossible(url));
@@ -136,7 +136,7 @@ final class ChangeableUrls implements Iterable<URL> {
return Collections.emptyList();
}
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
List<URL> urls = new ArrayList<URL>(entries.length);
List<URL> urls = new ArrayList<>(entries.length);
for (String entry : entries) {
try {
urls.add(new URL(base, entry));
@@ -150,7 +150,7 @@ final class ChangeableUrls implements Iterable<URL> {
}
public static ChangeableUrls fromUrls(Collection<URL> urls) {
return fromUrls(new ArrayList<URL>(urls).toArray(new URL[urls.size()]));
return fromUrls(new ArrayList<>(urls).toArray(new URL[urls.size()]));
}
public static ChangeableUrls fromUrls(URL... urls) {

View File

@@ -108,7 +108,7 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
@Override
public Resource[] getResources(String locationPattern) throws IOException {
List<Resource> resources = new ArrayList<Resource>();
List<Resource> resources = new ArrayList<>();
Resource[] candidates = this.patternResolverDelegate
.getResources(locationPattern);
for (Resource candidate : candidates) {
@@ -122,7 +122,7 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
private List<Resource> getAdditionalResources(String locationPattern)
throws MalformedURLException {
List<Resource> additionalResources = new ArrayList<Resource>();
List<Resource> additionalResources = new ArrayList<>();
String trimmedLocationPattern = trimLocationPattern(locationPattern);
for (SourceFolder sourceFolder : this.classLoaderFiles.getSourceFolders()) {
for (Entry<String, ClassLoaderFile> entry : sourceFolder.getFilesEntrySet()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class DefaultRestartInitializer implements RestartInitializer {
private static final Set<String> SKIPPED_STACK_ELEMENTS;
static {
Set<String> skipped = new LinkedHashSet<String>();
Set<String> skipped = new LinkedHashSet<>();
skipped.add("org.junit.runners.");
skipped.add("org.springframework.boot.test.");
skipped.add("cucumber.runtime.");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -89,13 +89,13 @@ public class Restarter {
private static Restarter instance;
private final Set<URL> urls = new LinkedHashSet<URL>();
private final Set<URL> urls = new LinkedHashSet<>();
private final ClassLoaderFiles classLoaderFiles = new ClassLoaderFiles();
private final Map<String, Object> attributes = new HashMap<String, Object>();
private final Map<String, Object> attributes = new HashMap<>();
private final BlockingDeque<LeakSafeThread> leakSafeThreads = new LinkedBlockingDeque<LeakSafeThread>();
private final BlockingDeque<LeakSafeThread> leakSafeThreads = new LinkedBlockingDeque<>();
private final Lock stopLock = new ReentrantLock();
@@ -119,7 +119,7 @@ public class Restarter {
private boolean finished = false;
private final List<ConfigurableApplicationContext> rootContexts = new CopyOnWriteArrayList<ConfigurableApplicationContext>();
private final List<ConfigurableApplicationContext> rootContexts = new CopyOnWriteArrayList<>();
/**
* Internal constructor to create a new {@link Restarter} instance.
@@ -387,7 +387,7 @@ public class Restarter {
*/
private void forceReferenceCleanup() {
try {
final List<long[]> memory = new LinkedList<long[]>();
final List<long[]> memory = new LinkedList<>();
while (true) {
memory.add(new long[102400]);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public class ClassLoaderFiles implements ClassLoaderFileRepository, Serializable
* Create a new {@link ClassLoaderFiles} instance.
*/
public ClassLoaderFiles() {
this.sourceFolders = new LinkedHashMap<String, SourceFolder>();
this.sourceFolders = new LinkedHashMap<>();
}
/**
@@ -56,8 +56,7 @@ public class ClassLoaderFiles implements ClassLoaderFileRepository, Serializable
*/
public ClassLoaderFiles(ClassLoaderFiles classLoaderFiles) {
Assert.notNull(classLoaderFiles, "ClassLoaderFiles must not be null");
this.sourceFolders = new LinkedHashMap<String, SourceFolder>(
classLoaderFiles.sourceFolders);
this.sourceFolders = new LinkedHashMap<>(classLoaderFiles.sourceFolders);
}
/**
@@ -158,7 +157,7 @@ public class ClassLoaderFiles implements ClassLoaderFileRepository, Serializable
private final String name;
private final Map<String, ClassLoaderFile> files = new LinkedHashMap<String, ClassLoaderFile>();
private final Map<String, ClassLoaderFile> files = new LinkedHashMap<>();
SourceFolder(String name) {
this.name = name;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@ public class RestartClassLoader extends URLClassLoader implements SmartClassLoad
resources.nextElement();
}
if (file.getKind() != Kind.DELETED) {
return new CompoundEnumeration<URL>(createFileUrl(name, file), resources);
return new CompoundEnumeration<>(createFileUrl(name, file), resources);
}
}
return resources;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class DefaultSourceFolderUrlFilter implements SourceFolderUrlFilter {
private static final Pattern VERSION_PATTERN = Pattern
.compile("^-\\d+(?:\\.\\d+)*(?:[.-].+)?$");
private static final Set<String> SKIPPED_PROJECTS = new HashSet<String>(Arrays.asList(
private static final Set<String> SKIPPED_PROJECTS = new HashSet<>(Arrays.asList(
"spring-boot", "spring-boot-devtools", "spring-boot-autoconfigure",
"spring-boot-actuator", "spring-boot-starter"));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -81,7 +81,7 @@ public class RestartServer {
* @param files updated class loader files
*/
public void updateAndRestart(ClassLoaderFiles files) {
Set<URL> urls = new LinkedHashSet<URL>();
Set<URL> urls = new LinkedHashSet<>();
Set<URL> classLoaderUrls = getClassLoaderUrls();
for (SourceFolder folder : files.getSourceFolders()) {
for (Entry<String, ClassLoaderFile> entry : folder.getFilesEntrySet()) {
@@ -124,7 +124,7 @@ public class RestartServer {
}
private Set<URL> getMatchingUrls(Set<URL> urls, String sourceFolder) {
Set<URL> matchingUrls = new LinkedHashSet<URL>();
Set<URL> matchingUrls = new LinkedHashSet<>();
for (URL url : urls) {
if (this.sourceFolderUrlFilter.isMatch(sourceFolder, url)) {
if (logger.isDebugEnabled()) {
@@ -138,7 +138,7 @@ public class RestartServer {
}
private Set<URL> getClassLoaderUrls() {
Set<URL> urls = new LinkedHashSet<URL>();
Set<URL> urls = new LinkedHashSet<>();
ClassLoader classLoader = this.classLoader;
while (classLoader != null) {
if (classLoader instanceof URLClassLoader) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,9 +47,9 @@ public class DevToolsSettings {
private static DevToolsSettings settings;
private final List<Pattern> restartIncludePatterns = new ArrayList<Pattern>();
private final List<Pattern> restartIncludePatterns = new ArrayList<>();
private final List<Pattern> restartExcludePatterns = new ArrayList<Pattern>();
private final List<Pattern> restartExcludePatterns = new ArrayList<>();
DevToolsSettings() {
}
@@ -62,7 +62,7 @@ public class DevToolsSettings {
}
private Map<String, Pattern> getPatterns(Map<?, ?> properties, String prefix) {
Map<String, Pattern> patterns = new LinkedHashMap<String, Pattern>();
Map<String, Pattern> patterns = new LinkedHashMap<>();
for (Map.Entry<?, ?> entry : properties.entrySet()) {
String name = String.valueOf(entry.getKey());
if (name.startsWith(prefix)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ import org.springframework.util.Assert;
*/
class TunnelClientListeners {
private final List<TunnelClientListener> listeners = new CopyOnWriteArrayList<TunnelClientListener>();
private final List<TunnelClientListener> listeners = new CopyOnWriteArrayList<>();
public void addListener(TunnelClientListener listener) {
Assert.notNull(listener, "Listener must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public class HttpTunnelPayloadForwarder {
private static final int MAXIMUM_QUEUE_SIZE = 100;
private final Map<Long, HttpTunnelPayload> queue = new HashMap<Long, HttpTunnelPayload>();
private final Map<Long, HttpTunnelPayload> queue = new HashMap<>();
private final Object monitor = new Object();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -227,7 +227,7 @@ public class HttpTunnelServer {
public ServerThread(ByteChannel targetServer) {
Assert.notNull(targetServer, "TargetServer must not be null");
this.targetServer = targetServer;
this.httpConnections = new ArrayDeque<HttpConnection>(2);
this.httpConnections = new ArrayDeque<>(2);
this.payloadForwarder = new HttpTunnelPayloadForwarder(targetServer);
}

View File

@@ -167,7 +167,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void liveReloadDisabled() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.livereload.enabled", false);
this.context = initializeAndRun(Config.class, properties);
this.thrown.expect(NoSuchBeanDefinitionException.class);
@@ -202,7 +202,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void restartDisabled() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.restart.enabled", false);
this.context = initializeAndRun(Config.class, properties);
this.thrown.expect(NoSuchBeanDefinitionException.class);
@@ -211,7 +211,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void restartWithTriggerFile() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.restart.trigger-file", "somefile.txt");
this.context = initializeAndRun(Config.class, properties);
ClassPathFileSystemWatcher classPathWatcher = this.context
@@ -224,7 +224,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Test
public void watchingAdditionalPaths() throws Exception {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.devtools.restart.additional-paths",
"src/main/java,src/test/java");
this.context = initializeAndRun(Config.class, properties);
@@ -268,7 +268,7 @@ public class LocalDevToolsAutoConfigurationTests {
private Map<String, Object> getDefaultProperties(
Map<String, Object> specifiedProperties) {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
properties.put("spring.thymeleaf.check-template-location", false);
properties.put("spring.devtools.livereload.port", this.liveReloadPort);
properties.put("server.port", 0);
@@ -307,7 +307,7 @@ public class LocalDevToolsAutoConfigurationTests {
@Bean
public RedisTemplate<Object, Object> sessionRedisTemplate() {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<Object, Object>();
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(mock(RedisConnectionFactory.class));
return redisTemplate;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ public class ClassPathChangedEventTests {
@Test
public void getChangeSet() throws Exception {
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
ClassPathChangedEvent event = new ClassPathChangedEvent(this.source, changeSet,
false);
assertThat(event.getChangeSet()).isSameAs(changeSet);
@@ -56,7 +56,7 @@ public class ClassPathChangedEventTests {
@Test
public void getRestartRequired() throws Exception {
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
ClassPathChangedEvent event;
event = new ClassPathChangedEvent(this.source, changeSet, false);
assertThat(event.isRestartRequired()).isFalse();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,7 +103,7 @@ public class ClassPathFileChangeListenerTests {
File file = new File("f1");
ChangedFile file1 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
ChangedFile file2 = new ChangedFile(folder, file, ChangedFile.Type.ADD);
Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
Set<ChangedFile> files = new LinkedHashSet<>();
files.add(file1);
files.add(file2);
ChangedFiles changedFiles = new ChangedFiles(new File("source"), files);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,9 +67,9 @@ public class ClassPathFileSystemWatcherTests {
@Test
public void configuredWithRestartStrategy() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
File folder = this.temp.newFolder();
List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();
urls.add(new URL("http://spring.io"));
urls.add(folder.toURI().toURL());
properties.put("urls", urls);
@@ -132,7 +132,7 @@ public class ClassPathFileSystemWatcherTests {
public static class Listener implements ApplicationListener<ClassPathChangedEvent> {
private List<ClassPathChangedEvent> events = new ArrayList<ClassPathChangedEvent>();
private List<ClassPathChangedEvent> events = new ArrayList<>();
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {

View File

@@ -219,7 +219,7 @@ public class FileSystemWatcherTests {
@Test
public void multipleListeners() throws Exception {
File folder = this.temp.newFolder();
final Set<ChangedFiles> listener2Changes = new LinkedHashSet<ChangedFiles>();
final Set<ChangedFiles> listener2Changes = new LinkedHashSet<>();
this.watcher.addSourceFolder(folder);
this.watcher.addListener(new FileChangeListener() {
@Override
@@ -249,7 +249,7 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles();
Set<ChangedFile> actual = changedFiles.getFiles();
Set<ChangedFile> expected = new HashSet<ChangedFile>();
Set<ChangedFile> expected = new HashSet<>();
expected.add(new ChangedFile(folder, modify, Type.MODIFY));
expected.add(new ChangedFile(folder, delete, Type.DELETE));
expected.add(new ChangedFile(folder, add, Type.ADD));
@@ -278,7 +278,7 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles();
Set<ChangedFile> actual = changedFiles.getFiles();
Set<ChangedFile> expected = new HashSet<ChangedFile>();
Set<ChangedFile> expected = new HashSet<>();
expected.add(new ChangedFile(folder, file, Type.MODIFY));
assertThat(actual).isEqualTo(expected);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -156,7 +156,7 @@ public class LiveReloadServerTests {
*/
private static class MonitoredLiveReloadServer extends LiveReloadServer {
private final List<ConnectionClosedException> closedExceptions = new ArrayList<ConnectionClosedException>();
private final List<ConnectionClosedException> closedExceptions = new ArrayList<>();
private final Object monitor = new Object();
@@ -172,7 +172,7 @@ public class LiveReloadServerTests {
public List<ConnectionClosedException> getClosedExceptions() {
synchronized (this.monitor) {
return new ArrayList<ConnectionClosedException>(this.closedExceptions);
return new ArrayList<>(this.closedExceptions);
}
}
@@ -207,7 +207,7 @@ public class LiveReloadServerTests {
private final CountDownLatch helloLatch = new CountDownLatch(2);
private final List<String> messages = new ArrayList<String>();
private final List<String> messages = new ArrayList<>();
private int pongCount;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -145,14 +145,14 @@ public class ClassPathChangeUploaderTests {
private ClassPathChangedEvent createClassPathChangedEvent(File sourceFolder)
throws IOException {
Set<ChangedFile> files = new LinkedHashSet<ChangedFile>();
Set<ChangedFile> files = new LinkedHashSet<>();
File file1 = createFile(sourceFolder, "File1");
File file2 = createFile(sourceFolder, "File2");
File file3 = createFile(sourceFolder, "File3");
files.add(new ChangedFile(sourceFolder, file1, Type.ADD));
files.add(new ChangedFile(sourceFolder, file2, Type.MODIFY));
files.add(new ChangedFile(sourceFolder, file3, Type.DELETE));
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
changeSet.add(new ChangedFiles(sourceFolder, files));
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
return event;

View File

@@ -112,7 +112,7 @@ public class RemoteClientConfigurationTests {
@Test
public void liveReloadOnClassPathChanged() throws Exception {
configure();
Set<ChangedFiles> changeSet = new HashSet<ChangedFiles>();
Set<ChangedFiles> changeSet = new HashSet<>();
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
this.context.publishEvent(event);
LiveReloadConfiguration configuration = this.context

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ public class MainMethodTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
private static ThreadLocal<MainMethod> mainMethod = new ThreadLocal<MainMethod>();
private static ThreadLocal<MainMethod> mainMethod = new ThreadLocal<>();
private Method actualMain;

View File

@@ -41,7 +41,7 @@ import static org.mockito.Mockito.mock;
*/
public class MockRestarter implements TestRule {
private Map<String, Object> attributes = new HashMap<String, Object>();
private Map<String, Object> attributes = new HashMap<>();
private Restarter mock = mock(Restarter.class);

View File

@@ -214,7 +214,7 @@ public class RestartClassLoaderTests {
}
private <T> List<T> toList(Enumeration<T> enumeration) {
List<T> list = new ArrayList<T>();
List<T> list = new ArrayList<>();
if (enumeration != null) {
while (enumeration.hasMoreElements()) {
list.add(enumeration.nextElement());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public class DefaultSourceFolderUrlFilterTests {
private static final List<String> COMMON_POSTFIXES;
static {
List<String> postfixes = new ArrayList<String>();
List<String> postfixes = new ArrayList<>();
postfixes.add(".jar");
postfixes.add("-1.3.0.jar");
postfixes.add("-1.3.0-SNAPSHOT.jar");
@@ -105,7 +105,7 @@ public class DefaultSourceFolderUrlFilterTests {
}
private List<URL> getUrls(String name) throws MalformedURLException {
List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();
urls.add(new URL("file:/some/path/" + name));
urls.add(new URL("file:/some/path/" + name + "!/"));
for (String postfix : COMMON_POSTFIXES) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,7 +73,7 @@ public class RestartServerTests {
files.addFile("my/module-a", "ClassA.class", fileA);
files.addFile("my/module-c", "ClassB.class", fileB);
server.updateAndRestart(files);
Set<URL> expectedUrls = new LinkedHashSet<URL>(Arrays.asList(url1, url3));
Set<URL> expectedUrls = new LinkedHashSet<>(Arrays.asList(url1, url3));
assertThat(server.restartUrls).isEqualTo(expectedUrls);
assertThat(server.restartFiles).isEqualTo(files);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,9 +43,9 @@ public class MockClientHttpRequestFactory implements ClientHttpRequestFactory {
private AtomicLong seq = new AtomicLong();
private Deque<Object> responses = new ArrayDeque<Object>();
private Deque<Object> responses = new ArrayDeque<>();
private List<MockClientHttpRequest> executedRequests = new ArrayList<MockClientHttpRequest>();
private List<MockClientHttpRequest> executedRequests = new ArrayList<>();
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod)

View File

@@ -345,7 +345,7 @@ public class HttpTunnelServerTests {
private int timeout;
private BlockingDeque<ByteBuffer> outgoing = new LinkedBlockingDeque<ByteBuffer>();
private BlockingDeque<ByteBuffer> outgoing = new LinkedBlockingDeque<>();
private ByteArrayOutputStream written = new ByteArrayOutputStream();