Skip to content

Commit

Permalink
Iterating on the approach to avoid hangs during Accessor initializati…
Browse files Browse the repository at this point in the history
…on (#28961)

* Iterating on the approach to avoid hangs during Accessor initialization

* Updating changelogs

* Update ImplementationBridgeHelpers.java
  • Loading branch information
FabianMeiswinkel authored May 20, 2022
1 parent e7bc664 commit 32c82ef
Show file tree
Hide file tree
Showing 28 changed files with 282 additions and 231 deletions.
2 changes: 1 addition & 1 deletion sdk/cosmos/azure-cosmos-spark_3-1_2-12/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#### Bugs Fixed
* Fixed an issue with creating new Throughput control client item when `enableThroughputControlGroup` is being called multiple times with the same throughput control group. - See [PR 28905](https://github.com/Azure/azure-sdk-for-java/pull/28905)
* Fixed a possible dead-lock on static ctor for CosmosException when the runtime is using custom class loaders. - See [PR 28912](https://github.com/Azure/azure-sdk-for-java/pull/28912)
* Fixed a possible dead-lock on static ctor for CosmosException when the runtime is using custom class loaders. - See [PR 28912](https://github.com/Azure/azure-sdk-for-java/pull/28912) and [PR 28961](https://github.com/Azure/azure-sdk-for-java/pull/28961)

#### Other Changes
* Changed 429 (Throttling) retry policy to have an upper bound for the back-off time of 5 seconds - See [PR 28764](https://github.com/Azure/azure-sdk-for-java/pull/28764)
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure-cosmos-spark_3-2_2-12/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#### Bugs Fixed
* Fixed an issue with creating new Throughput control client item when `enableThroughputControlGroup` is being called multiple times with the same throughput control group. - See [PR 28905](https://github.com/Azure/azure-sdk-for-java/pull/28905)
* Fixed a possible dead-lock on static ctor for CosmosException when the runtime is using custom class loaders. - See [PR 28912](https://github.com/Azure/azure-sdk-for-java/pull/28912)
* Fixed a possible dead-lock on static ctor for CosmosException when the runtime is using custom class loaders. - See [PR 28912](https://github.com/Azure/azure-sdk-for-java/pull/28912) and [PR 28961](https://github.com/Azure/azure-sdk-for-java/pull/28961)

#### Other Changes
* Changed 429 (Throttling) retry policy to have an upper bound for the back-off time of 5 seconds - See [PR 28764](https://github.com/Azure/azure-sdk-for-java/pull/28764)
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#### Bugs Fixed
* Fixed bubbling of Errors in case of any `java.lang.Error` - See [PR 28620](https://github.com/Azure/azure-sdk-for-java/pull/28620)
* Fixed an issue with creating new Throughput control client item when `enableThroughputControlGroup` is being called multiple times with the same throughput control group. - See [PR 28905](https://github.com/Azure/azure-sdk-for-java/pull/28905)
* Fixed a possible dead-lock on static ctor for CosmosException when the runtime is using custom class loaders. - See [PR 28912](https://github.com/Azure/azure-sdk-for-java/pull/28912)
* Fixed a possible dead-lock on static ctor for CosmosException when the runtime is using custom class loaders. - See [PR 28912](https://github.com/Azure/azure-sdk-for-java/pull/28912) and [PR 28961](https://github.com/Azure/azure-sdk-for-java/pull/28961)

#### Other Changes
* Added `exceptionMessage` and `exceptionResponseHeaders` to `CosmosDiagnostics` in case of any exceptions - See [PR 28620](https://github.com/Azure/azure-sdk-for-java/pull/28620)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,15 @@ String getLink() {
}

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
ImplementationBridgeHelpers.CosmosAsyncClientEncryptionKeyHelper.setCosmosAsyncClientEncryptionKeyAccessor(
new ImplementationBridgeHelpers.CosmosAsyncClientEncryptionKeyHelper.CosmosAsyncClientEncryptionKeyAccessor() {

@Override
public Mono<CosmosClientEncryptionKeyResponse> readClientEncryptionKey(CosmosAsyncClientEncryptionKey cosmosAsyncClientEncryptionKey, RequestOptions requestOptions) {
return cosmosAsyncClientEncryptionKey.read(requestOptions);
}
});
(cosmosAsyncClientEncryptionKey, requestOptions) -> cosmosAsyncClientEncryptionKey.read(requestOptions));
}

static { initialize(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -1721,20 +1721,15 @@ public void enableGlobalThroughputControlGroup(
///////////////////////////////////////////////////////////////////////////////////////////

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
ImplementationBridgeHelpers.CosmosAsyncContainerHelper.setCosmosAsyncContainerAccessor(
new ImplementationBridgeHelpers.CosmosAsyncContainerHelper.CosmosAsyncContainerAccessor() {
@Override
public <T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryChangeFeedInternalFunc(CosmosAsyncContainer cosmosAsyncContainer,
CosmosChangeFeedRequestOptions cosmosChangeFeedRequestOptions,
Class<T> classType) {
return cosmosAsyncContainer.queryChangeFeedInternalFunc(cosmosChangeFeedRequestOptions, classType);
}
});
CosmosAsyncContainer::queryChangeFeedInternalFunc);
}

static { initialize(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -1080,12 +1080,12 @@ private Mono<ThroughputResponse> readThroughputInternal(Mono<CosmosDatabaseRespo
///////////////////////////////////////////////////////////////////////////////////////////

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
ImplementationBridgeHelpers.CosmosAsyncDatabaseHelper.setCosmosAsyncDatabaseAccessor(
new ImplementationBridgeHelpers.CosmosAsyncDatabaseHelper.CosmosAsyncDatabaseAccessor() {

Expand All @@ -1100,4 +1100,6 @@ public String getLink(CosmosAsyncDatabase cosmosAsyncDatabase) {
}
});
}

static { initialize(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,15 @@ public GlobalThroughputControlConfigBuilder createGlobalThroughputControlConfigB
}

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
ImplementationBridgeHelpers.CosmosClientHelper.setCosmosClientAccessor(
cosmosClient -> cosmosClient.asyncClient());
}

static { initialize(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,12 @@ private void ifThrowIllegalArgException(boolean value, String error) {
///////////////////////////////////////////////////////////////////////////////////////////

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
CosmosClientBuilderHelper.setCosmosClientBuilderAccessor(
new CosmosClientBuilderHelper.CosmosClientBuilderAccessor() {

Expand Down Expand Up @@ -908,4 +908,6 @@ public ConsistencyLevel getConsistencyLevel(CosmosClientBuilder builder) {
}
});
}

static { initialize(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ private AtomicBoolean isDiagnosticsCapturedInPagedFlux(){
///////////////////////////////////////////////////////////////////////////////////////////

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
ImplementationBridgeHelpers.CosmosDiagnosticsHelper.setCosmosDiagnosticsAccessor(
new ImplementationBridgeHelpers.CosmosDiagnosticsHelper.CosmosDiagnosticsAccessor() {
@Override
Expand All @@ -190,4 +190,6 @@ public AtomicBoolean isDiagnosticsCapturedInPagedFlux(CosmosDiagnostics cosmosDi
}
});
}

static { initialize(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -547,19 +547,15 @@ void setRntbdPendingRequestQueueSize(int rntbdPendingRequestQueueSize) {
///////////////////////////////////////////////////////////////////////////////////////////

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
ImplementationBridgeHelpers.CosmosExceptionHelper.setCosmosExceptionAccessor(
new ImplementationBridgeHelpers.CosmosExceptionHelper.CosmosExceptionAccessor() {

@Override
public CosmosException createCosmosException(int statusCode, Exception innerException) {
return new CosmosException(statusCode, innerException);
}
});
(statusCode, innerException) -> new CosmosException(statusCode, innerException));
}

static { initialize(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ public String toString() {
///////////////////////////////////////////////////////////////////////////////////////////

/**
* Should not be called form user-code. This method is a no-op and is just used internally
* Should not be called from user-code. This method is a no-op and is just used internally
* to force loading this class
*/
public static void doNothingButEnsureLoadingClass() {}
public static void doNothingButEnsureLoadingClass() { initialize(); }

static {
private static void initialize() {
ImplementationBridgeHelpers.DirectConnectionConfigHelper.setDirectConnectionConfigAccessor(
new ImplementationBridgeHelpers.DirectConnectionConfigHelper.DirectConnectionConfigAccessor() {
@Override
Expand All @@ -348,4 +348,6 @@ public DirectConnectionConfig setIoThreadPriority(DirectConnectionConfig config,
}
});
}

static { initialize(); }
}
Loading

0 comments on commit 32c82ef

Please sign in to comment.