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
Address review: add missing static{initialize()} blocks, improve test
- Add 'static { initialize(); }' to CosmosRequestContext,
CosmosOperationDetails, and CosmosDiagnosticsContext which had
initialize() methods but no <clinit> invocation, so Class.forName()
alone would not register their accessors.
- Improve regression test: assert accessor return values are non-null,
catch ExecutionException for clearer failure messages, and document
the inherent <clinit>-once-per-JVM limitation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/ImplementationBridgeHelpersTest.java
+16-9Lines changed: 16 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -116,9 +116,13 @@ public void concurrentAccessorInitializationShouldNotDeadlock() throws Exception
116
116
// and https://github.com/Azure/azure-sdk-for-java/issues/48585
117
117
//
118
118
// Verifies that concurrently calling different getXxxAccessor() methods from
119
-
// multiple threads completes without deadlock. Before the fix, each getter
120
-
// called initializeAllAccessors() which eagerly loaded 40+ classes, creating
121
-
// circular <clinit> dependencies that permanently deadlocked the JVM.
119
+
// multiple threads completes without deadlock and returns non-null accessors.
120
+
//
121
+
// Limitation: Since JVM <clinit> runs exactly once per class per JVM lifetime,
122
+
// this in-process test validates accessor re-registration after a reflection
123
+
// reset — not the actual first-load <clinit> deadlock scenario. The real
124
+
// deadlock validation was performed via a 50-run fresh-JVM stress test
0 commit comments