|
[
Permlink
| « Hide
]
Sebb added a comment - 10/Dec/07 03:16 PM
The easiest solution for _testOnBorrow and _testOnReturn is probably to make these volatile, in which case the get/set routines no longer need to be synchronized.
The report was generated by Findbugs. I've just re-run it against current trunk, and it shows the same errors (amongst others).
If the class is intended for use from multiple threads, then it is vital that all fields that can be updated in one thread and read in another are synchronised on the same object. The Findbugs report shows that some fields can be accessed without synchronisation. The Java memory model only guarantees that such accesses see the most recent value if the accesses to the field are all synch on the same object (or volatile is used). Synchronisation is necessary for visibility as well as mutual exclusion. In fact in this case, the fields are mainly primitive booleans, so synch is not needed for exclusion when updating. However it is needed for visibility between threads. Synchronization fixes committed for GenericObjectPool, GenericKeyedObjectPool, StackKeyedObjectPool in trunk r603451 and 1.4 release branch r603449.
The relevant classes in the 1.4 release branch have been patched address this issue. Leaving open for 2.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||