Skip to content

Commit fecbd73

Browse files
jbertramgemmellr
authored andcommitted
ARTEMIS-5273 use collection interfaces where possible
1 parent a40b0a5 commit fecbd73

File tree

312 files changed

+958
-792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+958
-792
lines changed

artemis-boot/src/main/java/org/apache/activemq/artemis/boot/Artemis.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static Object execute(File artemisHome, File artemisInstance, File fileBr
7979
* This is a good method for booting an embedded command
8080
*/
8181
public static Object execute(File fileHome, File fileInstance, File fileBrokerETC, boolean useSystemOut, boolean enableShell, String... args) throws Throwable {
82-
ArrayList<File> dirs = new ArrayList<>();
82+
List<File> dirs = new ArrayList<>();
8383
if (fileHome != null) {
8484
dirs.add(new File(fileHome, "lib"));
8585
}
@@ -97,7 +97,7 @@ public static Object execute(File fileHome, File fileInstance, File fileBrokerET
9797
}
9898
}
9999

100-
ArrayList<URL> urls = new ArrayList<>();
100+
List<URL> urls = new ArrayList<>();
101101

102102
// Without the etc on the config, things like JGroups configuration wouldn't be loaded
103103
if (fileBrokerETC == null && fileInstance != null) {
@@ -119,7 +119,7 @@ public static Object execute(File fileHome, File fileInstance, File fileBrokerET
119119
if (bootdir.exists() && bootdir.isDirectory()) {
120120

121121
// Find the jar files in the directory..
122-
ArrayList<File> files = new ArrayList<>();
122+
List<File> files = new ArrayList<>();
123123
for (File f : bootdir.listFiles()) {
124124
if (f.getName().endsWith(".jar") || f.getName().endsWith(".zip")) {
125125
files.add(f);
@@ -158,7 +158,7 @@ public static Object execute(File fileHome, File fileInstance, File fileBrokerET
158158

159159
}
160160

161-
private static void add(ArrayList<URL> urls, File file) {
161+
private static void add(List<URL> urls, File file) {
162162
try {
163163
urls.add(file.toURI().toURL());
164164
} catch (MalformedURLException e) {

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.text.DecimalFormat;
2525
import java.util.HashMap;
2626
import java.util.LinkedHashMap;
27+
import java.util.Map;
2728

2829
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
2930
import org.apache.activemq.artemis.api.core.RoutingType;
@@ -557,7 +558,7 @@ public Object run(ActionContext context) throws Exception {
557558

558559
context.out.println(String.format("Creating ActiveMQ Artemis instance at: %s", directory.getCanonicalPath()));
559560

560-
HashMap<String, String> filters = new LinkedHashMap<>();
561+
Map<String, String> filters = new LinkedHashMap<>();
561562

562563
if (journalDeviceBlockSize % 512 != 0) {
563564
// This will generate a CLI error
@@ -880,7 +881,7 @@ public Object run(ActionContext context) throws Exception {
880881
return null;
881882
}
882883

883-
protected static void addScriptFilters(HashMap<String, String> filters,
884+
protected static void addScriptFilters(Map<String, String> filters,
884885
File home,
885886
File directory,
886887
File etcFolder,
@@ -910,7 +911,7 @@ protected static void addScriptFilters(HashMap<String, String> filters,
910911
filters.put("${role}", role);
911912
}
912913

913-
private String getConnectors(HashMap<String, String> filters) throws IOException {
914+
private String getConnectors(Map<String, String> filters) throws IOException {
914915
if (staticNode != null) {
915916
StringWriter stringWriter = new StringWriter();
916917
PrintWriter printer = new PrintWriter(stringWriter);
@@ -987,7 +988,7 @@ private static int countBoolean(boolean...b) {
987988
/**
988989
* It will create the address and queue configurations
989990
*/
990-
private void applyAddressesAndQueues(HashMap<String, String> filters) {
991+
private void applyAddressesAndQueues(Map<String, String> filters) {
991992
StringWriter writer = new StringWriter();
992993
PrintWriter printWriter = new PrintWriter(writer);
993994
printWriter.println();
@@ -1027,7 +1028,7 @@ private void applyAddressesAndQueues(HashMap<String, String> filters) {
10271028
filters.put("${address-queue.settings}", writer.toString());
10281029
}
10291030

1030-
private void performAutoTune(HashMap<String, String> filters, JournalType journalType, File dataFolder) {
1031+
private void performAutoTune(Map<String, String> filters, JournalType journalType, File dataFolder) {
10311032
if (noAutoTune) {
10321033
filters.put("${journal-buffer.settings}", "");
10331034
filters.put("${page-sync.settings}", "");
@@ -1038,7 +1039,7 @@ private void performAutoTune(HashMap<String, String> filters, JournalType journa
10381039
getActionContext().out.println("Auto tuning journal ...");
10391040

10401041
if (mapped && noJournalSync) {
1041-
HashMap<String, String> syncFilter = new HashMap<>();
1042+
Map<String, String> syncFilter = new HashMap<>();
10421043
syncFilter.put("${nanoseconds}", "0");
10431044
syncFilter.put("${writesPerMillisecond}", "0");
10441045
syncFilter.put("${maxaio}", journalType == JournalType.ASYNCIO ? "" + ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio() : "1");
@@ -1055,7 +1056,7 @@ private void performAutoTune(HashMap<String, String> filters, JournalType journa
10551056

10561057
String writesPerMillisecondStr = new DecimalFormat("###.##").format(writesPerMillisecond);
10571058

1058-
HashMap<String, String> syncFilter = new HashMap<>();
1059+
Map<String, String> syncFilter = new HashMap<>();
10591060
syncFilter.put("${nanoseconds}", Long.toString(nanoseconds));
10601061
syncFilter.put("${writesPerMillisecond}", writesPerMillisecondStr);
10611062
syncFilter.put("${maxaio}", journalType == JournalType.ASYNCIO ? "" + ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio() : "1");
@@ -1140,11 +1141,11 @@ private static String path(File value) throws IOException {
11401141
return value.getCanonicalPath();
11411142
}
11421143

1143-
private void write(String source, HashMap<String, String> filters, boolean unixTarget) throws Exception {
1144+
private void write(String source, Map<String, String> filters, boolean unixTarget) throws Exception {
11441145
write(source, new File(directory, source), filters, unixTarget, force);
11451146
}
11461147

1147-
private void writeEtc(String source, File etcFolder, HashMap<String, String> filters, boolean unixTarget) throws Exception {
1148+
private void writeEtc(String source, File etcFolder, Map<String, String> filters, boolean unixTarget) throws Exception {
11481149
write("etc/" + source, new File(etcFolder, source), filters, unixTarget, force);
11491150
}
11501151

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InstallAbstract.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.io.InputStream;
2626
import java.io.OutputStream;
2727
import java.nio.charset.StandardCharsets;
28-
import java.util.HashMap;
2928
import java.util.List;
3029
import java.util.Map;
3130
import java.util.regex.Matcher;
@@ -189,7 +188,7 @@ protected static void copy(InputStream is, OutputStream os) throws IOException {
189188

190189
protected void write(String source,
191190
File target,
192-
HashMap<String, String> filters,
191+
Map<String, String> filters,
193192
boolean unixTarget, boolean force) throws Exception {
194193
if (target.exists() && !force) {
195194
throw new CLIException(String.format("The file '%s' already exists. Use --force to overwrite.", target));

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Upgrade.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.nio.file.StandardCopyOption;
2727
import java.util.HashMap;
2828
import java.util.Iterator;
29+
import java.util.Map;
2930
import java.util.function.Consumer;
3031
import java.util.function.Function;
3132
import java.util.stream.Stream;
@@ -108,7 +109,7 @@ public Object run(ActionContext context) throws Exception {
108109
throw new IOException(etcFolder + " does not exist for etc");
109110
}
110111

111-
HashMap<String, String> filters = new HashMap<>();
112+
Map<String, String> filters = new HashMap<>();
112113
Create.addScriptFilters(filters, getHome(), getInstance(), etcFolder, dataFolder, oomeDumpFile, javaMemory, getJavaOptions(), getJavaUtilityOptions(), "NA");
113114

114115
if (IS_WINDOWS) {
@@ -321,7 +322,7 @@ private void replaceLines(ActionContext context, File tmpFile, File targetFile,
321322
}
322323

323324
private void upgrade(ActionContext context, File tmpFile, File targetFile, File bkpFile, String... keepingPrefixes) throws Exception {
324-
HashMap<String, String> replaceMatrix = new HashMap<>();
325+
Map<String, String> replaceMatrix = new HashMap<>();
325326

326327
doUpgrade(context, tmpFile, targetFile, bkpFile,
327328
oldLine -> {

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/ClusterNodeVerifier.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.ArrayList;
2222
import java.util.Date;
2323
import java.util.LinkedHashMap;
24+
import java.util.List;
2425
import java.util.Map;
2526
import java.util.concurrent.atomic.AtomicBoolean;
2627
import java.util.function.Consumer;
@@ -167,7 +168,7 @@ String formatDate(SimpleDateFormat sdf, long time) {
167168
}
168169

169170
protected Long[] fetchTopologyTime(Map<String, TopologyItem> topologyItemMap) {
170-
ArrayList<Long> times = new ArrayList<>(topologyItemMap.size() * 2);
171+
List<Long> times = new ArrayList<>(topologyItemMap.size() * 2);
171172
topologyItemMap.forEach((id, node) -> {
172173
if (node.primary != null) {
173174
try {

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/NodeCheck.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.activemq.artemis.cli.commands.check;
1919

2020
import java.util.ArrayList;
21+
import java.util.List;
2122

2223
import org.apache.activemq.artemis.api.core.management.NodeInfo;
2324
import picocli.CommandLine.Command;
@@ -102,7 +103,7 @@ public void setPeers(Integer peers) {
102103

103104
@Override
104105
protected CheckTask[] getCheckTasks() {
105-
ArrayList<CheckTask> checkTasks = new ArrayList<>();
106+
List<CheckTask> checkTasks = new ArrayList<>();
106107

107108
if (primary || live) {
108109
checkTasks.add(new CheckTask("the node has a primary", this::checkNodePrimary));

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/QueueCheck.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import javax.jms.Session;
2626
import java.util.ArrayList;
2727
import java.util.Enumeration;
28+
import java.util.List;
2829

2930
import org.apache.activemq.artemis.api.core.management.ResourceNames;
3031
import picocli.CommandLine.Command;
@@ -79,7 +80,7 @@ public void setProduce(Integer produce) {
7980

8081
@Override
8182
protected CheckTask[] getCheckTasks() {
82-
ArrayList<CheckTask> checkTasks = new ArrayList<>();
83+
List<CheckTask> checkTasks = new ArrayList<>();
8384

8485
if (getName() == null) {
8586
name = input("--name", "Name is a mandatory property for Queue check", null);

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/helper/HelperCreate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public HelperCreate setConfiguration(String configuration) {
279279

280280
public void createServer() throws Exception {
281281

282-
ArrayList<String> listCommands = new ArrayList<>();
282+
List<String> listCommands = new ArrayList<>();
283283

284284
add(listCommands, "create", "--silent", "--force", "--user", user, "--password", password, "--role", role, "--port-offset", "" + portOffset, "--data", dataFolder);
285285

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Arrays;
2121
import java.util.Date;
2222
import java.util.HashMap;
23+
import java.util.List;
2324
import java.util.Map;
2425
import java.util.TreeMap;
2526

@@ -315,14 +316,14 @@ private void printStats(String result) {
315316
int[] columnSizes = new int[FIELD.values().length];
316317
boolean[] centralize = new boolean[columnSizes.length];
317318

318-
ArrayList<String>[] fieldTitles = new ArrayList[columnSizes.length];
319+
List<String>[] fieldTitles = new ArrayList[columnSizes.length];
319320

320321
FIELD[] fields = FIELD.values();
321322
for (int i = 0; i < fields.length; i++) {
322323
if (singleLineHeader) {
323324
columnSizes[i] = fields[i].toString().length();
324325
} else {
325-
ArrayList<String> splitTitleArrayList = new ArrayList<>();
326+
List<String> splitTitleArrayList = new ArrayList<>();
326327
String[] splitTitleStringArray = fields[i].toString().split("_");
327328
centralize[i] = fields[i].center;
328329

@@ -447,7 +448,7 @@ private StringBuilder paddingString(StringBuilder value, int maxColumnSize) {
447448
//creates filter used for listQueues()
448449
private String createFilter() {
449450

450-
HashMap<String, Object> filterMap = new HashMap<>();
451+
Map<String, Object> filterMap = new HashMap<>();
451452

452453
if (((fieldName != null) && (fieldName.trim().length() > 0)) && ((queueName != null && queueName.trim().length() > 0))) {
453454
getActionContext().err.println("'--field' and '--queueName' cannot be specified together.");

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private static void printPages(DescribeJournal describeJournal,
255255
DescribeJournal bindingsDescribe) throws Exception {
256256
PageCursorsInfo cursorACKs = calculateCursorsInfo(describeJournal.getRecords());
257257

258-
HashSet<Long> existingQueues = new HashSet<>();
258+
Set<Long> existingQueues = new HashSet<>();
259259
if (bindingsDescribe != null && bindingsDescribe.getBindingEncodings() != null) {
260260
bindingsDescribe.getBindingEncodings().forEach(e -> existingQueues.add(e.getId()));
261261
}

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/RecoverMessages.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.File;
2020
import java.util.HashSet;
2121
import java.util.List;
22+
import java.util.Set;
2223

2324
import org.apache.activemq.artemis.api.core.Pair;
2425
import org.apache.activemq.artemis.cli.commands.ActionContext;
@@ -103,14 +104,14 @@ public static void recover(ActionContext context, Configuration configuration, S
103104

104105
List<JournalFile> files = messagesJournal.orderFiles();
105106

106-
HashSet<Byte> userRecordsOfInterest = new HashSet<>();
107+
Set<Byte> userRecordsOfInterest = new HashSet<>();
107108
userRecordsOfInterest.add(JournalRecordIds.ADD_LARGE_MESSAGE);
108109
userRecordsOfInterest.add(JournalRecordIds.ADD_MESSAGE);
109110
userRecordsOfInterest.add(JournalRecordIds.ADD_MESSAGE_PROTOCOL);
110111
userRecordsOfInterest.add(JournalRecordIds.ADD_REF);
111112
userRecordsOfInterest.add(JournalRecordIds.PAGE_TRANSACTION);
112113

113-
HashSet<Pair<Long, Long>> routeBindigns = new HashSet<>();
114+
Set<Pair<Long, Long>> routeBindigns = new HashSet<>();
114115

115116
for (JournalFile file : files) {
116117
// For reviewers and future maintainers: I really meant System.out.println here

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/journal/DecodeJournal.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static void importJournal(final String directory,
123123

124124
String line;
125125

126-
HashMap<Long, AtomicInteger> txCounters = new HashMap<>();
126+
Map<Long, AtomicInteger> txCounters = new HashMap<>();
127127

128128
long lineNumber = 0;
129129

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public MessageInfo readMessage(boolean decodeUTF8) throws Exception {
7171
long timestamp = 0L;
7272
long id = 0L;
7373
org.apache.activemq.artemis.utils.UUID userId = null;
74-
ArrayList<String> queues = new ArrayList<>();
74+
List<String> queues = new ArrayList<>();
7575

7676
// get message's attributes
7777
for (int i = 0; i < reader.getAttributeCount(); i++) {
@@ -157,7 +157,7 @@ private Byte getMessageType(String value) {
157157
return type;
158158
}
159159

160-
private void processMessageQueues(ArrayList<String> queues) {
160+
private void processMessageQueues(List<String> queues) {
161161
for (int i = 0; i < reader.getAttributeCount(); i++) {
162162
if (XmlDataConstants.QUEUE_NAME.equals(reader.getAttributeLocalName(i))) {
163163
String queueName = reader.getAttributeValue(i);

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XmlDataExporter.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public final class XmlDataExporter extends DBOption {
8686
private String undefinedPrefix = "UndefinedQueue_";
8787

8888
// an inner map of message refs hashed by the queue ID to which they belong and then hashed by their record ID
89-
private final Map<Long, HashMap<Long, ReferenceDescribe>> messageRefs = new HashMap<>();
89+
private final Map<Long, Map<Long, ReferenceDescribe>> messageRefs = new HashMap<>();
9090

9191
// map of all message records hashed by their record ID (which will match the record ID of the message refs)
9292
private final Map<Long, Message> messages = new TreeMap<>();
@@ -95,9 +95,9 @@ public final class XmlDataExporter extends DBOption {
9595

9696
private final Set<Long> pgTXs = new HashSet<>();
9797

98-
private final HashMap<Long, PersistentQueueBindingEncoding> queueBindings = new HashMap<>();
98+
private final Map<Long, PersistentQueueBindingEncoding> queueBindings = new HashMap<>();
9999

100-
private final HashMap<Long, PersistentAddressBindingEncoding> addressBindings = new HashMap<>();
100+
private final Map<Long, PersistentAddressBindingEncoding> addressBindings = new HashMap<>();
101101

102102
long messagesPrinted = 0L;
103103

@@ -184,7 +184,7 @@ private void writeXMLData() throws Exception {
184184
* @throws Exception will be thrown if anything goes wrong reading the journal
185185
*/
186186
private void processMessageJournal() throws Exception {
187-
ArrayList<RecordInfo> acks = new ArrayList<>();
187+
List<RecordInfo> acks = new ArrayList<>();
188188

189189
List<RecordInfo> records = new LinkedList<>();
190190

@@ -243,9 +243,9 @@ private void processMessageJournal() throws Exception {
243243
messages.put(info.id, ((MessageDescribe) o).getMsg());
244244
} else if (info.getUserRecordType() == JournalRecordIds.ADD_REF) {
245245
ReferenceDescribe ref = (ReferenceDescribe) o;
246-
HashMap<Long, ReferenceDescribe> map = messageRefs.get(info.id);
246+
Map<Long, ReferenceDescribe> map = messageRefs.get(info.id);
247247
if (map == null) {
248-
HashMap<Long, ReferenceDescribe> newMap = new HashMap<>();
248+
Map<Long, ReferenceDescribe> newMap = new HashMap<>();
249249
newMap.put(ref.refEncoding.queueID, ref);
250250
messageRefs.put(info.id, newMap);
251251
} else {
@@ -292,10 +292,10 @@ private void processMessageJournal() throws Exception {
292292
*
293293
* @param acks the list of ack records we got from the journal
294294
*/
295-
private void removeAcked(ArrayList<RecordInfo> acks) {
295+
private void removeAcked(List<RecordInfo> acks) {
296296
for (RecordInfo info : acks) {
297297
AckDescribe ack = (AckDescribe) DescribeJournal.newObjectEncoding(info, null);
298-
HashMap<Long, ReferenceDescribe> referenceDescribeHashMap = messageRefs.get(info.id);
298+
Map<Long, ReferenceDescribe> referenceDescribeHashMap = messageRefs.get(info.id);
299299
if (referenceDescribeHashMap != null) {
300300
referenceDescribeHashMap.remove(ack.refEncoding.queueID);
301301
if (referenceDescribeHashMap.size() == 0) {
@@ -491,7 +491,7 @@ private void printPagedMessagesAsXML() {
491491
}
492492
}
493493

494-
private List<String> extractQueueNames(HashMap<Long, DescribeJournal.ReferenceDescribe> refMap) {
494+
private List<String> extractQueueNames(Map<Long, DescribeJournal.ReferenceDescribe> refMap) {
495495
List<String> queues = new ArrayList<>();
496496
for (DescribeJournal.ReferenceDescribe ref : refMap.values()) {
497497
String queueName;

artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XmlDataImporter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public final class XmlDataImporter extends ConnectionConfigurationAbtract {
8686

8787
final Map<String, Long> queueIDs = new HashMap<>();
8888

89-
HashMap<String, String> oldPrefixTranslation = new HashMap<>();
89+
Map<String, String> oldPrefixTranslation = new HashMap<>();
9090

9191
private ClientSession session;
9292
private ClientProducer producer;

0 commit comments

Comments
 (0)