Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348759

Summary: SessionBroker's member sessions get postLogin event before descriptors initialized
Product: z_Archived Reporter: Andrei Ilitchev <andrei.ilitchev>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Suggested patch. none

Description Andrei Ilitchev CLA 2011-06-08 10:52:31 EDT
initializeDescriptors is no longer called for a DatabaseSession/ServerSession member of a SessionBroker: 
it's impossible because of interdependencies between the member sessions and
it's unnecessary because SessionBroker initializes all descriptors (after all member sessions are connected). 

Also noticed that preLogin for member sessions is called twice.

The suggested fix:
Don't rise postLogin for SessionBroker's member sessions in preConnectDatasource, instead rise it for all memberSessions in SesionBroker.login (and loginAndDetectDatasource).

Workaround:
Set a listener on the SessionBroker instead, postLogin event will be risen after descriptors have been initialized. From the passed to the event SessionBroker all member sessions could be extracted.
Comment 1 Andrei Ilitchev CLA 2011-06-09 12:09:06 EDT
Correction to the workaround.
All event listeners added to the SessionBroker are also added to all its member sessions. Therefore each listener added to SessionBroker will receive postLogin event for each member session and for the broker.
The listener should ignore postLogin event risen by member sessions, process the event risen by SessionBroker (event.getSession().isSessionBroker()).
Comment 2 Andrei Ilitchev CLA 2011-07-13 17:50:29 EDT
Created attachment 199623 [details]
Suggested patch.

The patch makes sure that postLogin event is risen after descriptors have been
initialized. In SessionBroker case it happens after all the member sessions are
logged in and SessionBroker has initialized all descriptors.

preLogin event for member sessions used to be risen twice - that's fixed, too.

Here's the order in which events are risen:
  brokerListener(preLogin(broker))

  for each member session:
    memberListener(preLogin(member))
    brokerListener(preLogin(broker))


  for each member session:
    memberListener(postLogin(member))
    brokerListener(postLogin(broker))

  brokerListener(postLogin(broker))

The patch is tested in composite.advanced.EntityManagerJUnitTestSuite.testSetup
by verifyPrePostLoginEvents method.
Comment 3 Andrei Ilitchev CLA 2011-07-13 18:09:06 EDT
The patch checked into both trunk (2.4) and 2.3.1
Comment 4 Andrei Ilitchev CLA 2011-07-13 18:12:44 EDT
Correction to the previous comment:

Here's the order in which events are risen:
  brokerListener(preLogin(broker))

  for each member session:
    memberListener(preLogin(member))
    brokerListener(preLogin(member))


  for each member session:
    memberListener(postLogin(member))
    brokerListener(postLogin(member))

  brokerListener(postLogin(broker))
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:20:26 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink