This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 348759 - SessionBroker's member sessions get postLogin event before descriptors initialized
Summary: SessionBroker's member sessions get postLogin event before descriptors initia...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-08 10:52 EDT by Andrei Ilitchev CLA
Modified: 2022-06-09 10:20 EDT (History)
0 users

See Also:


Attachments
Suggested patch. (36.52 KB, patch)
2011-07-13 17:50 EDT, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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