Bug 41682 - ClassCastException with BackupManager + debug logging
ClassCastException with BackupManager + debug logging
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Catalina
6.0.7
Other other
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-02-22 13:05 UTC by Graham Johnson
Modified: 2007-03-26 23:52 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Graham Johnson 2007-02-22 13:05:50 UTC
(Still happening in 6.0.9, though that isn't an option in Bugzilla)

If I use the BackupManager for session replication AND turn on debug logging, I
get this exception when I try to invalidate the session:

java.lang.ClassCastException: org.apache.catalina.ha.session.BackupManager
cannot be cast to org.apache.catalina.ha.session.DeltaManager
	at org.apache.catalina.ha.session.DeltaSession.expire(DeltaSession.java:361)
	at org.apache.catalina.ha.session.DeltaSession.expire(DeltaSession.java:352)
	at org.apache.catalina.session.StandardSession.expire(StandardSession.java:660)
	at
org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1112)
	at
org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:150)

The bug is easy to find in the source.  If debug logging is enabled, it tries to
cast manager to DeltaManager without an instanceof, even though it is doing an
instanceof immediately after:

    public void expire(boolean notify, boolean notifyCluster) {
        String expiredId = getIdInternal();
        super.expire(notify);

        if (notifyCluster) {
            if (log.isDebugEnabled())
                log.debug(sm.getString("deltaSession.notifying",
                                       ((DeltaManager)manager).getName(),
                                       new Boolean(isPrimarySession()),
                                       expiredId));
            if ( manager instanceof DeltaManager ) {
                ( (DeltaManager) manager).sessionExpired(expiredId);
            }
        }
    }
Comment 1 Filip Hanik 2007-03-26 23:52:24 UTC
Thanks for the report