Menu

#43 Multiple instantiation of WiredContainer

open
nobody
5
2008-08-13
2008-08-13
No

the WiredContainer can be instantiated multiple times in a webservice environment with many parallel threads.
This is due to two code-blocks which are not synchronized.

1.) WSAdapter - this class holds a static member for a WiredClientContext. But the initialisation of this variable is not synchronized.

2.) WiredClientContext - this class holds a static member "defaultContainer", which is a WiredContainer. The creation of this WiredContainer is also not synchronized

If more than one Thread executes these code-blocks at a time, the WiredContainer can be created more than once.

This behaviour would be no problem if a thread used the same WiredContainer for the whole call chain, e.g. from entry into the WiredContainer till exit of the container. But due to currently unknown reasons the Thread switches its WiredContainer during the execution of the call chain. This causes some severe problems. The WiredContainer holds the AllocationManager (that means resource and transaction management) in a ThreadLocal. If a Thread switches its container the AllocationManager is not available for the Thread.

The consequence of this behaviour is that SQL-Statements can run outside of a transaction-scope although a TX-attribute is specified.

Discussion


Log in to post a comment.