Replace remaining usage of LinkedList with ArrayList/ArrayDeque

Closes gh-25650
This commit is contained in:
Juergen Hoeller
2020-08-26 18:32:08 +02:00
parent d198c4426f
commit 874574513c
65 changed files with 239 additions and 239 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.scheduling.commonj;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import javax.naming.NamingException;
@@ -62,7 +62,8 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
@Nullable
private ScheduledTimerListener[] scheduledTimerListeners;
private final List<Timer> timers = new LinkedList<>();
@Nullable
private List<Timer> timers;
/**
@@ -87,6 +88,7 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
super.afterPropertiesSet();
if (this.scheduledTimerListeners != null) {
this.timers = new ArrayList<>(this.scheduledTimerListeners.length);
TimerManager timerManager = obtainTimerManager();
for (ScheduledTimerListener scheduledTask : this.scheduledTimerListeners) {
Timer timer;
@@ -144,15 +146,17 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor
@Override
public void destroy() {
// Cancel all registered timers.
for (Timer timer : this.timers) {
try {
timer.cancel();
}
catch (Throwable ex) {
logger.debug("Could not cancel CommonJ Timer", ex);
if (this.timers != null) {
for (Timer timer : this.timers) {
try {
timer.cancel();
}
catch (Throwable ex) {
logger.debug("Could not cancel CommonJ Timer", ex);
}
}
this.timers.clear();
}
this.timers.clear();
// Stop the TimerManager itself.
super.destroy();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.scheduling.quartz;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -228,7 +227,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
}
else {
// Create empty list for easier checks when registering triggers.
this.jobDetails = new LinkedList<>();
this.jobDetails = new ArrayList<>();
}
// Register Calendars.