tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42803] New: - AbstractReplicatedMap.size() is not thread safe.
Date Tue, 03 Jul 2007 10:05:26 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42803>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42803

           Summary: AbstractReplicatedMap.size() is not thread safe.
           Product: Tomcat 6
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: keiichi.fujino@gmail.com


NullPointerException is thrown when the session is created. 
The following are the error messages. 

** localhost.xxxx-xx-xx.log **
java.lang.NullPointerException
        at org.apache.catalina.tribes.tipis.AbstractReplicatedMap.size
(AbstractReplicatedMap.java:989)
        at org.apache.catalina.session.ManagerBase.add(ManagerBase.java:741)
        at org.apache.catalina.session.StandardSession.setId
(StandardSession.java:368)
        at org.apache.catalina.ha.session.DeltaSession.setId
(DeltaSession.java:243)
        at org.apache.catalina.session.ManagerBase.createSession
(ManagerBase.java:829)
        at org.apache.catalina.session.StandardManager.createSession
(StandardManager.java:291)
        at org.apache.catalina.connector.Request.doGetSession
(Request.java:2312)
        at org.apache.catalina.connector.Request.getSession(Request.java:2075)
        at org.apache.catalina.connector.RequestFacade.getSession
(RequestFacade.java:833)
        at org.apache.catalina.connector.RequestFacade.getSession
(RequestFacade.java:844)
        .........
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:128)
        at org.apache.catalina.ha.tcp.ReplicationValve.invoke
(ReplicationValve.java:347)
        at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:104)
        at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:261)
        at org.apache.jk.server.JkCoyoteHandler.invoke
(JkCoyoteHandler.java:190)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
        at org.apache.jk.common.ChannelSocket.processConnection
(ChannelSocket.java:697)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt
(ChannelSocket.java:889)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:686)
        at java.lang.Thread.run(Thread.java:595)


[Environment]
  use BackupManager in Tomcat6.0.13.
  <Manager className="org.apache.catalina.ha.session.BackupManager" ... />

I think org.apache.catalina.tribes.tipis.AbstractReplicatedMap.size() is not 
thread safe.
After creating the session. (ManagerBase.java:829))
To update maxActive, the size of the session map is gotten.
And org.apache.catalina.tribes.tipis.AbstractReplicatedMap.size() is as 
follows. 

  public int size() {
      //todo, implement a counter variable instead
      //only count active members in this node
      int counter = 0;
      Iterator it = super.entrySet().iterator();
      while (it.hasNext() ) {
          Map.Entry e = (Map.Entry) it.next();
          if ( e != null ) {
              MapEntry entry = (MapEntry) super.get(e.getKey());
              if (entry.isPrimary() && entry.getValue() != null) counter++; 
          }
      }
      return counter;
  }


While a certain Thread executes AbstractReplicatedMap.size()  
another Thread executes AbstractReplicatedMap.remove() by session.invalidate() 
and the session time-out. 

When the session is removed from the sessions by another thread after Iterator 
is gotten (line:984) 
entry(Session) acquired as follows might become Null. 
  
  MapEntry entry = (MapEntry) super.get(e.getKey());

Therefore, NullPointerException is thrown in the next line(line:989). 

If Servlet that does only request.getSession() and session.invalidate() is 
executed by a high load,
NullPointerExceprtion is immediately thrown. 

    public void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        session.invalidate();
    }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message