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.

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

Commit messages:
 - Update BeanContextSupport.java
 - 8238170: BeanContextSupport remove and propertyChange can deadlock

Changes: https://git.openjdk.org/jdk/pull/12158/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12158&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8238170
  Stats: 158 lines in 3 files changed: 147 ins; 0 del; 11 mod
  Patch: https://git.openjdk.org/jdk/pull/12158.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12158/head:pull/12158

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

Reply via email to