Code example for ConcurrentLinkedQueue

0
 * @author Jeanfrancois Arcand 
 */ 
public class SessionCreationInterceptor extends AtmosphereInterceptorAdapter { 
 
    // This can cause memory leak. 
    private ConcurrentLinkedQueue<String> ids = new ConcurrentLinkedQueue<String>();
 
    @Override 
    public Action inspect(AtmosphereResource r) {
 
        if (Utils.webSocketMessage(r)) return Action.CONTINUE;
 
        if (r.session(false) == null
                && !ids.remove(r.uuid())
                && r.getRequest().getMethod().equalsIgnoreCase("GET")) {
            r.session(true);
            ids.offer(r.uuid());
            return Action.CANCELLED; 
        } 
        return Action.CONTINUE;