diff --git a/core/src/main/java/hudson/AbstractMarkupText.java b/core/src/main/java/hudson/AbstractMarkupText.java index 1e78b3e10cfa..2398f6f74469 100644 --- a/core/src/main/java/hudson/AbstractMarkupText.java +++ b/core/src/main/java/hudson/AbstractMarkupText.java @@ -141,7 +141,7 @@ public MarkupText.SubText findToken(Pattern pattern) { public List findTokens(Pattern pattern) { String text = getText(); Matcher m = pattern.matcher(text); - List r = new ArrayList(); + List r = new ArrayList<>(); while(m.find()) { int idx = m.start(); diff --git a/core/src/main/java/hudson/BulkChange.java b/core/src/main/java/hudson/BulkChange.java index 28b9fde42610..e65fa4d3acb6 100644 --- a/core/src/main/java/hudson/BulkChange.java +++ b/core/src/main/java/hudson/BulkChange.java @@ -132,7 +132,7 @@ private void pop() { /** * {@link BulkChange}s that are effective currently. */ - private static final ThreadLocal INSCOPE = new ThreadLocal(); + private static final ThreadLocal INSCOPE = new ThreadLocal<>(); /** * Gets the {@link BulkChange} instance currently in scope for the current thread. diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index fdd2e88dd196..1d93d3fb249c 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -192,7 +192,7 @@ private static Manifest loadLinkedManifest(File archive) throws IOException { // TODO: define a mechanism to hide classes // String export = manifest.getMainAttributes().getValue("Export"); - List paths = new ArrayList(); + List paths = new ArrayList<>(); if (isLinked) { parseClassPath(manifest, archive, paths, "Libraries", ","); parseClassPath(manifest, archive, paths, "Class-Path", " +"); // backward compatibility @@ -218,8 +218,8 @@ private static Manifest loadLinkedManifest(File archive) throws IOException { } // compute dependencies - List dependencies = new ArrayList(); - List optionalDependencies = new ArrayList(); + List dependencies = new ArrayList<>(); + List optionalDependencies = new ArrayList<>(); String v = atts.getValue("Plugin-Dependencies"); if (v != null) { for (String s : v.split(",")) { @@ -336,7 +336,7 @@ public List> findComponents(Class type, Hudson huds } catch (AbstractMethodError e) { // backward compatibility for (T t : finder.findExtensions(type, hudson)) - r.add(new ExtensionComponent(t)); + r.add(new ExtensionComponent<>(t)); } } @@ -578,7 +578,7 @@ private List getTransitiveDependencies() { CyclicGraphDetector cgd = new CyclicGraphDetector() { @Override protected List getEdges(PluginWrapper pw) { - List dep = new ArrayList(); + List dep = new ArrayList<>(); for (Dependency d : pw.getDependencies()) { PluginWrapper p = pluginManager.getPlugin(d.shortName); if (p!=null && p.isActive()) @@ -644,7 +644,7 @@ protected Class findClass(String name) throws ClassNotFoundException { @SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Should not produce network overheads since the URL is local. JENKINS-53793 is a follow-up") protected Enumeration findResources(String name) throws IOException { - HashSet result = new HashSet(); + HashSet result = new HashSet<>(); if (PluginManager.FAST_LOOKUP) { for (PluginWrapper pw : getTransitiveDependencies()) { diff --git a/core/src/main/java/hudson/DNSMultiCast.java b/core/src/main/java/hudson/DNSMultiCast.java index aa71b2e23b2b..fcb3fe33bb05 100644 --- a/core/src/main/java/hudson/DNSMultiCast.java +++ b/core/src/main/java/hudson/DNSMultiCast.java @@ -32,7 +32,7 @@ public Object call() { try { jmdns = JmDNS.create(); - Map props = new HashMap(); + Map props = new HashMap<>(); String rootURL = jenkins.getRootUrl(); if (rootURL==null) return null; diff --git a/core/src/main/java/hudson/DescriptorExtensionList.java b/core/src/main/java/hudson/DescriptorExtensionList.java index 8452227e5e94..5e9d35f7ec4a 100644 --- a/core/src/main/java/hudson/DescriptorExtensionList.java +++ b/core/src/main/java/hudson/DescriptorExtensionList.java @@ -76,7 +76,7 @@ DescriptorExtensionList createDescriptorList(Jenkins jenkins, Class desc if (describableType == (Class) Publisher.class) { return (DescriptorExtensionList) new Publisher.DescriptorExtensionListImpl(jenkins); } - return new DescriptorExtensionList(jenkins,describableType); + return new DescriptorExtensionList<>(jenkins, describableType); } /** @@ -199,7 +199,7 @@ protected Collection> load(ExtensionComponentSet delta) { } private List> _load(Iterable> set) { - List> r = new ArrayList>(); + List> r = new ArrayList<>(); for( ExtensionComponent c : set ) { Descriptor d = c.getInstance(); try { diff --git a/core/src/main/java/hudson/EnvVars.java b/core/src/main/java/hudson/EnvVars.java index 6d2f451071ee..8caaebf31290 100644 --- a/core/src/main/java/hudson/EnvVars.java +++ b/core/src/main/java/hudson/EnvVars.java @@ -200,7 +200,7 @@ public TraceResolver(Comparator comparator) { } public void clear() { - referredVariables = new TreeSet(comparator); + referredVariables = new TreeSet<>(comparator); } public String resolve(String name) { @@ -288,8 +288,8 @@ private void cutCycle(List cycle) { * Scan all variables and list all referring variables. */ public void scan() { - refereeSetMap = new TreeMap>(comparator); - List extendingVariableNames = new ArrayList(); + refereeSetMap = new TreeMap<>(comparator); + List extendingVariableNames = new ArrayList<>(); TraceResolver resolver = new TraceResolver(comparator); @@ -327,10 +327,10 @@ public void scan() { // When A refers B, the last appearance of B always comes after // the last appearance of A. - List reversedDuplicatedOrder = new ArrayList(sorter.getSorted()); + List reversedDuplicatedOrder = new ArrayList<>(sorter.getSorted()); Collections.reverse(reversedDuplicatedOrder); - orderedVariableNames = new ArrayList(overrides.size()); + orderedVariableNames = new ArrayList<>(overrides.size()); for(String key: reversedDuplicatedOrder) { if(overrides.containsKey(key) && !orderedVariableNames.contains(key)) { orderedVariableNames.add(key); diff --git a/core/src/main/java/hudson/ExpressionFactory2.java b/core/src/main/java/hudson/ExpressionFactory2.java index 277858c933d5..c8704fccfdb8 100644 --- a/core/src/main/java/hudson/ExpressionFactory2.java +++ b/core/src/main/java/hudson/ExpressionFactory2.java @@ -168,5 +168,5 @@ public Collection values() { * * @see Functions#getCurrentJellyContext() */ - protected static final ThreadLocal CURRENT_CONTEXT = new ThreadLocal(); + protected static final ThreadLocal CURRENT_CONTEXT = new ThreadLocal<>(); } diff --git a/core/src/main/java/hudson/ExtensionList.java b/core/src/main/java/hudson/ExtensionList.java index b4d32bd06de2..0417f1674ce1 100644 --- a/core/src/main/java/hudson/ExtensionList.java +++ b/core/src/main/java/hudson/ExtensionList.java @@ -86,7 +86,7 @@ public class ExtensionList extends AbstractList implements OnMaster { @CopyOnWrite private volatile List> extensions; - private final List listeners = new CopyOnWriteArrayList(); + private final List listeners = new CopyOnWriteArrayList<>(); /** * Place to store manually registered instances with the per-Hudson scope. @@ -104,7 +104,7 @@ protected ExtensionList(Hudson hudson, Class extensionType) { } protected ExtensionList(Jenkins jenkins, Class extensionType) { - this(jenkins,extensionType,new CopyOnWriteArrayList>()); + this(jenkins,extensionType, new CopyOnWriteArrayList<>()); } /** @@ -237,7 +237,7 @@ public boolean removeAll(Collection c) { private synchronized boolean removeSync(Object o) { boolean removed = removeComponent(legacyInstances, o); if(extensions!=null) { - List> r = new ArrayList>(extensions); + List> r = new ArrayList<>(extensions); removed |= removeComponent(r,o); extensions = sort(r); } @@ -279,11 +279,11 @@ public boolean add(T t) { } private synchronized boolean addSync(T t) { - legacyInstances.add(new ExtensionComponent(t)); + legacyInstances.add(new ExtensionComponent<>(t)); // if we've already filled extensions, add it if(extensions!=null) { - List> r = new ArrayList>(extensions); - r.add(new ExtensionComponent(t)); + List> r = new ArrayList<>(extensions); + r.add(new ExtensionComponent<>(t)); extensions = sort(r); } return true; @@ -395,7 +395,7 @@ protected Collection> load(ExtensionComponentSet delta) { * The implementation should copy a list, do a sort, and return the new instance. */ protected List> sort(List> r) { - r = new ArrayList>(r); + r = new ArrayList<>(r); Collections.sort(r); return r; } @@ -412,7 +412,7 @@ public static ExtensionList create(Hudson hudson, Class type) { @SuppressWarnings({"unchecked", "rawtypes"}) public static ExtensionList create(Jenkins jenkins, Class type) { if(type.getAnnotation(LegacyInstancesAreScopedToHudson.class)!=null) - return new ExtensionList(jenkins,type); + return new ExtensionList<>(jenkins, type); else { return new ExtensionList(jenkins, type, staticLegacyInstances.computeIfAbsent(type, key -> new CopyOnWriteArrayList())); } diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 66d2ea9aae03..13311e72b587 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -325,7 +325,7 @@ public static String normalize(@Nonnull String path) { } boolean isAbsolute = buf.length() > 0; // Split remaining path into tokens, trimming any duplicate or trailing separators - List tokens = new ArrayList(); + List tokens = new ArrayList<>(); int s = 0, end = path.length(); for (int i = 0; i < end; i++) { char c = path.charAt(i); @@ -1061,7 +1061,7 @@ private T act(final FileCallable callable, ClassLoader cl) throws IOExcep if(channel!=null) { // run this on a remote system try { - DelegatingCallable wrapper = new FileCallableWrapper(callable, cl); + DelegatingCallable wrapper = new FileCallableWrapper<>(callable, cl); for (FileCallableWrapperFactory factory : ExtensionList.lookup(FileCallableWrapperFactory.class)) { wrapper = factory.wrap(wrapper); } @@ -1136,7 +1136,7 @@ protected void after() {} */ public Future actAsync(final FileCallable callable) throws IOException, InterruptedException { try { - DelegatingCallable wrapper = new FileCallableWrapper(callable); + DelegatingCallable wrapper = new FileCallableWrapper<>(callable); for (FileCallableWrapperFactory factory : ExtensionList.lookup(FileCallableWrapperFactory.class)) { wrapper = factory.wrap(wrapper); } @@ -1839,7 +1839,7 @@ public List invoke(File f, VirtualChannel channel) throws IOException return Collections.emptyList(); } - ArrayList r = new ArrayList(children.length); + ArrayList r = new ArrayList<>(children.length); for (File child : children) r.add(new FilePath(child)); diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 118a1f70faf8..76fdf2f8130a 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -465,7 +465,7 @@ public static String appendIfNotNull(String text, String suffix, String nullText } public static Map getSystemProperties() { - return new TreeMap(System.getProperties()); + return new TreeMap<>(System.getProperties()); } /** @@ -479,7 +479,7 @@ public static String getSystemProperty(String key) { } public static Map getEnvVars() { - return new TreeMap(EnvVars.masterEnvVars); + return new TreeMap<>(EnvVars.masterEnvVars); } public static boolean isWindows() { @@ -544,7 +544,7 @@ private static String[] logRecordPreformat(LogRecord r) { * @since 1.525 */ public static Iterable reverse(Collection collection) { - List list = new ArrayList(collection); + List list = new ArrayList<>(collection); Collections.reverse(list); return list; } diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index f0f18b4f81df..45fe90cab0f2 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -197,14 +197,14 @@ public ProcStarter cmds(String... args) { } public ProcStarter cmds(File program, String... args) { - commands = new ArrayList(args.length+1); + commands = new ArrayList<>(args.length + 1); commands.add(program.getPath()); commands.addAll(Arrays.asList(args)); return this; } public ProcStarter cmds(List args) { - commands = new ArrayList(args); + commands = new ArrayList<>(args); return this; } diff --git a/core/src/main/java/hudson/Lookup.java b/core/src/main/java/hudson/Lookup.java index 090f3eb28449..b0b40ba89151 100644 --- a/core/src/main/java/hudson/Lookup.java +++ b/core/src/main/java/hudson/Lookup.java @@ -32,7 +32,7 @@ * @author Kohsuke Kawaguchi */ public class Lookup { - private final ConcurrentHashMap data = new ConcurrentHashMap(); + private final ConcurrentHashMap data = new ConcurrentHashMap<>(); public T get(Class type) { return type.cast(data.get(type)); diff --git a/core/src/main/java/hudson/Main.java b/core/src/main/java/hudson/Main.java index c4aa94275567..55ee2fb9f0aa 100644 --- a/core/src/main/java/hudson/Main.java +++ b/core/src/main/java/hudson/Main.java @@ -152,7 +152,7 @@ public static int remotePost(String[] args) throws Exception { // run the command long start = System.currentTimeMillis(); - List cmd = new ArrayList(); + List cmd = new ArrayList<>(); for( int i=1; i tags = new ArrayList(); + private final List tags = new ArrayList<>(); /** * Represents one mark up inserted into text. diff --git a/core/src/main/java/hudson/PermalinkList.java b/core/src/main/java/hudson/PermalinkList.java index 0c4a3085a630..caffd8baf0fe 100644 --- a/core/src/main/java/hudson/PermalinkList.java +++ b/core/src/main/java/hudson/PermalinkList.java @@ -60,7 +60,7 @@ public Permalink get(String id) { * Finds the closest name match by its ID. */ public Permalink findNearest(String id) { - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (Permalink p : this) ids.add(p.getId()); String nearest = EditDistance.findNearest(id, ids); diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index c26ca2439deb..ba0648b7bcc0 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -284,9 +284,9 @@ private enum PMConstructor { /** * All active plugins, topologically sorted so that when X depends on Y, Y appears in the list before X does. */ - protected final List activePlugins = new CopyOnWriteArrayList(); + protected final List activePlugins = new CopyOnWriteArrayList<>(); - protected final List failedPlugins = new ArrayList(); + protected final List failedPlugins = new ArrayList<>(); /** * Plug-in root directory. @@ -422,7 +422,7 @@ public void run(Reactor session) throws Exception { // once we've listed plugins, we can fill in the reactor with plugin-specific initialization tasks TaskGraphBuilder g = new TaskGraphBuilder(); - final Map inspectedShortNames = new HashMap(); + final Map inspectedShortNames = new HashMap<>(); for( final File arc : archives ) { g.followedBy().notFatal().attains(PLUGINS_LISTED).add("Inspecting plugin " + arc, new Executable() { @@ -465,7 +465,7 @@ public void run(Reactor reactor) throws Exception { CyclicGraphDetector cgd = new CyclicGraphDetector() { @Override protected List getEdges(PluginWrapper p) { - List next = new ArrayList(); + List next = new ArrayList<>(); addTo(p.getDependencies(), next); addTo(p.getOptionalDependencies(), next); return next; @@ -1241,7 +1241,7 @@ public PluginWrapper getPlugin(Class pluginClazz) { * @return The list of plugins implementing the specified class. */ public List getPlugins(Class pluginSuperclass) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (PluginWrapper p : getPlugins()) { if(pluginSuperclass.isInstance(p.getPlugin())) result.add(p); @@ -1264,7 +1264,7 @@ public String getSearchUrl() { */ @Deprecated public Collection> discover( Class spi ) { - Set> result = new HashSet>(); + Set> result = new HashSet<>(); for (PluginWrapper p : activePlugins) { Service.load(spi, p.classLoader, result); @@ -1807,7 +1807,7 @@ public Descriptor getProxyDescriptor() { */ public List> prevalidateConfig(InputStream configXml) throws IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); - List> jobs = new ArrayList>(); + List> jobs = new ArrayList<>(); UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); // TODO call uc.updateAllSites() when available? perhaps not, since we should not block on network here for (Map.Entry requestedPlugin : parseRequestedPlugins(configXml).entrySet()) { @@ -1901,7 +1901,7 @@ public HttpResponse doInstallNecessaryPlugins(StaplerRequest req) throws IOExcep * Parses configuration XML files and picks up references to XML files. */ public Map parseRequestedPlugins(InputStream configXml) throws IOException { - final Map requestedPlugins = new TreeMap(); + final Map requestedPlugins = new TreeMap<>(); try { SAXParserFactory.newInstance().newSAXParser().parse(configXml, new DefaultHandler() { @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { @@ -1981,16 +1981,16 @@ public final class UberClassLoader extends ClassLoader { * Make generated types visible. * Keyed by the generated class name. */ - private ConcurrentMap> generatedClasses = new ConcurrentHashMap>(); + private ConcurrentMap> generatedClasses = new ConcurrentHashMap<>(); /** Cache of loaded, or known to be unloadable, classes. */ - private final Map> loaded = new HashMap>(); + private final Map> loaded = new HashMap<>(); public UberClassLoader() { super(PluginManager.class.getClassLoader()); } public void addNamedClass(String className, Class c) { - generatedClasses.put(className,new WeakReference(c)); + generatedClasses.put(className, new WeakReference<>(c)); } @Override @@ -2071,7 +2071,7 @@ protected URL findResource(String name) { @Override protected Enumeration findResources(String name) throws IOException { - List resources = new ArrayList(); + List resources = new ArrayList<>(); if (FAST_LOOKUP) { for (PluginWrapper p : activePlugins) { resources.addAll(Collections.list(ClassLoaderReflectionToolkit._findResources(p.classLoader, name))); diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 9699df02c892..dc3de475bf37 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -114,7 +114,7 @@ public class Util { */ @Nonnull public static List filter( @Nonnull Iterable base, @Nonnull Class type ) { - List r = new ArrayList(); + List r = new ArrayList<>(); for (Object i : base) { if(type.isInstance(i)) r.add(type.cast(i)); @@ -144,7 +144,7 @@ public static List filter( @Nonnull List base, @Nonnull Class type */ @Nullable public static String replaceMacro( @CheckForNull String s, @Nonnull Map properties) { - return replaceMacro(s,new VariableResolver.ByMap(properties)); + return replaceMacro(s, new VariableResolver.ByMap<>(properties)); } /** @@ -783,7 +783,7 @@ public static String combine(long n, @Nonnull String suffix) { */ @Nonnull public static List createSubList(@Nonnull Collection source, @Nonnull Class type ) { - List r = new ArrayList(); + List r = new ArrayList<>(); for (Object item : source) { if(type.isInstance(item)) r.add(type.cast(item)); @@ -1117,7 +1117,7 @@ public static List join(@Nonnull Collection... items) { int size = 0; for (Collection item : items) size += item.size(); - List r = new ArrayList(size); + List r = new ArrayList<>(size); for (Collection item : items) r.addAll(item); return r; diff --git a/core/src/main/java/hudson/cli/CLICommand.java b/core/src/main/java/hudson/cli/CLICommand.java index 738c738a63e0..4a47ae973c8e 100644 --- a/core/src/main/java/hudson/cli/CLICommand.java +++ b/core/src/main/java/hudson/cli/CLICommand.java @@ -530,7 +530,7 @@ public static CLICommand clone(String name) { private static final Logger LOGGER = Logger.getLogger(CLICommand.class.getName()); - private static final ThreadLocal CURRENT_COMMAND = new ThreadLocal(); + private static final ThreadLocal CURRENT_COMMAND = new ThreadLocal<>(); /*package*/ static CLICommand setCurrent(CLICommand cmd) { CLICommand old = getCurrent(); diff --git a/core/src/main/java/hudson/cli/InstallPluginCommand.java b/core/src/main/java/hudson/cli/InstallPluginCommand.java index 2bbabe09c655..5279a7fd3a3f 100644 --- a/core/src/main/java/hudson/cli/InstallPluginCommand.java +++ b/core/src/main/java/hudson/cli/InstallPluginCommand.java @@ -63,7 +63,7 @@ public String getShortDescription() { "and the plugin will be installed from the update center. If the short name includes a minimum version number " + "(like ‘findbugs:1.4’), and there are multiple update centers publishing different versions, the update centers " + "will be searched in order for the first one publishing a version that is at least the specified version.") - public List sources = new ArrayList(); + public List sources = new ArrayList<>(); @Option(name="-name",usage="If specified, the plugin will be installed as this short name (whereas normally the name is inferred from the source name automatically).") public String name; // TODO better to parse out Short-Name from the manifest and deprecate this option diff --git a/core/src/main/java/hudson/console/ConsoleNote.java b/core/src/main/java/hudson/console/ConsoleNote.java index 39977a590ee5..3c18b657168a 100644 --- a/core/src/main/java/hudson/console/ConsoleNote.java +++ b/core/src/main/java/hudson/console/ConsoleNote.java @@ -340,7 +340,7 @@ public static int findPreamble(byte[] buf, int start, int len) { * @since 1.350 */ public static List removeNotes(Collection logLines) { - List r = new ArrayList(logLines.size()); + List r = new ArrayList<>(logLines.size()); for (String l : logLines) r.add(removeNotes(l)); return r; diff --git a/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java b/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java index 1ba648eb38fe..eba9991aff14 100644 --- a/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java +++ b/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java @@ -53,7 +53,7 @@ public final class MemoryUsageMonitor extends PeriodicWork { * A memory group is conceptually a set of memory pools. */ public final class MemoryGroup { - private final List pools = new ArrayList(); + private final List pools = new ArrayList<>(); /** * Trend of the memory usage, after GCs. diff --git a/core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java b/core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java index 8b3778262ef5..27a5685f1dcc 100644 --- a/core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java +++ b/core/src/main/java/hudson/diagnosis/NullIdDescriptorMonitor.java @@ -55,7 +55,7 @@ public String getDisplayName() { return Messages.NullIdDescriptorMonitor_DisplayName(); } - private final List problems = new ArrayList(); + private final List problems = new ArrayList<>(); @Override public boolean isActivated() { diff --git a/core/src/main/java/hudson/diagnosis/OldDataMonitor.java b/core/src/main/java/hudson/diagnosis/OldDataMonitor.java index 7fc185737c15..c4317b4816af 100644 --- a/core/src/main/java/hudson/diagnosis/OldDataMonitor.java +++ b/core/src/main/java/hudson/diagnosis/OldDataMonitor.java @@ -78,7 +78,7 @@ public class OldDataMonitor extends AdministrativeMonitor { private static final Logger LOGGER = Logger.getLogger(OldDataMonitor.class.getName()); - private ConcurrentMap data = new ConcurrentHashMap(); + private ConcurrentMap data = new ConcurrentHashMap<>(); /** * Gets instance of the monitor. @@ -106,7 +106,7 @@ public boolean isActivated() { } public Map getData() { - Map r = new HashMap(); + Map r = new HashMap<>(); for (Map.Entry entry : this.data.entrySet()) { Saveable s = entry.getKey().get(); if (s != null) { diff --git a/core/src/main/java/hudson/init/InitStrategy.java b/core/src/main/java/hudson/init/InitStrategy.java index 9d7d287c4310..c6c5795e546c 100644 --- a/core/src/main/java/hudson/init/InitStrategy.java +++ b/core/src/main/java/hudson/init/InitStrategy.java @@ -45,7 +45,7 @@ public class InitStrategy { * and when that happens, Jenkins will ignore all but the first one in the list. */ public List listPluginArchives(PluginManager pm) throws IOException { - List r = new ArrayList(); + List r = new ArrayList<>(); // the ordering makes sure that during the debugging we get proper precedence among duplicates. // for example, while doing "mvn jpi:run" or "mvn hpi:run" on a plugin that's bundled with Jenkins, we want to the diff --git a/core/src/main/java/hudson/init/TaskMethodFinder.java b/core/src/main/java/hudson/init/TaskMethodFinder.java index 0e09bfe26782..bbd60a61bfe0 100644 --- a/core/src/main/java/hudson/init/TaskMethodFinder.java +++ b/core/src/main/java/hudson/init/TaskMethodFinder.java @@ -32,7 +32,7 @@ abstract class TaskMethodFinder extends TaskBuilder { private static final Logger LOGGER = Logger.getLogger(TaskMethodFinder.class.getName()); protected final ClassLoader cl; - private final Set discovered = new HashSet(); + private final Set discovered = new HashSet<>(); private final Class type; private final Class milestoneType; @@ -52,7 +52,7 @@ public TaskMethodFinder(Class type, Class milestoneType, Clas protected abstract boolean fatalOf(T i); public Collection discoverTasks(Reactor session) throws IOException { - List result = new ArrayList(); + List result = new ArrayList<>(); for (Method e : Index.list(type, cl, Method.class)) { if (filter(e)) continue; // already reported once @@ -180,7 +180,7 @@ public String toString() { } private Collection toMilestones(String[] tokens, Milestone m) { - List r = new ArrayList(); + List r = new ArrayList<>(); for (String s : tokens) { try { r.add((Milestone)Enum.valueOf(milestoneType,s)); diff --git a/core/src/main/java/hudson/logging/LogRecorder.java b/core/src/main/java/hudson/logging/LogRecorder.java index 0ca0d57196a8..85de03238709 100644 --- a/core/src/main/java/hudson/logging/LogRecorder.java +++ b/core/src/main/java/hudson/logging/LogRecorder.java @@ -75,7 +75,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable { private volatile String name; - public final CopyOnWriteList targets = new CopyOnWriteList(); + public final CopyOnWriteList targets = new CopyOnWriteList<>(); private final static TargetComparator TARGET_COMPARATOR = new TargetComparator(); @Restricted(NoExternalUse.class) diff --git a/core/src/main/java/hudson/logging/LogRecorderManager.java b/core/src/main/java/hudson/logging/LogRecorderManager.java index 78c24c2a2efb..a572900a5597 100644 --- a/core/src/main/java/hudson/logging/LogRecorderManager.java +++ b/core/src/main/java/hudson/logging/LogRecorderManager.java @@ -68,7 +68,7 @@ public class LogRecorderManager extends AbstractModelObject implements ModelObje /** * {@link LogRecorder}s keyed by their {@linkplain LogRecorder#name name}. */ - public transient final Map logRecorders = new CopyOnWriteMap.Tree(); + public transient final Map logRecorders = new CopyOnWriteMap.Tree<>(); public String getDisplayName() { return Messages.LogRecorderManager_DisplayName(); @@ -160,7 +160,7 @@ public void doRss( StaplerRequest req, StaplerResponse rsp ) throws IOException, String level = req.getParameter("level"); if(level!=null) { Level threshold = Level.parse(level); - List filtered = new ArrayList(); + List filtered = new ArrayList<>(); for (LogRecord r : logs) { if(r.getLevel().intValue() >= threshold.intValue()) filtered.add(r); diff --git a/core/src/main/java/hudson/logging/WeakLogHandler.java b/core/src/main/java/hudson/logging/WeakLogHandler.java index 339c50ef6411..9a51f279de28 100644 --- a/core/src/main/java/hudson/logging/WeakLogHandler.java +++ b/core/src/main/java/hudson/logging/WeakLogHandler.java @@ -44,7 +44,7 @@ public final class WeakLogHandler extends Handler { public WeakLogHandler(Handler target, Logger logger) { this.logger = logger; logger.addHandler(this); - this.target = new WeakReference(target); + this.target = new WeakReference<>(target); } public void publish(LogRecord record) { diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index 2268f3dd9967..a868edb9de94 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -465,7 +465,7 @@ public Result run(@Nonnull BuildListener listener) throws Exception { listener.getLogger().print(Messages.AbstractBuild_BuildingOnMaster()); } else { listener.getLogger().print(Messages.AbstractBuild_BuildingRemotely(ModelHyperlinkNote.encodeTo("/computer/" + builtOn, node.getDisplayName()))); - Set assignedLabels = new HashSet(node.getAssignedLabels()); + Set assignedLabels = new HashSet<>(node.getAssignedLabels()); assignedLabels.remove(node.getSelfLabel()); if (!assignedLabels.isEmpty()) { boolean first = true; @@ -536,7 +536,7 @@ protected Launcher createLauncher(@Nonnull BuildListener listener) throws IOExce l = bw.decorateLauncher(AbstractBuild.this,l,listener); } - buildEnvironments = new ArrayList(); + buildEnvironments = new ArrayList<>(); for (RunListener rl: RunListener.all()) { Environment environment = rl.setUpEnvironment(AbstractBuild.this, l, listener); @@ -583,7 +583,7 @@ public void defaultCheckout() throws IOException, InterruptedException { } build.scm = scm.createChangeLogParser(); - build.changeSet = new WeakReference>(build.calcChangeSet()); + build.changeSet = new WeakReference<>(build.calcChangeSet()); for (SCMListener l : SCMListener.all()) try { @@ -635,7 +635,7 @@ public final void post(BuildListener listener) throws Exception { post2(listener); } finally { // update the culprit list - HashSet r = new HashSet(); + HashSet r = new HashSet<>(); for (User u : getCulprits()) r.add(u.getId()); culprits = ImmutableSortedSet.copyOf(r); @@ -834,7 +834,7 @@ protected final boolean preBuild(BuildListener listener,Iterable>(cs); + changeSet = new WeakReference<>(cs); return cs; } @@ -903,7 +903,7 @@ public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedE public EnvironmentList getEnvironments() { Executor e = Executor.currentExecutor(); if (e!=null && e.getCurrentExecutable()==this) { - if (buildEnvironments==null) buildEnvironments = new ArrayList(); + if (buildEnvironments==null) buildEnvironments = new ArrayList<>(); return new EnvironmentList(buildEnvironments); } @@ -936,7 +936,7 @@ public List getPersistentActions(){ * @since 1.378 */ public Set getSensitiveBuildVariables() { - Set s = new HashSet(); + Set s = new HashSet<>(); ParametersAction parameters = getAction(ParametersAction.class); if (parameters != null) { @@ -973,7 +973,7 @@ public Set getSensitiveBuildVariables() { * The returned map is mutable so that subtypes can put more values. */ public Map getBuildVariables() { - Map r = new HashMap(); + Map r = new HashMap<>(); ParametersAction parameters = getAction(ParametersAction.class); if (parameters!=null) { @@ -1000,7 +1000,7 @@ public Map getBuildVariables() { * Creates {@link VariableResolver} backed by {@link #getBuildVariables()}. */ public final VariableResolver getBuildVariableResolver() { - return new VariableResolver.ByMap(getBuildVariables()); + return new VariableResolver.ByMap<>(getBuildVariables()); } /** @@ -1173,7 +1173,7 @@ public AbstractBuild getUpstreamRelationshipBuild(AbstractProject that * of builds (which can be empty if no build uses the artifact from this build or downstream is not {@link AbstractProject#isFingerprintConfigured}.) */ public Map getDownstreamBuilds() { - Map r = new HashMap(); + Map r = new HashMap<>(); for (AbstractProject p : getParent().getDownstreamProjects()) { if (p.isFingerprintConfigured()) r.put(p,getDownstreamRelationship(p)); @@ -1200,7 +1200,7 @@ public Map getTransitiveUpstreamBuilds() { } private Map _getUpstreamBuilds(Collection projects) { - Map r = new HashMap(); + Map r = new HashMap<>(); for (AbstractProject p : projects) { int n = getUpstreamRelationship(p); if (n>=0) @@ -1222,7 +1222,7 @@ public Map getDependencyChanges(AbstractBuild Map ndep = n.getDependencies(true); Map odep = o.getDependencies(true); - Map r = new HashMap(); + Map r = new HashMap<>(); for (Map.Entry entry : odep.entrySet()) { AbstractProject p = entry.getKey(); @@ -1274,7 +1274,7 @@ public DependencyChange(AbstractProject project, int fromId, int toId) { * of IDs, but due to log rotations, some builds may be already unavailable. */ public List getBuilds() { - List r = new ArrayList(); + List r = new ArrayList<>(); AbstractBuild b = project.getNearestBuild(fromId); if (b!=null && b.getNumber()==fromId) diff --git a/core/src/main/java/hudson/model/Actionable.java b/core/src/main/java/hudson/model/Actionable.java index 96eeda813ab2..496c2de2866c 100644 --- a/core/src/main/java/hudson/model/Actionable.java +++ b/core/src/main/java/hudson/model/Actionable.java @@ -78,7 +78,7 @@ public List getActions() { if (actions == null) { synchronized (this) { if (actions == null) { - actions = new CopyOnWriteArrayList(); + actions = new CopyOnWriteArrayList<>(); } } } @@ -196,7 +196,7 @@ public boolean addOrReplaceAction(@Nonnull Action a) { throw new IllegalArgumentException("Action must be non-null"); } // CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way: - List old = new ArrayList(1); + List old = new ArrayList<>(1); List current = getActions(); boolean found = false; for (Action a2 : current) { @@ -255,7 +255,7 @@ public boolean removeActions(@Nonnull Class clazz) { throw new IllegalArgumentException("Action type must be non-null"); } // CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way: - List old = new ArrayList(); + List old = new ArrayList<>(); List current = getActions(); for (Action a : current) { if (clazz.isInstance(a)) { @@ -290,7 +290,7 @@ public boolean replaceActions(@Nonnull Class clazz, @Nonnull A throw new IllegalArgumentException("Action must be non-null"); } // CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way: - List old = new ArrayList(); + List old = new ArrayList<>(); List current = getActions(); boolean found = false; for (Action a1 : current) { diff --git a/core/src/main/java/hudson/model/AutoCompletionCandidates.java b/core/src/main/java/hudson/model/AutoCompletionCandidates.java index 29ce16f4ca59..e8e64b8e4833 100644 --- a/core/src/main/java/hudson/model/AutoCompletionCandidates.java +++ b/core/src/main/java/hudson/model/AutoCompletionCandidates.java @@ -48,7 +48,7 @@ * @author Kohsuke Kawaguchi */ public class AutoCompletionCandidates implements HttpResponse { - private final List values = new ArrayList(); + private final List values = new ArrayList<>(); public AutoCompletionCandidates add(String v) { values.add(v); diff --git a/core/src/main/java/hudson/model/Build.java b/core/src/main/java/hudson/model/Build.java index 15aed23050bc..00f9c21d4eb4 100644 --- a/core/src/main/java/hudson/model/Build.java +++ b/core/src/main/java/hudson/model/Build.java @@ -147,7 +147,7 @@ protected Result doRun(@Nonnull BuildListener listener) throws Exception { Result r = null; try { - List wrappers = new ArrayList(project.getBuildWrappers().values()); + List wrappers = new ArrayList<>(project.getBuildWrappers().values()); ParametersAction parameters = getAction(ParametersAction.class); if (parameters != null) diff --git a/core/src/main/java/hudson/model/Cause.java b/core/src/main/java/hudson/model/Cause.java index d05cd867b505..4758f17dd06c 100644 --- a/core/src/main/java/hudson/model/Cause.java +++ b/core/src/main/java/hudson/model/Cause.java @@ -175,8 +175,8 @@ public UpstreamCause(Run up) { upstreamBuild = up.getNumber(); upstreamProject = up.getParent().getFullName(); upstreamUrl = up.getParent().getUrl(); - upstreamCauses = new ArrayList(); - Set traversed = new HashSet(); + upstreamCauses = new ArrayList<>(); + Set traversed = new HashSet<>(); for (Cause c : up.getCauses()) { upstreamCauses.add(trim(c, MAX_DEPTH, traversed)); } @@ -234,7 +234,7 @@ public int hashCode() { return c; } UpstreamCause uc = (UpstreamCause) c; - List cs = new ArrayList(); + List cs = new ArrayList<>(); if (depth > 0) { if (traversed.add(uc.upstreamUrl + uc.upstreamBuild)) { for (Cause c2 : uc.upstreamCauses) { @@ -333,7 +333,7 @@ public static class ConverterImpl extends XStream2.PassthruConverter(); + if (uc.upstreamCauses == null) uc.upstreamCauses = new ArrayList<>(); uc.upstreamCauses.add(uc.upstreamCause); uc.upstreamCause = null; OldDataMonitor.report(context, "1.288"); diff --git a/core/src/main/java/hudson/model/ChoiceParameterDefinition.java b/core/src/main/java/hudson/model/ChoiceParameterDefinition.java index 9ea14153624d..ffe11cb3fdab 100644 --- a/core/src/main/java/hudson/model/ChoiceParameterDefinition.java +++ b/core/src/main/java/hudson/model/ChoiceParameterDefinition.java @@ -45,7 +45,7 @@ public ChoiceParameterDefinition(String name, String choices, String description public ChoiceParameterDefinition(String name, String[] choices, String description) { super(name, description); - this.choices = new ArrayList(Arrays.asList(choices)); + this.choices = new ArrayList<>(Arrays.asList(choices)); defaultValue = null; } diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index e4c3a661b84d..9a271550a25a 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -150,9 +150,9 @@ @ExportedBean public /*transient*/ abstract class Computer extends Actionable implements AccessControlled, ExecutorListener, DescriptorByNameOwner { - private final CopyOnWriteArrayList executors = new CopyOnWriteArrayList(); + private final CopyOnWriteArrayList executors = new CopyOnWriteArrayList<>(); // TODO: - private final CopyOnWriteArrayList oneOffExecutors = new CopyOnWriteArrayList(); + private final CopyOnWriteArrayList oneOffExecutors = new CopyOnWriteArrayList<>(); private int numExecutors; @@ -199,7 +199,7 @@ * @see Executor#resetWorkUnit(String) */ private transient final List terminatedBy = Collections.synchronizedList(new ArrayList - ()); + <>()); /** * This method captures the information of a request to terminate a computer instance. Method is public as @@ -241,7 +241,7 @@ public void recordTermination() { * @since 1.607 */ public List getTerminatedBy() { - return new ArrayList(terminatedBy); + return new ArrayList<>(terminatedBy); } public Computer(Node node) { @@ -260,7 +260,7 @@ public List getComputerPanelBoxs(){ */ @SuppressWarnings("deprecation") public List getActions() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.addAll(super.getActions()); synchronized (this) { if (transientActions == null) { @@ -327,7 +327,7 @@ public String getLog() throws IOException { */ public AnnotatedLargeText getLogText() { checkPermission(CONNECT); - return new AnnotatedLargeText(getLogFile(), Charset.defaultCharset(), false, this); + return new AnnotatedLargeText<>(getLogFile(), Charset.defaultCharset(), false, this); } public ACL getACL() { @@ -910,7 +910,7 @@ private void addNewExecutorIfNecessary() { if (Jenkins.getInstanceOrNull() == null) { return; } - Set availableNumbers = new HashSet(); + Set availableNumbers = new HashSet<>(); for (int i = 0; i < numExecutors; i++) availableNumbers.add(i); @@ -965,7 +965,7 @@ public final int countExecutors() { @Exported @StaplerDispatchable public List getExecutors() { - return new ArrayList(executors); + return new ArrayList<>(executors); } /** @@ -974,7 +974,7 @@ public List getExecutors() { @Exported @StaplerDispatchable public List getOneOffExecutors() { - return new ArrayList(oneOffExecutors); + return new ArrayList<>(oneOffExecutors); } /** @@ -998,7 +998,7 @@ public List getAllExecutors() { @Restricted(NoExternalUse.class) public List getDisplayExecutors() { // The size may change while we are populating, but let's start with a reasonable guess to minimize resizing - List result = new ArrayList(executors.size()+oneOffExecutors.size()); + List result = new ArrayList<>(executors.size() + oneOffExecutors.size()); int index = 0; for (Executor e: executors) { if (e.isDisplayCell()) { @@ -1153,7 +1153,7 @@ public String getSearchUrl() { */ @Exported(inline=true) public Map getMonitorData() { - Map r = new HashMap(); + Map r = new HashMap<>(); if (hasPermission(CONNECT)) { for (NodeMonitor monitor : NodeMonitor.getAll()) r.put(monitor.getClass().getName(), monitor.data(this)); @@ -1324,7 +1324,7 @@ private static class ListPossibleNames extends MasterToSlaveCallable call() throws IOException { - List names = new ArrayList(); + List names = new ArrayList<>(); Enumeration nis = NetworkInterface.getNetworkInterfaces(); while (nis.hasMoreElements()) { diff --git a/core/src/main/java/hudson/model/ComputerPanelBox.java b/core/src/main/java/hudson/model/ComputerPanelBox.java index 94ee1aaa3ca9..d5e7e45cba50 100644 --- a/core/src/main/java/hudson/model/ComputerPanelBox.java +++ b/core/src/main/java/hudson/model/ComputerPanelBox.java @@ -37,7 +37,7 @@ public Computer getComputer(){ * List of all the registered {@link ComputerPanelBox}s. */ public static List all(Computer computer) { - List boxs = new ArrayList(); + List boxs = new ArrayList<>(); for(ComputerPanelBox box: ExtensionList.lookup(ComputerPanelBox.class)){ box.setComputer(computer); boxs.add(box); diff --git a/core/src/main/java/hudson/model/ComputerSet.java b/core/src/main/java/hudson/model/ComputerSet.java index 5dbadb921955..1b618d0d508f 100644 --- a/core/src/main/java/hudson/model/ComputerSet.java +++ b/core/src/main/java/hudson/model/ComputerSet.java @@ -85,7 +85,7 @@ public void save() throws IOException { }; private static final DescribableList> monitors - = new DescribableList>(MONITORS_OWNER); + = new DescribableList<>(MONITORS_OWNER); @Exported public String getDisplayName() { @@ -129,7 +129,7 @@ public static DescribableList> getMonitors() * Returns a subset pf {@link #getMonitors()} that are {@linkplain NodeMonitor#isIgnored() not ignored}. */ public static Map,NodeMonitor> getNonIgnoredMonitors() { - Map,NodeMonitor> r = new HashMap, NodeMonitor>(); + Map,NodeMonitor> r = new HashMap<>(); for (NodeMonitor m : monitors) { if(!m.isIgnored()) r.put(m.getDescriptor(),m); @@ -421,7 +421,7 @@ public void doRun() { */ @Nonnull public static List getComputerNames() { - final ArrayList names = new ArrayList(); + final ArrayList names = new ArrayList<>(); for (Computer c : Jenkins.getInstance().getComputers()) { if (!c.getName().isEmpty()) { names.add(c.getName()); @@ -435,14 +435,14 @@ public static List getComputerNames() { static { try { DescribableList> r - = new DescribableList>(Saveable.NOOP); + = new DescribableList<>(Saveable.NOOP); // load persisted monitors XmlFile xf = getConfigFile(); if(xf.exists()) { DescribableList> persisted = (DescribableList>) xf.read(); - List sanitized = new ArrayList(); + List sanitized = new ArrayList<>(); for (NodeMonitor nm : persisted) { try { nm.getDescriptor(); diff --git a/core/src/main/java/hudson/model/DependencyGraph.java b/core/src/main/java/hudson/model/DependencyGraph.java index 6c7469a3021b..bce830b4ee94 100644 --- a/core/src/main/java/hudson/model/DependencyGraph.java +++ b/core/src/main/java/hudson/model/DependencyGraph.java @@ -70,8 +70,8 @@ */ public class DependencyGraph implements Comparator { - private Map> forward = new HashMap>(); - private Map> backward = new HashMap>(); + private Map> forward = new HashMap<>(); + private Map> backward = new HashMap<>(); private transient Map, Object> computationalData; @@ -90,7 +90,7 @@ public void build() { // Set full privileges while computing to avoid missing any projects the current user cannot see. SecurityContext saveCtx = ACL.impersonate(ACL.SYSTEM); try { - this.computationalData = new HashMap, Object>(); + this.computationalData = new HashMap<>(); for( AbstractProject p : Jenkins.getInstance().allItems(AbstractProject.class) ) p.buildDependencyGraph(this); @@ -113,7 +113,7 @@ private void topologicalDagSort() { DirectedGraph g = new DirectedGraph() { @Override protected Collection nodes() { - final Set nodes = new HashSet(); + final Set nodes = new HashSet<>(); nodes.addAll(forward.keySet()); nodes.addAll(backward.keySet()); return nodes; @@ -127,8 +127,8 @@ protected Collection forward(AbstractProject node) { List> sccs = g.getStronglyConnectedComponents(); - final Map topoOrder = new HashMap(); - topologicallySorted = new ArrayList>(); + final Map topoOrder = new HashMap<>(); + topologicallySorted = new ArrayList<>(); int idx=0; for (SCC scc : sccs) { for (AbstractProject n : scc) { @@ -196,7 +196,7 @@ public List getUpstream(AbstractProject p) { private List get(Map> map, AbstractProject src, boolean up) { List v = map.get(src); if(v==null) return Collections.emptyList(); - List result = new ArrayList(v.size()); + List result = new ArrayList<>(v.size()); for (DependencyGroup d : v) result.add(up ? d.getUpstreamProject() : d.getDownstreamProject()); return result; } @@ -284,8 +284,8 @@ public void addDependencyDeclarers(AbstractProject upstream, Collection possi * where the length is greater than 1. */ public boolean hasIndirectDependencies(AbstractProject src, AbstractProject dst) { - Set visited = new HashSet(); - Stack queue = new Stack(); + Set visited = new HashSet<>(); + Stack queue = new Stack<>(); queue.addAll(getDownstream(src)); queue.remove(dst); @@ -316,8 +316,8 @@ public Set getTransitiveDownstream(AbstractProject src) { } private Set getTransitive(Map> direction, AbstractProject src, boolean up) { - Set visited = new HashSet(); - Stack queue = new Stack(); + Set visited = new HashSet<>(); + Stack queue = new Stack<>(); queue.add(src); @@ -336,7 +336,7 @@ private Set getTransitive(Map> map, AbstractProject key, Dependency dep) { List set = map.get(key); if(set==null) { - set = new ArrayList(); + set = new ArrayList<>(); map.put(key,set); } for (DependencyGroup d : set) { @@ -457,7 +457,7 @@ public int hashCode() { * Collect multiple dependencies between the same two projects. */ private static class DependencyGroup { - private Set group = new LinkedHashSet(); + private Set group = new LinkedHashSet<>(); DependencyGroup(Dependency first) { this.upstream = first.getUpstreamProject(); diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 3d941cd0586d..b00b60e4fb56 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -137,7 +137,7 @@ public abstract class Descriptor> implements Saveable, */ public transient final Class clazz; - private transient final Map checkMethods = new ConcurrentHashMap(2); + private transient final Map checkMethods = new ConcurrentHashMap<>(2); /** * Lazily computed list of properties on {@link #clazz} and on the descriptor itself. @@ -233,7 +233,7 @@ public List getApplicableItemDescriptors() { * * @see #getHelpFile(String) */ - private transient final Map helpRedirect = new HashMap(2); + private transient final Map helpRedirect = new HashMap<>(2); private static class HelpRedirect { private final Class owner; @@ -416,7 +416,7 @@ public void calcFillSettings(String field, Map attributes) { throw new IllegalStateException(String.format("%s doesn't have the %s method for filling a drop-down list", getClass(), methodName)); // build query parameter line by figuring out what should be submitted - List depends = buildFillDependencies(method, new ArrayList()); + List depends = buildFillDependencies(method, new ArrayList<>()); if (!depends.isEmpty()) attributes.put("fillDependsOn",Util.join(depends," ")); @@ -506,7 +506,7 @@ public PropertyType getGlobalPropertyType(String field) { * Given the class, list up its {@link PropertyType}s from its public fields/getters. */ private Map buildPropertyTypes(Class clazz) { - Map r = new HashMap(); + Map r = new HashMap<>(); for (Field f : clazz.getFields()) r.put(f.getName(),new PropertyType(f)); @@ -855,7 +855,7 @@ protected final String getViewPage(Class clazz, String pageName) { } protected List getPossibleViewNames(String baseName) { - List names = new ArrayList(); + List names = new ArrayList<>(); for (Facet f : WebApp.get(Jenkins.getInstance().servletContext).facets) { if (f instanceof JellyCompatibleFacet) { JellyCompatibleFacet jcf = (JellyCompatibleFacet) f; @@ -981,12 +981,12 @@ public static T[] toArray( T... values ) { } public static List toList( T... values ) { - return new ArrayList(Arrays.asList(values)); + return new ArrayList<>(Arrays.asList(values)); } public static > Map,T> toMap(Iterable describables) { - Map,T> m = new LinkedHashMap,T>(); + Map,T> m = new LinkedHashMap<>(); for (T d : describables) { Descriptor descriptor; try { @@ -1025,7 +1025,7 @@ List newInstancesFromHeteroList(StaplerRequest req, JSONObject formData, Stri List newInstancesFromHeteroList(StaplerRequest req, Object formData, Collection> descriptors) throws FormException { - List items = new ArrayList(); + List items = new ArrayList<>(); if (formData!=null) { for (Object o : JSONArray.fromObject(formData)) { diff --git a/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java b/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java index e449569500d8..ef099a64dc77 100644 --- a/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java +++ b/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java @@ -65,7 +65,7 @@ public static ExtensionList all() { public static List apply(Object context, Iterable source) { ExtensionList filters = all(); - List r = new ArrayList(); + List r = new ArrayList<>(); Class contextClass = context == null ? null : context.getClass(); if (source == null) { @@ -110,7 +110,7 @@ public static List apply(Object context, Iterable s public static List applyType(Class contextClass, Iterable source) { ExtensionList filters = all(); - List r = new ArrayList(); + List r = new ArrayList<>(); OUTER: for (T d : source) { diff --git a/core/src/main/java/hudson/model/DownloadService.java b/core/src/main/java/hudson/model/DownloadService.java index 125d58a39490..1b0c4088fb83 100644 --- a/core/src/main/java/hudson/model/DownloadService.java +++ b/core/src/main/java/hudson/model/DownloadService.java @@ -309,7 +309,7 @@ public String getUrl() { * URLs to download from. */ public List getUrls() { - List updateSites = new ArrayList(); + List updateSites = new ArrayList<>(); for (UpdateSite site : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) { String siteUrl = site.getUrl(); int baseUrlEnd = siteUrl.indexOf("update-center.json"); diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index 5f90ad1bfcf3..b466779e1ac0 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -139,7 +139,7 @@ public class Executor extends Thread implements ModelObject { * Cause of interruption. Access needs to be synchronized. */ @GuardedBy("lock") - private final List causes = new Vector(); + private final List causes = new Vector<>(); public Executor(@Nonnull Computer owner, int n) { super("Executor #"+n+" for "+owner.getDisplayName()); @@ -271,7 +271,7 @@ public void recordCauseOfInterruption(Run build, TaskListener listener) { lock.writeLock().lock(); try { if (causes.isEmpty()) return; - r = new ArrayList(causes); + r = new ArrayList<>(causes); causes.clear(); } finally { lock.writeLock().unlock(); @@ -961,7 +961,7 @@ public static long getEstimatedDurationFor(Executable e) { * Mechanism to allow threads (in particular the channel request handling threads) to * run on behalf of {@link Executor}. */ - private static final ThreadLocal IMPERSONATION = new ThreadLocal(); + private static final ThreadLocal IMPERSONATION = new ThreadLocal<>(); private static final Logger LOGGER = Logger.getLogger(Executor.class.getName()); } diff --git a/core/src/main/java/hudson/model/Fingerprint.java b/core/src/main/java/hudson/model/Fingerprint.java index cb33903bd190..2a06ca74cf6b 100644 --- a/core/src/main/java/hudson/model/Fingerprint.java +++ b/core/src/main/java/hudson/model/Fingerprint.java @@ -349,7 +349,7 @@ public static final class RangeSet { private final List ranges; public RangeSet() { - this(new ArrayList()); + this(new ArrayList<>()); } private RangeSet(List data) { @@ -417,7 +417,7 @@ protected Iterator expand(Range range) { */ @Exported public synchronized List getRanges() { - return new ArrayList(ranges); + return new ArrayList<>(ranges); } /** @@ -515,7 +515,7 @@ public synchronized void add(RangeSet that) { * @return true if this range set was modified as a result. */ public synchronized boolean retainAll(RangeSet that) { - List intersection = new ArrayList(); + List intersection = new ArrayList<>(); int lhs=0,rhs=0; while(lhs sub = new ArrayList(); + List sub = new ArrayList<>(); int lhs=0,rhs=0; while(lhs usages = new Hashtable(); + private Hashtable usages = new Hashtable<>(); - PersistedList facets = new PersistedList(this); + PersistedList facets = new PersistedList<>(this); /** * Lazily computed immutable {@link FingerprintFacet}s created from {@link TransientFingerprintFacetFactory}. @@ -967,7 +967,7 @@ public RangeSet getRangeSet(Job job) { * Gets the sorted list of job names where this jar is used. */ public @Nonnull List getJobs() { - List r = new ArrayList(); + List r = new ArrayList<>(); r.addAll(usages.keySet()); Collections.sort(r); return r; @@ -993,7 +993,7 @@ public RangeItem(String name, RangeSet ranges) { // this is for remote API @Exported(name="usage") public @Nonnull List _getUsages() { - List r = new ArrayList(); + List r = new ArrayList<>(); final Jenkins instance = Jenkins.getInstance(); for (Entry e : usages.entrySet()) { final String itemName = e.getKey(); @@ -1032,7 +1032,7 @@ public synchronized void add(@Nonnull String jobFullName, int n) throws IOExcept // JENKINS-49588 protected Object readResolve() { if (usages == null) { - usages = new Hashtable(); + usages = new Hashtable<>(); } return this; } @@ -1087,7 +1087,7 @@ public synchronized boolean isAlive() { public synchronized boolean trim() throws IOException { boolean modified = false; - for (Entry e : new Hashtable(usages).entrySet()) {// copy because we mutate + for (Entry e : new Hashtable<>(usages).entrySet()) {// copy because we mutate Job j = Jenkins.getInstance().getItemByFullName(e.getKey(),Job.class); if(j==null) {// no such job any more. recycle the record modified = true; @@ -1158,7 +1158,7 @@ public synchronized boolean trim() throws IOException { */ public @Nonnull Collection getFacets() { if (transientFacets==null) { - List transientFacets = new ArrayList(); + List transientFacets = new ArrayList<>(); for (TransientFingerprintFacetFactory fff : TransientFingerprintFacetFactory.all()) { fff.createFor(this,transientFacets); } @@ -1199,7 +1199,7 @@ public int size() { * @return Sorted list of {@link FingerprintFacet}s */ public @Nonnull Collection getSortedFacets() { - List r = new ArrayList(getFacets()); + List r = new ArrayList<>(getFacets()); Collections.sort(r,new Comparator() { public int compare(FingerprintFacet o1, FingerprintFacet o2) { long a = o1.getTimestamp(); @@ -1230,7 +1230,7 @@ public int compare(FingerprintFacet o1, FingerprintFacet o2) { * Returns the actions contributed from {@link #getFacets()} */ public @Nonnull List getActions() { - List r = new ArrayList(); + List r = new ArrayList<>(); for (FingerprintFacet ff : getFacets()) ff.createActions(r); return Collections.unmodifiableList(r); @@ -1381,7 +1381,7 @@ public Api getApi() { if(logger.isLoggable(Level.FINE)) logger.fine("Loading fingerprint "+file+" took "+(System.currentTimeMillis()-start)+"ms"); if (f.facets==null) - f.facets = new PersistedList(f); + f.facets = new PersistedList<>(f); for (FingerprintFacet facet : f.facets) facet._setOwner(f); return f; @@ -1420,7 +1420,7 @@ private static String messageOfParseException(Throwable t) { } @Override public String toString() { - return "Fingerprint[original=" + original + ",hash=" + getHashString() + ",fileName=" + fileName + ",timestamp=" + DATE_CONVERTER.toString(timestamp) + ",usages=" + ((usages == null) ? "null" : new TreeMap(getUsages())) + ",facets=" + facets + "]"; + return "Fingerprint[original=" + original + ",hash=" + getHashString() + ",fileName=" + fileName + ",timestamp=" + DATE_CONVERTER.toString(timestamp) + ",usages=" + ((usages == null) ? "null" : new TreeMap<>(getUsages())) + ",facets=" + facets + "]"; } /** diff --git a/core/src/main/java/hudson/model/HealthReport.java b/core/src/main/java/hudson/model/HealthReport.java index ddcc1f9deceb..7b675382723c 100644 --- a/core/src/main/java/hudson/model/HealthReport.java +++ b/core/src/main/java/hudson/model/HealthReport.java @@ -62,7 +62,7 @@ public class HealthReport implements Serializable, Comparable { private static final String HEALTH_0_TO_20_IMG = "health-00to19.png"; private static final String HEALTH_UNKNOWN_IMG = "empty.png"; - private static final Map iconIMGToClassMap = new HashMap(); + private static final Map iconIMGToClassMap = new HashMap<>(); static { iconIMGToClassMap.put(HEALTH_OVER_80_IMG, HEALTH_OVER_80); iconIMGToClassMap.put(HEALTH_61_TO_80_IMG, HEALTH_61_TO_80); diff --git a/core/src/main/java/hudson/model/ItemGroupMixIn.java b/core/src/main/java/hudson/model/ItemGroupMixIn.java index 195d4d8c0ce9..3fb988afa358 100644 --- a/core/src/main/java/hudson/model/ItemGroupMixIn.java +++ b/core/src/main/java/hudson/model/ItemGroupMixIn.java @@ -107,7 +107,7 @@ public boolean accept(File child) { return child.isDirectory(); } }); - CopyOnWriteMap.Tree configurations = new CopyOnWriteMap.Tree(); + CopyOnWriteMap.Tree configurations = new CopyOnWriteMap.Tree<>(); for (File subdir : subdirs) { try { // Try to retain the identity of an existing child object if we can. diff --git a/core/src/main/java/hudson/model/Items.java b/core/src/main/java/hudson/model/Items.java index d0a26238a3d3..12fce1434e9f 100644 --- a/core/src/main/java/hudson/model/Items.java +++ b/core/src/main/java/hudson/model/Items.java @@ -69,7 +69,7 @@ public class Items { * Use {@link #all()} for read access and {@link Extension} for registration. */ @Deprecated - public static final List LIST = (List)new DescriptorList(TopLevelItem.class); + public static final List LIST = (List) new DescriptorList<>(TopLevelItem.class); /** * Used to behave differently when loading posted configuration as opposed to persisted configuration. @@ -173,7 +173,7 @@ public static List all(ItemGroup c) { * @since 1.607 */ public static List all(Authentication a, ItemGroup c) { - List result = new ArrayList(); + List result = new ArrayList<>(); ACL acl; if (c instanceof AccessControlled) { acl = ((AccessControlled) c).getACL(); @@ -224,7 +224,7 @@ public static List fromNameList(String list, Class type) public static List fromNameList(ItemGroup context, @Nonnull String list, @Nonnull Class type) { final Jenkins jenkins = Jenkins.getInstance(); - List r = new ArrayList(); + List r = new ArrayList<>(); if (jenkins == null) { return r; } @@ -250,7 +250,7 @@ public static String getCanonicalName(ItemGroup context, String path) { String[] c = context.getFullName().split("/"); String[] p = path.split("/"); - Stack name = new Stack(); + Stack name = new Stack<>(); for (int i=0; i newValue = new ArrayList(); + List newValue = new ArrayList<>(); while(tokens.hasMoreTokens()) { String relativeName = tokens.nextToken().trim(); String canonicalName = getCanonicalName(context, relativeName); @@ -400,12 +400,12 @@ public static XmlFile getConfigFile(Item item) { * @since 1.512 */ public static List getAllItems(final ItemGroup root, Class type) { - List r = new ArrayList(); + List r = new ArrayList<>(); getAllItems(root, type, r); return r; } private static void getAllItems(final ItemGroup root, Class type, List r) { - List items = new ArrayList(((ItemGroup) root).getItems()); + List items = new ArrayList<>(((ItemGroup) root).getItems()); // because we add items depth first, we can use the quicker BY_NAME comparison Collections.sort(items, BY_NAME); for (Item i : items) { diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 047e90a85f44..820c85e8aea3 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -175,7 +175,7 @@ public abstract class Job, RunT extends Run> properties = new CopyOnWriteList>(); + protected CopyOnWriteList> properties = new CopyOnWriteList<>(); @Restricted(NoExternalUse.class) public transient RunIdMigrator runIdMigrator; @@ -232,7 +232,7 @@ public void onLoad(ItemGroup parent, String name) } if (properties == null) // didn't exist < 1.72 - properties = new CopyOnWriteList>(); + properties = new CopyOnWriteList<>(); for (JobProperty p : properties) p.setOwner(this); @@ -595,14 +595,14 @@ public JobProperty getProperty(String className) { * @see JobProperty#getJobOverrides */ public Collection getOverrides() { - List r = new ArrayList(); + List r = new ArrayList<>(); for (JobProperty p : properties) r.addAll(p.getJobOverrides()); return r; } public List getWidgets() { - ArrayList r = new ArrayList(); + ArrayList r = new ArrayList<>(); r.add(createHistoryWidget()); return r; } @@ -741,7 +741,7 @@ public RunList getNewBuilds() { * Obtains all the {@link Run}s whose build numbers matches the given {@link RangeSet}. */ public synchronized List getBuilds(RangeSet rs) { - List builds = new LinkedList(); + List builds = new LinkedList<>(); for (Range r : rs.getRanges()) { for (RunT b = getNearestBuild(r.start); b!=null && b.getNumber() getLastBuildsOverThreshold(int numberOfBuilds, Result threshold) { - List result = new ArrayList(numberOfBuilds); + List result = new ArrayList<>(numberOfBuilds); RunT r = getLastBuild(); while (r != null && result.size() < numberOfBuilds) { @@ -1021,7 +1021,7 @@ public List getLastBuildsOverThreshold(int numberOfBuilds, Result threshol */ @SuppressWarnings("unchecked") protected List getEstimatedDurationCandidates() { - List candidates = new ArrayList(3); + List candidates = new ArrayList<>(3); RunT lastSuccessful = getLastSuccessfulBuild(); int lastSuccessfulNumber = -1; if (lastSuccessful != null) { @@ -1031,7 +1031,7 @@ protected List getEstimatedDurationCandidates() { int i = 0; RunT r = getLastBuild(); - List fallbackCandidates = new ArrayList(3); + List fallbackCandidates = new ArrayList<>(3); while (r != null && candidates.size() < 3 && i < 6) { if (!r.isBuilding() && r.getResult() != null && r.getNumber() != lastSuccessfulNumber) { Result result = r.getResult(); @@ -1103,7 +1103,7 @@ public FeedItem(ChangeLogSet.Entry e, int idx) { } } - List entries = new ArrayList(); + List entries = new ArrayList<>(); String scmDisplayName = ""; if (this instanceof SCMTriggerItem) { SCMTriggerItem scmItem = (SCMTriggerItem) this; @@ -1199,7 +1199,7 @@ public HealthReport getBuildHealth() { @Exported(name = "healthReport") public List getBuildHealthReports() { - List reports = new ArrayList(); + List reports = new ArrayList<>(); RunT lastBuild = getLastBuild(); if (lastBuild != null && lastBuild.isBuilding()) { @@ -1241,7 +1241,7 @@ public List getBuildHealthReports() { // store the cache cachedBuildHealthReportsBuildNumber = lastBuild.getNumber(); - cachedBuildHealthReports = new ArrayList(reports); + cachedBuildHealthReports = new ArrayList<>(reports); } return reports; @@ -1332,7 +1332,7 @@ public synchronized void doConfigSubmit(StaplerRequest req, logRotator = null; - DescribableList, JobPropertyDescriptor> t = new DescribableList, JobPropertyDescriptor>(NOOP,getAllProperties()); + DescribableList, JobPropertyDescriptor> t = new DescribableList<>(NOOP, getAllProperties()); JSONObject jsonProperties = json.optJSONObject("properties"); if (jsonProperties != null) { t.rebuild(req,jsonProperties,JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass())); @@ -1469,7 +1469,7 @@ public String toString() { } - DataSetBuilder data = new DataSetBuilder(); + DataSetBuilder data = new DataSetBuilder<>(); for (Run r : getNewBuilds()) { if (r.isBuilding()) continue; diff --git a/core/src/main/java/hudson/model/JobPropertyDescriptor.java b/core/src/main/java/hudson/model/JobPropertyDescriptor.java index 6955dff091cc..1a90cedf85dd 100644 --- a/core/src/main/java/hudson/model/JobPropertyDescriptor.java +++ b/core/src/main/java/hudson/model/JobPropertyDescriptor.java @@ -99,7 +99,7 @@ public boolean isApplicable(Class jobType) { * Gets the {@link JobPropertyDescriptor}s applicable for a given job type. */ public static List getPropertyDescriptors(Class clazz) { - List r = new ArrayList(); + List r = new ArrayList<>(); for (JobPropertyDescriptor p : all()) if(p.isApplicable(clazz)) r.add(p); diff --git a/core/src/main/java/hudson/model/Label.java b/core/src/main/java/hudson/model/Label.java index 049d0f89fc32..7e9736078db5 100644 --- a/core/src/main/java/hudson/model/Label.java +++ b/core/src/main/java/hudson/model/Label.java @@ -241,7 +241,7 @@ public Set getSortedNodes() { @Exported public Set getClouds() { if(clouds==null) { - Set r = new HashSet(); + Set r = new HashSet<>(); Jenkins h = Jenkins.getInstance(); for (Cloud c : h.clouds) { if(c.canProvision(this)) @@ -381,7 +381,7 @@ private String toString(Collection model) { */ @Exported public List getTiedJobs() { - List r = new ArrayList(); + List r = new ArrayList<>(); for (AbstractProject p : Jenkins.getInstance().allItems(AbstractProject.class)) { if(p instanceof TopLevelItem && this.equals(p.getAssignedLabel())) r.add(p); @@ -417,7 +417,7 @@ public int getTiedJobCount() { } } if (topLevelItem instanceof ItemGroup) { - Stack q = new Stack(); + Stack q = new Stack<>(); q.push((ItemGroup) topLevelItem); while (!q.isEmpty()) { @@ -480,7 +480,7 @@ public Api getApi() { * @since 1.420 */ public Set listAtoms() { - Set r = new HashSet(); + Set r = new HashSet<>(); accept(ATOM_COLLECTOR,r); return r; } diff --git a/core/src/main/java/hudson/model/ListView.java b/core/src/main/java/hudson/model/ListView.java index 9d84eb32cebb..96d8ce1f9eb5 100644 --- a/core/src/main/java/hudson/model/ListView.java +++ b/core/src/main/java/hudson/model/ListView.java @@ -77,7 +77,7 @@ public class ListView extends View implements DirectlyModifiableView { * List of job names. This is what gets serialized. */ @GuardedBy("this") - /*package*/ /*almost-final*/ SortedSet jobNames = new TreeSet(CaseInsensitiveComparator.INSTANCE); + /*package*/ /*almost-final*/ SortedSet jobNames = new TreeSet<>(CaseInsensitiveComparator.INSTANCE); private DescribableList> jobFilters; @@ -135,7 +135,7 @@ private Object readResolve() { } synchronized(this) { if (jobNames == null) { - jobNames = new TreeSet(CaseInsensitiveComparator.INSTANCE); + jobNames = new TreeSet<>(CaseInsensitiveComparator.INSTANCE); } } initColumns(); @@ -145,14 +145,14 @@ private Object readResolve() { protected void initColumns() { if (columns == null) - columns = new DescribableList>(this, + columns = new DescribableList<>(this, ListViewColumn.createDefaultInitialColumnList(getClass()) ); } protected void initJobFilters() { if (jobFilters == null) - jobFilters = new DescribableList>(this); + jobFilters = new DescribableList<>(this); } /** @@ -196,14 +196,14 @@ public List getItems() { */ private List getItems(boolean recurse) { SortedSet names; - List items = new ArrayList(); + List items = new ArrayList<>(); synchronized (this) { - names = new TreeSet(jobNames); + names = new TreeSet<>(jobNames); } ItemGroup parent = getOwner().getItemGroup(); - List parentItems = new ArrayList(parent.getItems()); + List parentItems = new ArrayList<>(parent.getItems()); includeItems(parent, parentItems, names); Boolean statusFilter = this.statusFilter; // capture the value to isolate us from concurrent update @@ -223,13 +223,13 @@ private List getItems(boolean recurse) { // check the filters Iterable jobFilters = getJobFilters(); - List allItems = new ArrayList(parentItems); - if (recurse) allItems = expand(allItems, new ArrayList()); + List allItems = new ArrayList<>(parentItems); + if (recurse) allItems = expand(allItems, new ArrayList<>()); for (ViewJobFilter jobFilter: jobFilters) { items = jobFilter.filter(items, allItems, this); } // for sanity, trim off duplicates - items = new ArrayList(new LinkedHashSet(items)); + items = new ArrayList<>(new LinkedHashSet<>(items)); return items; } @@ -459,12 +459,12 @@ protected void submit(StaplerRequest req) throws ServletException, FormException setIncludeRegex(req.getParameter("useincluderegex") != null ? req.getParameter("includeRegex") : null); if (columns == null) { - columns = new DescribableList>(this); + columns = new DescribableList<>(this); } columns.rebuildHetero(req, json, ListViewColumn.all(), "columns"); if (jobFilters == null) { - jobFilters = new DescribableList>(this); + jobFilters = new DescribableList<>(this); } jobFilters.rebuildHetero(req, json, ViewJobFilter.all(), "jobFilters"); @@ -545,7 +545,7 @@ private void locationChanged(ViewGroup vg, String oldFullName, String newFullNam private void renameViewItem(String oldFullName, String newFullName, ViewGroup vg, ListView lv) { boolean needsSave; synchronized (lv) { - Set oldJobNames = new HashSet(lv.jobNames); + Set oldJobNames = new HashSet<>(lv.jobNames); lv.jobNames.clear(); for (String oldName : oldJobNames) { lv.jobNames.add(Items.computeRelativeNamesAfterRenaming(oldFullName, newFullName, oldName, vg.getItemGroup())); diff --git a/core/src/main/java/hudson/model/LoadBalancer.java b/core/src/main/java/hudson/model/LoadBalancer.java index ce69e8977930..fca13b938c47 100644 --- a/core/src/main/java/hudson/model/LoadBalancer.java +++ b/core/src/main/java/hudson/model/LoadBalancer.java @@ -79,9 +79,9 @@ public abstract class LoadBalancer implements ExtensionPoint { @Override public Mapping map(Task task, MappingWorksheet ws) { // build consistent hash for each work chunk - List> hashes = new ArrayList>(ws.works.size()); + List> hashes = new ArrayList<>(ws.works.size()); for (int i=0; i hash = new ConsistentHash(new Hash() { + ConsistentHash hash = new ConsistentHash<>(new Hash() { public String hash(ExecutorChunk node) { return node.getName(); } diff --git a/core/src/main/java/hudson/model/MultiStageTimeSeries.java b/core/src/main/java/hudson/model/MultiStageTimeSeries.java index 62867f2e26a0..a6b226fa7119 100644 --- a/core/src/main/java/hudson/model/MultiStageTimeSeries.java +++ b/core/src/main/java/hudson/model/MultiStageTimeSeries.java @@ -201,7 +201,7 @@ public static class TrendChart implements HttpResponse { public TrendChart(TimeScale timeScale, MultiStageTimeSeries... series) { this.timeScale = timeScale; - this.series = new ArrayList(Arrays.asList(series)); + this.series = new ArrayList<>(Arrays.asList(series)); this.dataset = createDataset(); } diff --git a/core/src/main/java/hudson/model/MyView.java b/core/src/main/java/hudson/model/MyView.java index d24ad9785233..3dcc8e397a39 100644 --- a/core/src/main/java/hudson/model/MyView.java +++ b/core/src/main/java/hudson/model/MyView.java @@ -75,7 +75,7 @@ public TopLevelItem doCreateItem(StaplerRequest req, StaplerResponse rsp) @Override public Collection getItems() { - List items = new ArrayList(); + List items = new ArrayList<>(); for (TopLevelItem item : getOwner().getItemGroup().getItems()) { if (item.hasPermission(Item.CONFIGURE)) { items.add(item); diff --git a/core/src/main/java/hudson/model/MyViewsProperty.java b/core/src/main/java/hudson/model/MyViewsProperty.java index b4b246e2cae7..4ebb4fdc226b 100644 --- a/core/src/main/java/hudson/model/MyViewsProperty.java +++ b/core/src/main/java/hudson/model/MyViewsProperty.java @@ -73,7 +73,7 @@ public class MyViewsProperty extends UserProperty implements ModifiableViewGroup /** * Always hold at least one view. */ - private CopyOnWriteArrayList views = new CopyOnWriteArrayList(); + private CopyOnWriteArrayList views = new CopyOnWriteArrayList<>(); private transient ViewGroupMixIn viewGroupMixIn; @@ -91,7 +91,7 @@ private MyViewsProperty() { public Object readResolve() { if (views == null) // this shouldn't happen, but an error in 1.319 meant the last view could be deleted - views = new CopyOnWriteArrayList(); + views = new CopyOnWriteArrayList<>(); if (views.isEmpty()) { // preserve the non-empty invariant diff --git a/core/src/main/java/hudson/model/PageDecorator.java b/core/src/main/java/hudson/model/PageDecorator.java index 6f42942ace25..a9a5f174fdfc 100644 --- a/core/src/main/java/hudson/model/PageDecorator.java +++ b/core/src/main/java/hudson/model/PageDecorator.java @@ -108,7 +108,7 @@ public final String getUrl() { * Use {@link #all()} for read access, and use {@link Extension} for registration. */ @Deprecated - public static final List ALL = (List)new DescriptorList(PageDecorator.class); + public static final List ALL = (List) new DescriptorList<>(PageDecorator.class); /** * Returns all the registered {@link PageDecorator} descriptors. diff --git a/core/src/main/java/hudson/model/PaneStatusProperties.java b/core/src/main/java/hudson/model/PaneStatusProperties.java index 279f72fa64c7..0cd6e0aeeeed 100644 --- a/core/src/main/java/hudson/model/PaneStatusProperties.java +++ b/core/src/main/java/hudson/model/PaneStatusProperties.java @@ -13,7 +13,7 @@ public class PaneStatusProperties extends UserProperty implements Saveable { - private final PersistedList collapsed = new PersistedList(this); + private final PersistedList collapsed = new PersistedList<>(this); private static final PaneStatusProperties FALLBACK = new PaneStatusPropertiesSessionFallback(); diff --git a/core/src/main/java/hudson/model/ParameterDefinition.java b/core/src/main/java/hudson/model/ParameterDefinition.java index d535a90a0514..57fdf5346845 100644 --- a/core/src/main/java/hudson/model/ParameterDefinition.java +++ b/core/src/main/java/hudson/model/ParameterDefinition.java @@ -232,7 +232,7 @@ public static DescriptorExtensionList a * Use {@link #all()} for read access, and {@link Extension} for registration. */ @Deprecated - public static final DescriptorList LIST = new DescriptorList(ParameterDefinition.class); + public static final DescriptorList LIST = new DescriptorList<>(ParameterDefinition.class); public abstract static class ParameterDescriptor extends Descriptor { diff --git a/core/src/main/java/hudson/model/ParametersAction.java b/core/src/main/java/hudson/model/ParametersAction.java index ccf6f4eb908b..6e2ef3468616 100644 --- a/core/src/main/java/hudson/model/ParametersAction.java +++ b/core/src/main/java/hudson/model/ParametersAction.java @@ -222,11 +222,11 @@ public boolean shouldSchedule(List actions) { return !parameters.isEmpty(); } else { // I don't think we need multiple ParametersActions, but let's be defensive - Set params = new HashSet(); + Set params = new HashSet<>(); for (ParametersAction other: others) { params.addAll(other.parameters); } - return !params.equals(new HashSet(this.parameters)); + return !params.equals(new HashSet<>(this.parameters)); } } @@ -324,7 +324,7 @@ private List filter(List parameters) { return parameters; } - List filteredParameters = new ArrayList(); + List filteredParameters = new ArrayList<>(); for (ParameterValue v : this.parameters) { if (this.parameterDefinitionNames.contains(v.getName()) || isSafeParameter(v.getName())) { diff --git a/core/src/main/java/hudson/model/ParametersDefinitionProperty.java b/core/src/main/java/hudson/model/ParametersDefinitionProperty.java index 1fa26ed3720a..815070e093c2 100644 --- a/core/src/main/java/hudson/model/ParametersDefinitionProperty.java +++ b/core/src/main/java/hudson/model/ParametersDefinitionProperty.java @@ -138,7 +138,7 @@ public void _doBuild(StaplerRequest req, StaplerResponse rsp, @QueryParameter Ti delay=new TimeDuration(TimeUnit.MILLISECONDS.convert(getJob().getQuietPeriod(), TimeUnit.SECONDS)); - List values = new ArrayList(); + List values = new ArrayList<>(); JSONObject formData = req.getSubmittedForm(); JSONArray a = JSONArray.fromObject(formData.get("parameter")); @@ -177,7 +177,7 @@ public void buildWithParameters(StaplerRequest req, StaplerResponse rsp) throws } public void buildWithParameters(StaplerRequest req, StaplerResponse rsp, @CheckForNull TimeDuration delay) throws IOException, ServletException { - List values = new ArrayList(); + List values = new ArrayList<>(); for (ParameterDefinition d: parameterDefinitions) { ParameterValue value = d.createValue(req); if (value != null) { diff --git a/core/src/main/java/hudson/model/PermalinkProjectAction.java b/core/src/main/java/hudson/model/PermalinkProjectAction.java index 22c949e7d4c3..7909040f654d 100644 --- a/core/src/main/java/hudson/model/PermalinkProjectAction.java +++ b/core/src/main/java/hudson/model/PermalinkProjectAction.java @@ -91,7 +91,7 @@ abstract class Permalink { /** * List of {@link Permalink}s that are built into Jenkins. */ - public static final List BUILTIN = new CopyOnWriteArrayList(); + public static final List BUILTIN = new CopyOnWriteArrayList<>(); public static final Permalink LAST_BUILD = new Permalink() { public String getDisplayName() { diff --git a/core/src/main/java/hudson/model/Project.java b/core/src/main/java/hudson/model/Project.java index b969b9942c03..ff1119b5e234 100644 --- a/core/src/main/java/hudson/model/Project.java +++ b/core/src/main/java/hudson/model/Project.java @@ -157,7 +157,7 @@ public DescribableList> getBuildWrappersL @Override protected Set getResourceActivities() { - final Set activities = new HashSet(); + final Set activities = new HashSet<>(); activities.addAll(super.getResourceActivities()); activities.addAll(Util.filter(getBuildersList(),ResourceActivity.class)); diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index b2c4f7135a9d..8c3233059931 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -184,7 +184,7 @@ public class Queue extends ResourceController implements Saveable { * This consists of {@link Item}s that cannot be run yet * because its time has not yet come. */ - private final Set waitingList = new TreeSet(); + private final Set waitingList = new TreeSet<>(); /** * {@link Task}s that can be built immediately @@ -193,20 +193,20 @@ public class Queue extends ResourceController implements Saveable { * blocked via {@link QueueTaskDispatcher#canRun(Item)}, * or otherwise blocked by {@link Task#isBuildBlocked()}. */ - private final ItemList blockedProjects = new ItemList(); + private final ItemList blockedProjects = new ItemList<>(); /** * {@link Task}s that can be built immediately * that are waiting for available {@link Executor}. * This list is sorted in such a way that earlier items are built earlier. */ - private final ItemList buildables = new ItemList(); + private final ItemList buildables = new ItemList<>(); /** * {@link Task}s that are being handed over to the executor, but execution * has not started yet. */ - private final ItemList pendings = new ItemList(); + private final ItemList pendings = new ItemList<>(); private transient volatile Snapshot snapshot = new Snapshot(waitingList, blockedProjects, buildables, pendings); @@ -319,7 +319,7 @@ public String toString() { private volatile transient QueueSorter sorter; - private transient final AtmostOneTaskExecutor maintainerThread = new AtmostOneTaskExecutor(new Callable() { + private transient final AtmostOneTaskExecutor maintainerThread = new AtmostOneTaskExecutor<>(new Callable() { @Override public Void call() throws Exception { maintain(); @@ -365,7 +365,7 @@ public void setSorter(QueueSorter sorter) { */ static class State { public long counter; - public List items = new ArrayList(); + public List items = new ArrayList<>(); } /** @@ -495,7 +495,7 @@ public void clear() { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); lock.lock(); try { try { - for (WaitingItem i : new ArrayList( + for (WaitingItem i : new ArrayList<>( waitingList)) // copy the list as we'll modify it in the loop i.cancel(this); blockedProjects.cancelAll(); @@ -579,7 +579,7 @@ public WaitingItem schedule(Task p, int quietPeriod, List actions) { */ public @Nonnull ScheduleResult schedule2(Task p, int quietPeriod, List actions) { // remove nulls - actions = new ArrayList(actions); + actions = new ArrayList<>(actions); for (Iterator itr = actions.iterator(); itr.hasNext();) { Action a = itr.next(); if (a==null) itr.remove(); @@ -617,14 +617,14 @@ public WaitingItem schedule(Task p, int quietPeriod, List actions) { due.add(Calendar.SECOND, quietPeriod); // Do we already have this task in the queue? Because if so, we won't schedule a new one. - List duplicatesInQueue = new ArrayList(); + List duplicatesInQueue = new ArrayList<>(); for (Item item : liveGetItems(p)) { boolean shouldScheduleItem = false; for (QueueAction action : item.getActions(QueueAction.class)) { shouldScheduleItem |= action.shouldSchedule(actions); } for (QueueAction action : Util.filter(actions, QueueAction.class)) { - shouldScheduleItem |= action.shouldSchedule((new ArrayList(item.getAllActions()))); + shouldScheduleItem |= action.shouldSchedule((new ArrayList<>(item.getAllActions()))); } if (!shouldScheduleItem) { duplicatesInQueue.add(item); @@ -787,7 +787,7 @@ private WaitingItem peek() { @Exported(inline=true) public Item[] getItems() { Snapshot s = this.snapshot; - List r = new ArrayList(); + List r = new ArrayList<>(); for(WaitingItem p : s.waitingList) { r = checkPermissionsAndAddToList(r, p); @@ -826,7 +826,7 @@ private List checkPermissionsAndAddToList(List r, Item t) { @Exported(inline=true) public StubItem[] getDiscoverableItems() { Snapshot s = this.snapshot; - List r = new ArrayList(); + List r = new ArrayList<>(); for(WaitingItem p : s.waitingList) { r = filterDiscoverableItemListBasedOnPermissions(r, p); @@ -904,7 +904,7 @@ public Item getItem(long id) { */ public List getBuildableItems(Computer c) { Snapshot snapshot = this.snapshot; - List result = new ArrayList(); + List result = new ArrayList<>(); _getBuildableItems(c, snapshot.buildables, result); _getBuildableItems(c, snapshot.pendings, result); return result; @@ -925,7 +925,7 @@ private void _getBuildableItems(Computer c, List col, List getBuildableItems() { Snapshot snapshot = this.snapshot; - ArrayList r = new ArrayList(snapshot.buildables); + ArrayList r = new ArrayList<>(snapshot.buildables); r.addAll(snapshot.pendings); return r; } @@ -934,14 +934,14 @@ public List getBuildableItems() { * Gets the snapshot of all {@link BuildableItem}s. */ public List getPendingItems() { - return new ArrayList(snapshot.pendings); + return new ArrayList<>(snapshot.pendings); } /** * Gets the snapshot of all {@link BlockedItem}s. */ protected List getBlockedItems() { - return new ArrayList(snapshot.blockedProjects); + return new ArrayList<>(snapshot.blockedProjects); } /** @@ -969,7 +969,7 @@ public void clearLeftItems() { */ public List getUnblockedItems() { Snapshot snapshot = this.snapshot; - List queuedNotBlocked = new ArrayList(); + List queuedNotBlocked = new ArrayList<>(); queuedNotBlocked.addAll(snapshot.waitingList); queuedNotBlocked.addAll(snapshot.buildables); queuedNotBlocked.addAll(snapshot.pendings); @@ -984,7 +984,7 @@ public List getUnblockedItems() { */ public Set getUnblockedTasks() { List items = getUnblockedItems(); - Set unblockedTasks = new HashSet(items.size()); + Set unblockedTasks = new HashSet<>(items.size()); for (Queue.Item t : items) unblockedTasks.add(t.task); return unblockedTasks; @@ -1089,7 +1089,7 @@ public Item getItem(Task t) { private List liveGetItems(Task t) { lock.lock(); try { - List result = new ArrayList(); + List result = new ArrayList<>(); result.addAll(blockedProjects.getAll(t)); result.addAll(buildables.getAll(t)); // Do not include pendings—we have already finalized WorkUnitContext.actions. @@ -1117,7 +1117,7 @@ private List liveGetItems(Task t) { */ public List getItems(Task t) { Snapshot snapshot = this.snapshot; - List result = new ArrayList(); + List result = new ArrayList<>(); for (Item item : snapshot.blockedProjects) { if (item.task.equals(t)) { result.add(item); @@ -1356,7 +1356,7 @@ public static java.util.concurrent.Callable wrapWithLock(java.util.concur final Jenkins jenkins = Jenkins.getInstanceOrNull(); // TODO confirm safe to assume non-null and use getInstance() final Queue queue = jenkins == null ? null : jenkins.getQueue(); - return queue == null ? callable : new LockedJUCCallable(callable); + return queue == null ? callable : new LockedJUCCallable<>(callable); } @Override @@ -1466,10 +1466,10 @@ public void maintain() { LOGGER.log(Level.FINE, "Queue maintenance started on {0} with {1}", new Object[] {this, snapshot}); // The executors that are currently waiting for a job to run. - Map parked = new HashMap(); + Map parked = new HashMap<>(); {// update parked (and identify any pending items whose executor has disappeared) - List lostPendings = new ArrayList(pendings); + List lostPendings = new ArrayList<>(pendings); for (Computer c : jenkins.getComputers()) { for (Executor e : c.getAllExecutors()) { if (e.isInterrupted()) { @@ -1584,7 +1584,7 @@ public void maintain() { updateSnapshot(); // allocate buildable jobs to executors - for (BuildableItem p : new ArrayList( + for (BuildableItem p : new ArrayList<>( buildables)) {// copy as we'll mutate the list in the loop // one last check to make sure this build is not blocked. CauseOfBlockage causeOfBlockage = getCauseOfBlockageForItem(p); @@ -1721,7 +1721,7 @@ private Runnable makeFlyWeightTaskBuildable(final BuildableItem p){ } } - Map hashSource = new HashMap(h.getNodes().size()); + Map hashSource = new HashMap<>(h.getNodes().size()); // Even if master is configured with zero executors, we may need to run a flyweight task like MatrixProject on it. hashSource.put(h, Math.max(h.getNumExecutors() * 100, 1)); @@ -1730,7 +1730,7 @@ private Runnable makeFlyWeightTaskBuildable(final BuildableItem p){ hashSource.put(n, n.getNumExecutors() * 100); } - ConsistentHash hash = new ConsistentHash(NODE_HASH); + ConsistentHash hash = new ConsistentHash<>(NODE_HASH); hash.addAll(hashSource); String fullDisplayName = p.task.getFullDisplayName(); @@ -2222,7 +2222,7 @@ protected Item(Task task, List actions, long id, FutureImpl future, long @SuppressWarnings("deprecation") // JENKINS-51584 protected Item(Item item) { // do not use item.getAllActions() here as this will persist actions from a TransientActionFactory - this(item.task, new ArrayList(item.getActions()), item.id, item.future, item.inQueueSince); + this(item.task, new ArrayList<>(item.getActions()), item.id, item.future, item.inQueueSince); } /** diff --git a/core/src/main/java/hudson/model/ResourceController.java b/core/src/main/java/hudson/model/ResourceController.java index 852a72f3669d..9d1a82c85209 100644 --- a/core/src/main/java/hudson/model/ResourceController.java +++ b/core/src/main/java/hudson/model/ResourceController.java @@ -42,7 +42,7 @@ public class ResourceController { /** * {@link ResourceList}s that are used by activities that are in progress. */ - private final Set inProgress = new CopyOnWriteArraySet(); + private final Set inProgress = new CopyOnWriteArraySet<>(); /** * View of {@link #inProgress} that exposes its {@link ResourceList}. diff --git a/core/src/main/java/hudson/model/ResourceList.java b/core/src/main/java/hudson/model/ResourceList.java index 0a5217088e76..d3fdb9302ec2 100644 --- a/core/src/main/java/hudson/model/ResourceList.java +++ b/core/src/main/java/hudson/model/ResourceList.java @@ -52,7 +52,7 @@ public final class ResourceList { /** * All resources (R/W.) */ - private final Set all = new HashSet(); + private final Set all = new HashSet<>(); /** * Write accesses. Values are the # of write counts that this list uses. @@ -60,7 +60,7 @@ public final class ResourceList { * The values are mostly supposed to be 1, but when {@link ResourceController} * uses a list to keep track of the union of all the activities, it can get larger. */ - private final Map write = new HashMap(); + private final Map write = new HashMap<>(); private static final Integer MAX_INT = Integer.MAX_VALUE; /** @@ -143,7 +143,7 @@ private Resource _getConflict(ResourceList lhs, ResourceList rhs) { @Override public String toString() { - Map m = new HashMap(); + Map m = new HashMap<>(); for (Resource r : all) m.put(r,"R"); for (Entry e : write.entrySet()) diff --git a/core/src/main/java/hudson/model/Result.java b/core/src/main/java/hudson/model/Result.java index 8b1d05fc4b0f..ea912c856d69 100644 --- a/core/src/main/java/hudson/model/Result.java +++ b/core/src/main/java/hudson/model/Result.java @@ -155,7 +155,7 @@ public boolean isCompleteBuild() { } private static @Nonnull List getNames() { - List l = new ArrayList(); + List l = new ArrayList<>(); for (Result r : all) l.add(r.name); return l; diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 8565876d292e..9ff9cdfb41a7 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -381,7 +381,7 @@ protected void onLoad() { */ @Deprecated public List getTransientActions() { - List actions = new ArrayList(); + List actions = new ArrayList<>(); for (TransientBuildActionFactory factory: TransientBuildActionFactory.all()) { for (Action created : factory.createFor(this)) { if (created == null) { @@ -821,7 +821,7 @@ public int getNumber() { * @since 1.556 */ protected @Nonnull BuildReference createReference() { - return new BuildReference(getId(), _this()); + return new BuildReference<>(getId(), _this()); } /** @@ -865,7 +865,7 @@ protected void dropLinks() { public final @CheckForNull RunT getPreviousBuildInProgress() { if(previousBuildInProgress==this) return null; // the most common case - List fixUp = new ArrayList(); + List fixUp = new ArrayList<>(); RunT r = _this(); // 'r' is the source of the pointer (so that we can add it to fix up if we find that the target of the pointer is inefficient.) RunT answer; while (true) { @@ -948,7 +948,7 @@ protected void dropLinks() { * @since 1.383 */ public @Nonnull List getPreviousBuildsOverThreshold(int numberOfBuilds, @Nonnull Result threshold) { - List builds = new ArrayList(numberOfBuilds); + List builds = new ArrayList<>(numberOfBuilds); RunT r = getPreviousBuild(); while (r != null && builds.size() < numberOfBuilds) { @@ -1216,7 +1216,7 @@ public final class ArtifactList extends ArrayList { * Map of Artifact to treeNodeId of parent node in tree view. * Contains Artifact objects for directories and files (the ArrayList contains only files). */ - private LinkedHashMap tree = new LinkedHashMap(); + private LinkedHashMap tree = new LinkedHashMap<>(); void updateFrom(SerializableArtifactList clone) { Map artifacts = new HashMap<>(); // need to share objects between tree and list, since computeDisplayName mutates displayPath @@ -1256,7 +1256,7 @@ public void computeDisplayName() { int depth=0; do { collision = false; - Map names = new HashMap(); + Map names = new HashMap<>(); for (int i = 0; i < tokens.length; i++) { String[] token = tokens[i]; String displayName = combineLast(token,len[i]); @@ -1658,7 +1658,7 @@ private final class CheckpointSet { * Stages of the builds that this runner has completed. This is used for concurrent {@link RunExecution}s to * coordinate and serialize their executions where necessary. */ - private final Set checkpoints = new HashSet(); + private final Set checkpoints = new HashSet<>(); private boolean allDone; @@ -1697,7 +1697,7 @@ private synchronized void allDone() { private final CheckpointSet checkpoints = new CheckpointSet(); - private final Map attributes = new HashMap(); + private final Map attributes = new HashMap<>(); /** * Performs the main build and returns the status code. diff --git a/core/src/main/java/hudson/model/RunnerStack.java b/core/src/main/java/hudson/model/RunnerStack.java index 2cade6d5efb6..ae12e70294b7 100644 --- a/core/src/main/java/hudson/model/RunnerStack.java +++ b/core/src/main/java/hudson/model/RunnerStack.java @@ -38,12 +38,12 @@ * @since 1.319 */ final class RunnerStack { - private final Map> stack = new WeakHashMap>(); + private final Map> stack = new WeakHashMap<>(); synchronized void push(RunExecution r) { Executor e = Executor.currentExecutor(); Stack s = stack.get(e); - if(s==null) stack.put(e,s=new Stack()); + if(s==null) stack.put(e,s= new Stack<>()); s.push(r); } diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java index c3cad4eea739..c9514a34d757 100644 --- a/core/src/main/java/hudson/model/Slave.java +++ b/core/src/main/java/hudson/model/Slave.java @@ -636,7 +636,7 @@ public final List>> retentionStrategyDescriptors @SuppressWarnings("unchecked") // used by Jelly EL only @Restricted(NoExternalUse.class) // used by Jelly EL only public final List nodePropertyDescriptors(@CheckForNull Slave it) { - List result = new ArrayList(); + List result = new ArrayList<>(); Collection list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class); for (NodePropertyDescriptor npd : it == null diff --git a/core/src/main/java/hudson/model/TaskThread.java b/core/src/main/java/hudson/model/TaskThread.java index 73623e7b0d04..9fb5ba25e9dc 100644 --- a/core/src/main/java/hudson/model/TaskThread.java +++ b/core/src/main/java/hudson/model/TaskThread.java @@ -97,7 +97,7 @@ public Reader readAll() throws IOException { */ protected final void associateWith(TaskAction action) { action.workerThread = this; - action.log = new WeakReference(log); + action.log = new WeakReference<>(log); } /** @@ -188,7 +188,7 @@ public static ListenerAndText forMemory(TaskAction context) { return new ListenerAndText( new StreamTaskListener(log), - new AnnotatedLargeText(log,Charset.defaultCharset(),false,context) + new AnnotatedLargeText<>(log, Charset.defaultCharset(), false, context) ); } @@ -198,7 +198,7 @@ public static ListenerAndText forMemory(TaskAction context) { public static ListenerAndText forFile(File f, TaskAction context) throws IOException { return new ListenerAndText( new StreamTaskListener(f), - new AnnotatedLargeText(f,Charset.defaultCharset(),false,context) + new AnnotatedLargeText<>(f, Charset.defaultCharset(), false, context) ); } } diff --git a/core/src/main/java/hudson/model/TransientComputerActionFactory.java b/core/src/main/java/hudson/model/TransientComputerActionFactory.java index 3a77db8c5260..1506da71352c 100644 --- a/core/src/main/java/hudson/model/TransientComputerActionFactory.java +++ b/core/src/main/java/hudson/model/TransientComputerActionFactory.java @@ -64,7 +64,7 @@ public static ExtensionList all() { * Creates {@link Action}s for a node, using all registered {@link TransientComputerActionFactory}s. */ public static List createAllFor(Computer target) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (TransientComputerActionFactory f: all()) { result.addAll(f.createFor(target)); } diff --git a/core/src/main/java/hudson/model/TransientViewActionFactory.java b/core/src/main/java/hudson/model/TransientViewActionFactory.java index edf9a1c85afc..d5fa9dcfc2f5 100644 --- a/core/src/main/java/hudson/model/TransientViewActionFactory.java +++ b/core/src/main/java/hudson/model/TransientViewActionFactory.java @@ -31,7 +31,7 @@ public static ExtensionList all() { * Creates {@link Action}s for a view, using all registered {@link TransientViewActionFactory}s. */ public static List createAllFor(View v) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (TransientViewActionFactory f: all()) { result.addAll(f.createFor(v)); } diff --git a/core/src/main/java/hudson/model/TreeView.java b/core/src/main/java/hudson/model/TreeView.java index d70c2d4744d6..d4229acbf882 100644 --- a/core/src/main/java/hudson/model/TreeView.java +++ b/core/src/main/java/hudson/model/TreeView.java @@ -62,12 +62,12 @@ public class TreeView extends View implements ViewGroup { * List of job names. This is what gets serialized. */ private final Set jobNames - = new TreeSet(CaseInsensitiveComparator.INSTANCE); + = new TreeSet<>(CaseInsensitiveComparator.INSTANCE); /** * Nested views. */ - private final CopyOnWriteArrayList views = new CopyOnWriteArrayList(); + private final CopyOnWriteArrayList views = new CopyOnWriteArrayList<>(); @DataBoundConstructor public TreeView(String name) { diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index 0185e4f854d4..2b1cdd4c943b 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -189,18 +189,18 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas /** * List of created {@link UpdateCenterJob}s. Access needs to be synchronized. */ - private final Vector jobs = new Vector(); + private final Vector jobs = new Vector<>(); /** * {@link UpdateSite}s from which we've already installed a plugin at least once. * This is used to skip network tests. */ - private final Set sourcesUsed = new HashSet(); + private final Set sourcesUsed = new HashSet<>(); /** * List of {@link UpdateSite}s to be used. */ - private final PersistedList sites = new PersistedList(this); + private final PersistedList sites = new PersistedList<>(this); /** * Update center configuration data @@ -338,7 +338,7 @@ public void configure(UpdateCenterConfiguration config) { @StaplerDispatchable public List getJobs() { synchronized (jobs) { - return new ArrayList(jobs); + return new ArrayList<>(jobs); } } @@ -918,7 +918,7 @@ private XmlFile getConfigFile() { @Exported public List getAvailables() { - Map pluginMap = new LinkedHashMap(); + Map pluginMap = new LinkedHashMap<>(); for (UpdateSite site : sites) { for (Plugin plugin: site.getAvailables()) { final Plugin existing = pluginMap.get(plugin.name); @@ -935,7 +935,7 @@ public List getAvailables() { } } - return new ArrayList(pluginMap.values()); + return new ArrayList<>(pluginMap.values()); } /** @@ -943,7 +943,7 @@ public List getAvailables() { * A plugin with multiple categories will appear multiple times in the list. */ public PluginEntry[] getCategorizedAvailables() { - TreeSet entries = new TreeSet(); + TreeSet entries = new TreeSet<>(); for (Plugin p : getAvailables()) { if (p.categories==null || p.categories.length==0) entries.add(new PluginEntry(p, getCategoryDisplayName(null))); @@ -966,7 +966,7 @@ private static String getCategoryDisplayName(String category) { } public List getUpdates() { - Map pluginMap = new LinkedHashMap(); + Map pluginMap = new LinkedHashMap<>(); for (UpdateSite site : sites) { for (Plugin plugin: site.getUpdates()) { final Plugin existing = pluginMap.get(plugin.name); @@ -983,7 +983,7 @@ public List getUpdates() { } } - return new ArrayList(pluginMap.values()); + return new ArrayList<>(pluginMap.values()); } /** @@ -997,7 +997,7 @@ public List getUpdates() { * */ public List updateAllSites() throws InterruptedException, ExecutionException { - List > futures = new ArrayList>(); + List > futures = new ArrayList<>(); for (UpdateSite site : getSites()) { Future future = site.updateDirectly(DownloadService.signatureCheck); if (future != null) { @@ -1005,7 +1005,7 @@ public List updateAllSites() throws InterruptedException, Execut } } - List results = new ArrayList(); + List results = new ArrayList<>(); for (Future f : futures) { results.add(f.get()); } diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 153d692093b9..c4a3abf71ec6 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -355,7 +355,7 @@ public JSONObject getJSONObject() { */ @Exported public List getAvailables() { - List r = new ArrayList(); + List r = new ArrayList<>(); Data data = getData(); if(data==null) return Collections.emptyList(); for (Plugin p : data.plugins.values()) { @@ -415,7 +415,7 @@ public List getUpdates() { Data data = getData(); if(data==null) return Collections.emptyList(); // fail to determine - List r = new ArrayList(); + List r = new ArrayList<>(); for (PluginWrapper pw : Jenkins.getInstance().getPluginManager().getPlugins()) { Plugin p = pw.getUpdateInfo(); if(p!=null) r.add(p); @@ -515,13 +515,13 @@ public final class Data { /** * Plugins in the repository, keyed by their artifact IDs. */ - public final Map plugins = new TreeMap(String.CASE_INSENSITIVE_ORDER); + public final Map plugins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); /** * List of warnings (mostly security) published with the update site. * * @since 2.40 */ - private final Set warnings = new HashSet(); + private final Set warnings = new HashSet<>(); /** * If this is non-null, Jenkins is going to check the connectivity to this URL to make sure @@ -1073,7 +1073,7 @@ public boolean isCompatibleWithInstalledVersion() { */ @Exported public List getNeededDependencies() { - List deps = new ArrayList(); + List deps = new ArrayList<>(); for(Map.Entry e : dependencies.entrySet()) { VersionNumber requiredVersion = e.getValue() != null ? new VersionNumber(e.getValue()) : null; diff --git a/core/src/main/java/hudson/model/UsageStatistics.java b/core/src/main/java/hudson/model/UsageStatistics.java index e7037555ae24..93e4057c4092 100644 --- a/core/src/main/java/hudson/model/UsageStatistics.java +++ b/core/src/main/java/hudson/model/UsageStatistics.java @@ -130,7 +130,7 @@ public String getStatData() throws IOException { o.put("servletContainer", j.servletContext.getServerInfo()); o.put("version", Jenkins.VERSION); - List nodes = new ArrayList(); + List nodes = new ArrayList<>(); for( Computer c : j.getComputers() ) { JSONObject n = new JSONObject(); if(c.getNode()==j) { @@ -146,7 +146,7 @@ public String getStatData() throws IOException { } o.put("nodes",nodes); - List plugins = new ArrayList(); + List plugins = new ArrayList<>(); for( PluginWrapper pw : j.getPluginManager().getPlugins() ) { if(!pw.isActive()) continue; // treat disabled plugins as if they are uninstalled JSONObject p = new JSONObject(); diff --git a/core/src/main/java/hudson/model/UserProperties.java b/core/src/main/java/hudson/model/UserProperties.java index 2c936dfbbfa2..3b02a7c7114c 100644 --- a/core/src/main/java/hudson/model/UserProperties.java +++ b/core/src/main/java/hudson/model/UserProperties.java @@ -40,5 +40,5 @@ public class UserProperties { * Use {@link UserProperty#all()} for read access and {@link Extension} for auto-registration. */ @Deprecated - public static final List LIST = (List)new DescriptorList(UserProperty.class); + public static final List LIST = (List) new DescriptorList<>(UserProperty.class); } diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index a062f19b8c5b..ff391155ede6 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -206,7 +206,7 @@ protected View(String name, ViewGroup owner) { public Collection getAllItems() { if (this instanceof ViewGroup) { - final Collection items = new LinkedHashSet(getItems()); + final Collection items = new LinkedHashSet<>(getItems()); for(View view: ((ViewGroup) this).getViews()) { items.addAll(view.getAllItems()); @@ -318,7 +318,7 @@ public DescribableList getProperties() { * on this label. */ public List getApplicablePropertyDescriptors() { - List r = new ArrayList(); + List r = new ArrayList<>(); for (ViewPropertyDescriptor pd : ViewProperty.all()) { if (pd.isEnabledFor(this)) r.add(pd); @@ -428,9 +428,9 @@ public List getComputers() { return Arrays.asList(computers); } - List result = new ArrayList(); + List result = new ArrayList<>(); - HashSet