RFR: 8238170: BeanContextSupport remove and propertyChange can deadlock

Paul Hohensee phh at openjdk.org
Wed Jan 25 21:13:20 UTC 2023


On Tue, 24 Jan 2023 03:15:50 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> Two methods in the BeanContextSupport class use two locks in a different order, which can cause a deadlock. 
> 
> Here is the first order: (1) first acquire BeanContext.globalHierarchyLock and then children:
> 
>     enter public method remove(Object) at line 484
>     call remove(Object, boolean) at line 485
>     acquire synchronization on BeanContext.globalHierarchyLock at line 502
>     acquire synchronization on children at line 534
> 
> Here is the second order: (2) first acquire children and then BeanContext.globalHierarchyLock:
> 
>     enter public method propertyChange() at line 1110
>     acquire synchronization on children at line 1114
>     call remove(Object, boolean) at line 1121
>     acquire synchronization on BeanContext.globalHierarchyLock at line 502 
> 
> The fix added the "BeanContext.globalHierarchyLock" before the usage of the "children" lock in the propertyChange method.

Lgtm.

Pre-submit 32-bit linux build errors appear unrelated.

-------------

Marked as reviewed by phh (Reviewer).

PR: https://git.openjdk.org/jdk/pull/12158



More information about the client-libs-dev mailing list