124
124
import java .sql .Savepoint ;
125
125
import java .sql .Struct ;
126
126
import java .text .ParseException ;
127
- import java .util .ArrayList ;
128
127
import java .util .Arrays ;
128
+ import java .util .Collection ;
129
129
import java .util .HashMap ;
130
130
import java .util .Iterator ;
131
131
import java .util .List ;
132
132
import java .util .Map ;
133
133
import java .util .Objects ;
134
134
import java .util .Properties ;
135
135
import java .util .concurrent .ConcurrentHashMap ;
136
+ import java .util .concurrent .ConcurrentLinkedQueue ;
136
137
import java .util .concurrent .CountDownLatch ;
137
138
import java .util .concurrent .Executor ;
138
139
import java .util .concurrent .ScheduledFuture ;
@@ -178,11 +179,11 @@ public class PGDirectConnection extends BasicContext implements PGConnection {
178
179
private static class Cleanup implements CleanupRunnable {
179
180
180
181
ServerConnection serverConnection ;
181
- List <WeakReference <PGStatement >> statements ;
182
+ Collection <WeakReference <PGStatement >> statements ;
182
183
StackTraceElement [] allocationStackTrace ;
183
184
String connectionInfo ;
184
185
185
- private Cleanup (ServerConnection serverConnection , List <WeakReference <PGStatement >> statements , String connectionInfo ) {
186
+ private Cleanup (ServerConnection serverConnection , Collection <WeakReference <PGStatement >> statements , String connectionInfo ) {
186
187
this .serverConnection = serverConnection ;
187
188
this .statements = statements ;
188
189
this .allocationStackTrace = new Exception ().getStackTrace ();
@@ -217,7 +218,7 @@ public void run() {
217
218
boolean autoCommit = true ;
218
219
private int networkTimeout ;
219
220
private SQLWarning warningChain ;
220
- private List <WeakReference <PGStatement >> activeStatements ;
221
+ private Collection <WeakReference <PGStatement >> activeStatements ;
221
222
private Map <StatementCacheKey , StatementDescription > descriptionCache ;
222
223
private Map <StatementCacheKey , PreparedStatementDescription > preparedStatementCache ;
223
224
private int preparedStatementCacheThreshold ;
@@ -234,7 +235,7 @@ public void run() {
234
235
235
236
this .strict = getSetting (STRICT_MODE );
236
237
this .networkTimeout = getSetting (DEFAULT_NETWORK_TIMEOUT );
237
- this .activeStatements = new ArrayList <>();
238
+ this .activeStatements = new ConcurrentLinkedQueue <>();
238
239
this .notificationListeners = new ConcurrentHashMap <>();
239
240
240
241
final int descriptionCacheSize = getSetting (DESCRIPTION_CACHE_SIZE );
@@ -394,7 +395,7 @@ else if (s == statement) {
394
395
*
395
396
* @param statements Statements to close
396
397
*/
397
- private static void closeStatements (List <WeakReference <PGStatement >> statements ) {
398
+ private static void closeStatements (Collection <WeakReference <PGStatement >> statements ) {
398
399
399
400
for (WeakReference <PGStatement > statementRef : statements ) {
400
401
0 commit comments