From 35451ee584fc5fac376f30b73c1445037dbb16c1 Mon Sep 17 00:00:00 2001 From: Sergio del Amo Date: Tue, 22 Dec 2020 11:12:35 +0100 Subject: [PATCH] fix: don't use list but concurrent linked queue (#514) see: https://github.com/micronaut-projects/micronaut-security/issues/500 --- .../client/clientcredentials/CacheableProcessor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/security-oauth2/src/main/java/io/micronaut/security/oauth2/client/clientcredentials/CacheableProcessor.java b/security-oauth2/src/main/java/io/micronaut/security/oauth2/client/clientcredentials/CacheableProcessor.java index 1ea38823e1..6948d6a855 100644 --- a/security-oauth2/src/main/java/io/micronaut/security/oauth2/client/clientcredentials/CacheableProcessor.java +++ b/security-oauth2/src/main/java/io/micronaut/security/oauth2/client/clientcredentials/CacheableProcessor.java @@ -23,8 +23,8 @@ import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; -import java.util.ArrayList; -import java.util.List; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.Function; import java.util.stream.Collectors; @@ -50,7 +50,7 @@ class CacheableProcessor implements Processor { private Subscription subscription; @NonNull - private List> subscriptions = new ArrayList<>(); + private Queue> subscriptions = new ConcurrentLinkedQueue<>(); @Nullable private final Function transformer; @@ -83,7 +83,7 @@ public void clear() { } subscriptions = subscriptions.stream() .filter(elementSubscription -> !elementSubscription.isCanceled() && !elementSubscription.isComplete()) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ConcurrentLinkedQueue::new)); } // Subscriber