[
https://jira.jboss.org/jira/browse/JBAS-5880?page=com.atlassian.jira.plug...
]
Adrian Brock updated JBAS-5880:
-------------------------------
Description:
We found a synchronization problem when starting JBoss under load. In class
TxServerClientInterceptor method getEmptyPropagationContext a static member is initialized
without being synchronized.
While one thread is still initializing the otid member in line 100, an other thread
assigns a new object to the "current" member so that otid is null.
... BINGO
sniplet from TxServerClientInterceptor
090 static PropagationContext getEmptyPropagationContext()
091 {
092 if (emptyPC == null)
093 {
094 // According to the spec, this should all be ignored
095 // But we get NPEs if it doesn't contain some content
096 emptyPC = new PropagationContext();
097 emptyPC.parents = new TransIdentity[0];
098 emptyPC.current = new TransIdentity();
099 emptyPC.current.otid = new otid_t();
100 emptyPC.current.otid.formatID = 666;
101 emptyPC.current.otid.bqual_length = 1;
102 emptyPC.current.otid.tid = new byte[] { (byte) 1 };
103 emptyPC.implementation_specific_data = ORB.init().create_any();
104 emptyPC.implementation_specific_data.insert_boolean(false);
105 }
106 return emptyPC;
The problem is that a second thread could see emptyPC as not null
while the first thread is still initialising the data.
The fix is to contruct a "temp" propagation context that is only assigned
to emptyPC once it is fully initialised.
SInce this is just a cached object, it doesn't really matter if a few threads at the
start
of processing initialise emptyPC multiple times, the method is "idempotent".
was:
We found a synchronization problem when starting JBoss under load. In class
TxServerClientInterceptor method getEmptyPropagationContext a static member is initialized
without being synchronized.
While one thread is still initializing the otid member in line 100, an other thread
assigns a new object to the "current" member so that otid is null.
... BINGO
sniplet from TxServerClientInterceptor
090 static PropagationContext getEmptyPropagationContext()
091 {
092 if (emptyPC == null)
093 {
094 // According to the spec, this should all be ignored
095 // But we get NPEs if it doesn't contain some content
096 emptyPC = new PropagationContext();
097 emptyPC.parents = new TransIdentity[0];
098 emptyPC.current = new TransIdentity();
099 emptyPC.current.otid = new otid_t();
100 emptyPC.current.otid.formatID = 666;
101 emptyPC.current.otid.bqual_length = 1;
102 emptyPC.current.otid.tid = new byte[] { (byte) 1 };
103 emptyPC.implementation_specific_data = ORB.init().create_any();
104 emptyPC.implementation_specific_data.insert_boolean(false);
105 }
106 return emptyPC;
Note: Please keep in mind that synchronization is done only if the emtyPC object needs
initialization:
static PropagationContext getEmptyPropagationContext()
{
if (emptyPC == null)
{
syncronized(any){
if (emptyPC == null)
{
tempEmptyPc = new PropagationContext();
tempEmptyPC.parents = new ....
// assign as late as possible
emptyPC = tempEmptyPc;
}
}
}
return emptyPC;
Synchronization Problem in TxServerClientInterceptor
-----------------------------------------------------
Key: JBAS-5880
URL:
https://jira.jboss.org/jira/browse/JBAS-5880
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: IIOP service
Affects Versions: JBossAS-4.2.2.GA
Reporter: Justin Bertram
Assignee: Stefan Guilhen
Fix For: JBossAS-4.2.4.GA
We found a synchronization problem when starting JBoss under load. In class
TxServerClientInterceptor method getEmptyPropagationContext a static member is initialized
without being synchronized.
While one thread is still initializing the otid member in line 100, an other thread
assigns a new object to the "current" member so that otid is null.
... BINGO
sniplet from TxServerClientInterceptor
090 static PropagationContext getEmptyPropagationContext()
091 {
092 if (emptyPC == null)
093 {
094 // According to the spec, this should all be ignored
095 // But we get NPEs if it doesn't contain some content
096 emptyPC = new PropagationContext();
097 emptyPC.parents = new TransIdentity[0];
098 emptyPC.current = new TransIdentity();
099 emptyPC.current.otid = new otid_t();
100 emptyPC.current.otid.formatID = 666;
101 emptyPC.current.otid.bqual_length = 1;
102 emptyPC.current.otid.tid = new byte[] { (byte) 1 };
103 emptyPC.implementation_specific_data = ORB.init().create_any();
104 emptyPC.implementation_specific_data.insert_boolean(false);
105 }
106 return emptyPC;
The problem is that a second thread could see emptyPC as not null
while the first thread is still initialising the data.
The fix is to contruct a "temp" propagation context that is only assigned
to emptyPC once it is fully initialised.
SInce this is just a cached object, it doesn't really matter if a few threads at the
start
of processing initialise emptyPC multiple times, the method is "idempotent".
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira