[ 
https://issues.apache.org/jira/browse/POOL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12550393
 ] 

Sebb commented on POOL-113:
---------------------------

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.

> Inconsistent synch in InvalidEvictorLender, GenericKeyedObjectPool, 
> GenericObjectPool
> -------------------------------------------------------------------------------------
>
>                 Key: POOL-113
>                 URL: https://issues.apache.org/jira/browse/POOL-113
>             Project: Commons Pool
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 1.4
>
>         Attachments: InvalidEvictorLender.txt
>
>
> InvalidEvictorLender does not always synchronize referant field.
> Patch to follow - please check that the correct synch object is used.
> Similar problems apply to GenericKeyedObjectPool:
> Inconsistent synchronization of 
> org.apache.commons.pool.impl.GenericKeyedObjectPool._testOnBorrow; locked 66% 
> of time
> GenericKeyedObjectPool.java   line 913
> Inconsistent synchronization of 
> org.apache.commons.pool.impl.GenericKeyedObjectPool._testOnReturn; locked 66% 
> of time
> GenericKeyedObjectPool.java   line 1096
> And to GenericObjectPool:
> Inconsistent synchronization of 
> org.apache.commons.pool.impl.GenericObjectPool._testOnBorrow; locked 66% of 
> time
> GenericObjectPool.java        line 915
> Inconsistent synchronization of 
> org.apache.commons.pool.impl.GenericObjectPool._testOnReturn; locked 66% of 
> time
> GenericObjectPool.java        line 1017

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to