Commit 02898e7
Fix JVM <clinit> deadlock in Cosmos SDK accessor initialization
Replace broad initializeAllAccessors() fallback calls in each
getXxxAccessor() method with targeted Class.forName() that loads only
the specific class registering that accessor. This eliminates the
circular class initialization dependency chain that caused permanent
JVM-level deadlocks when multiple threads concurrently triggered
Cosmos SDK class loading for the first time.
Root cause: When any getXxxAccessor() found its accessor unset, it
called initializeAllAccessors() which eagerly loaded 40+ classes via
ModelBridgeInternal, UtilBridgeInternal, and BridgeInternal. If two
threads entered different <clinit> methods simultaneously, the JVM
class initialization monitors created an AB/BA deadlock that was
permanent and unrecoverable.
Fix: Each of the 35 getXxxAccessor() methods now calls
ensureClassInitialized() with just the fully-qualified name of the
class that registers that specific accessor. This dramatically
narrows the class loading scope per accessor call, making circular
dependencies practically impossible.
The public initializeAllAccessors() method is preserved for explicit
eager bootstrap use cases (e.g., Kafka connector, Spring @PostConstruct
workaround).
Fixes: #48622
Fixes: #48585
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 3a6b4a5 commit 02898e7
2 files changed
Lines changed: 57 additions & 38 deletions
File tree
- sdk/cosmos/azure-cosmos
- src/main/java/com/azure/cosmos/implementation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
0 commit comments