From bc5836f688e57d6ac08dda88ad4a693db30d678b Mon Sep 17 00:00:00 2001 From: Gintas Grigelionis Date: Sat, 28 Apr 2018 11:06:42 +0200 Subject: [PATCH] Synchronized fields ought to be final --- src/main/org/apache/tools/ant/ComponentHelper.java | 2 +- src/main/org/apache/tools/ant/PropertyHelper.java | 6 +++--- src/main/org/apache/tools/ant/taskdefs/JDBCTask.java | 2 +- .../org/apache/tools/ant/taskdefs/ProcessDestroyer.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java index d80ede69e..04b048ad6 100644 --- a/src/main/org/apache/tools/ant/ComponentHelper.java +++ b/src/main/org/apache/tools/ant/ComponentHelper.java @@ -60,7 +60,7 @@ import org.apache.tools.ant.util.FileUtils; */ public class ComponentHelper { /** Map of component name to lists of restricted definitions */ - private Map> restrictedDefinitions = new HashMap<>(); + private final Map> restrictedDefinitions = new HashMap<>(); /** Map from component name to anttypedefinition */ private final Hashtable antTypeTable = new Hashtable<>(); diff --git a/src/main/org/apache/tools/ant/PropertyHelper.java b/src/main/org/apache/tools/ant/PropertyHelper.java index dcda2ecd0..fdd437662 100644 --- a/src/main/org/apache/tools/ant/PropertyHelper.java +++ b/src/main/org/apache/tools/ant/PropertyHelper.java @@ -238,21 +238,21 @@ public class PropertyHelper implements GetProperty { private final Hashtable, List> delegates = new Hashtable<>(); /** Project properties map (usually String to String). */ - private Hashtable properties = new Hashtable<>(); + private final Hashtable properties = new Hashtable<>(); /** * Map of "user" properties (as created in the Ant task, for example). * Note that these key/value pairs are also always put into the * project properties, so only the project properties need to be queried. */ - private Hashtable userProperties = new Hashtable<>(); + private final Hashtable userProperties = new Hashtable<>(); /** * Map of inherited "user" properties - that are those "user" * properties that have been created by tasks and not been set * from the command line or a GUI tool. */ - private Hashtable inheritedProperties = new Hashtable<>(); + private final Hashtable inheritedProperties = new Hashtable<>(); /** * Default constructor. diff --git a/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java b/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java index fdfdc39ed..aa8f1fb97 100644 --- a/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java @@ -97,7 +97,7 @@ public abstract class JDBCTask extends Task { * getting an OutOfMemoryError when calling this task * multiple times in a row. */ - private static Hashtable LOADER_MAP = new Hashtable<>(HASH_TABLE_SIZE); + private static final Hashtable LOADER_MAP = new Hashtable<>(HASH_TABLE_SIZE); private boolean caching = true; diff --git a/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java b/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java index acc69a0d3..6ab8a0a28 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java +++ b/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java @@ -31,7 +31,7 @@ import java.util.Set; class ProcessDestroyer implements Runnable { private static final int THREAD_DIE_TIMEOUT = 20000; - private Set processes = new HashSet<>(); + private final Set processes = new HashSet<>(); // methods to register and unregister shutdown hooks private Method addShutdownHookMethod; private Method removeShutdownHookMethod;