You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I am getting a false positive AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE for a long instance varibale update in a private method only called by synchronized methods.
[INFO] --- spotbugs:4.9.3.0:check (default-cli) @ commons-pool3 ---
[INFO] BugInstance size is 1
[INFO] Error size is 0
[INFO] Total bugs: 1
[ERROR] Medium: Operation on the "destroyCount" shared variable in "SoftReferenceObjectPool" class is not atomic [org.apache.commons.pool3.impl.SoftReferenceObjectPool] At SoftReferenceObjectPool.java:[line 269] AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE
[INFO]
The instance variable org.apache.commons.pool3.impl.SoftReferenceObjectPool.destroyCount is updated at line 269 in the private method org.apache.commons.pool3.impl.SoftReferenceObjectPool.destroy(PooledSoftReference<T>), and that private method is only called from synchronized methods:
addObject()
borrowObject()
invalidateObject((T)
returnObject(T)
Once the synchronized methods exit, the updated destroyCount value is visible to other threads, which is why this looks like an FP.
The toString() method only reads the destroyCount value.