Project: Tomcat
Bug 41682 ClassCastException with BackupManager + debug logging
Reported: 2007-02-22 13:05:50 | Status: resolved fixed

(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); } } }

Files changed in fix:
java/org/apache/catalina/ha/session/DeltaSession.java