Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326649 - DatabaseSessionImpl.finalize() leads to ClassCastException
Summary: DatabaseSessionImpl.finalize() leads to ClassCastException
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-30 05:07 EDT by Oliver Michels CLA
Modified: 2022-06-09 10:27 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Michels CLA 2010-09-30 05:07:46 EDT
Build Identifier: 2.1.1.v20100817-r8050

SessionBroker.logout() is called from the finalize method of its super class DatabaseSessionImpl.

then in logout() there is an explizit cast from all Sessions to DatabaseSessionImpl:
  for (Iterator sessionEnum = getSessionsByName().values().iterator();
                 sessionEnum.hasNext();) {
            DatabaseSessionImpl session = (DatabaseSessionImpl)sessionEnum.next();
            session.logout();
        }


but in SessionBroker.internalRegisterSession() 

clientBroker.internalRegisterSession(sessionName, ((ServerSession)serverSession).acquireClientSession());

resulting to register a ClientSession.

But ClientSession is not a subclass of DatabaseSessionImpl leading to ClassCastException.


Reproducible: Always

Steps to Reproduce:
read the code
Comment 1 Andrei Ilitchev CLA 2010-10-07 13:35:53 EDT
Suggested fix in SessionBroker:

public void logout() throws DatabaseException {
    if(!isLoggedIn) {
        return;
    }
    if (!isClientSessionBroker()) {
        for (Iterator sessionEnum = getSessionsByName().values().iterator();
             sessionEnum.hasNext();) {
            DatabaseSessionImpl session = (DatabaseSessionImpl)sessionEnum.next();
            session.logout();
        }
        if(hasExternalTransactionController()) {
            getExternalTransactionController().clearSequencingListeners();
        }
    }
    sequencing = null;
    isLoggedIn = false;
}
Comment 2 Peter Krogh CLA 2010-11-10 11:00:16 EST
Our SessionBroker Feature is being looked at in 2.3.0, this bug is being looked at the same time.
Comment 3 Andrei Ilitchev CLA 2011-04-28 15:58:25 EDT
Fixed in rev.9276 as part of a patch for Bug 328404 - JPA Persistence Unit Composition .
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:27:49 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink