4 Replies Latest reply on Feb 17, 2016 7:32 AM by jadtn

    [wildfly 9.02 undertow] "bad ref" on httpsession wrong equals on httpsession

    jadtn

      Hi

      I've a HttpSessionListener and the HttpSession passed on created and destroy aren't the same and equals don't works .

      sessionOnCreated.equals(sessionOnDestroy) == false

      sessionCreated {}  io.undertow.servlet.spec.HttpSessionImpl@39f87f

      sessionDestroyed{}  io.undertow.servlet.spec.HttpSessionImpl@973b68

       

      it need to look the sessionId .

      I thing it s a bug if you are agree...

       

      Adrien

       

       

      import java.io.Serializable;

      import java.util.ArrayList;

      import java.util.Collection;

      import java.util.Date;

      import java.util.Iterator;

      import java.util.List;

      import java.util.Map;

      import java.util.Map.Entry;

      import java.util.Set;

      import java.util.Vector;

       

       

      import javax.servlet.http.HttpSession;

      import javax.servlet.http.HttpSessionEvent;

      import javax.servlet.http.HttpSessionListener;

       

       

      import org.slf4j.Logger;

      import org.slf4j.LoggerFactory;

       

       

       

      public class SessionCounterCleaner implements HttpSessionListener,Serializable {

        private static transient Logger log = LoggerFactory.getLogger(SessionCounterCleaner.class);

        final Vector<HttpSession> sessions=new Vector<HttpSession>(100);

        public SessionCounterCleaner() {

        }

       

        @Override

        public void sessionCreated(HttpSessionEvent e) {

        if (log.isDebugEnabled()) {

        log.debug("session createad (HttpSessionEvent e)"+e);

        }

        sessions.add(e.getSession());

        }

      }

       

       

       

        @Override

        public void sessionDestroyed(HttpSessionEvent e) {

        for (int i = 0; i < 5; i++) {

        log.error("xxsessionDestroyed{}  "+e.getSession());

        }

        singleton.sessionDestroy(e.getSession());

       

       

        }

       

       

        public  void sessionDestroy(final HttpSession session) {

        if (log.isDebugEnabled()) {

        log.debug("sessionDestroyed{");

        }

       

      boolean destroyed =sessions.remove(session);

        if(destroyed==false){

        int sessSize=sessions.size();

        for (int i = 0; i < 50; i++) {

        log.error("ARRRRRRG !!"+session);

        }

       

        .........

        

       

      }