Skip to content

Commit

Permalink
Use thread safe collection in servlet-undertow
Browse files Browse the repository at this point in the history
  • Loading branch information
mocenas authored and michalvavrik committed Jan 22, 2024
1 parent 15c4264 commit 95acb59
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.quarkus.ts.http.undertow.listener;

import java.util.LinkedList;
import java.util.concurrent.ConcurrentLinkedDeque;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.servlet.http.HttpSession;
Expand All @@ -19,7 +19,11 @@
public final class SessionListener implements HttpSessionListener {

public static final String GAUGE_ACTIVE_SESSION = "io_quarkus_ts_active_sessions_amount";
private LinkedList<String> sessionsBucket = new LinkedList<>();
/*
* Needs to use thread-safe collection.
* When multiple sessions gets created or destroyed at once, it might create inconsistencies otherwise.
*/
private final ConcurrentLinkedDeque<String> sessionsBucket = new ConcurrentLinkedDeque<>();

SessionListener(MeterRegistry registry) {
registry.gaugeCollectionSize(GAUGE_ACTIVE_SESSION, Tags.empty(), sessionsBucket);
Expand Down

0 comments on commit 95acb59

Please sign in to comment.