Skip to content

Commit

Permalink
Removing Class.forName for implementation bridge helpers (Azure#28912)
Browse files Browse the repository at this point in the history
* improvement for CosmosExceptionHelper

* update log message

* Removing Class.forName for implementation bridge helpers

* Added changelog

* Update spotbugs-exclude.xml

* Update spotbugs-exclude.xml

* Adding API comments

* Update CHANGELOG.md

Co-authored-by: annie-mac <[email protected]>
  • Loading branch information
FabianMeiswinkel and annie-mac authored May 17, 2022
1 parent 7c78689 commit 2a25c89
Show file tree
Hide file tree
Showing 30 changed files with 544 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,37 @@
MS_SHOULD_BE_FINAL"/>
</Match>

<Match>
<Or>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosAsyncClientEncryptionKeyHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosAsyncContainerHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosAsyncDatabaseHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosBatchHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosBatchOperationResultHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosBatchRequestOptionsHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosBatchResponseHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosBulkExecutionOptionsHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosBulkExecutionThresholdsStateHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosBulkItemResponseHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosChangeFeedRequestOptionsHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosClientBuilderHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosClientHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosContainerPropertiesHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosDiagnosticsHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosExceptionHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosItemRequestOptionsHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosItemResponseHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosPageFluxHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosPatchOperationsHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$CosmosQueryRequestOptionsHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$DirectConnectionConfigHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$FeedResponseHelper"/>
<Class name="com.azure.cosmos.implementation.ImplementationBridgeHelpers$PartitionKeyHelper"/>
</Or>
<Bug pattern="DM_EXIT"/>
</Match>

<!-- Empty byte array is returned as null to reactor. Reactor transform null from Callable to downstream onComplete -->
<Match>
<Class name="~com\.azure\.core\.http\.okhttp\.implementation\.OkHttpAsyncResponse(.*)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class CosmosEncryptionClient implements Closeable {

CosmosEncryptionClient(CosmosClient cosmosClient, KeyEncryptionKeyResolver keyEncryptionKeyResolver,
String keyEncryptionKeyResolverName) {
this.cosmosClientAccessor = CosmosClientHelper.geCosmosClientAccessor();
this.cosmosClientAccessor = CosmosClientHelper.getCosmosClientAccessor();
this.keyEncryptionKeyResolver = keyEncryptionKeyResolver;
this.cosmosClient = cosmosClient;
this.cosmosAsyncClient = this.cosmosClientAccessor.getCosmosAsyncClient(cosmosClient);
Expand Down
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos-spark_3-1_2-12/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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)

#### 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
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos-spark_3-2_2-12/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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)

#### 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: 2 additions & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#### 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)


#### 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 @@ -110,6 +110,12 @@ String getLink() {
return builder.toString();
}

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

static {
ImplementationBridgeHelpers.CosmosAsyncClientEncryptionKeyHelper.setCosmosAsyncClientEncryptionKeyAccessor(
new ImplementationBridgeHelpers.CosmosAsyncClientEncryptionKeyHelper.CosmosAsyncClientEncryptionKeyAccessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,12 @@ public void enableGlobalThroughputControlGroup(
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////

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

static {
ImplementationBridgeHelpers.CosmosAsyncContainerHelper.setCosmosAsyncContainerAccessor(
new ImplementationBridgeHelpers.CosmosAsyncContainerHelper.CosmosAsyncContainerAccessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,12 @@ private Mono<ThroughputResponse> readThroughputInternal(Mono<CosmosDatabaseRespo
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////

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

static {
ImplementationBridgeHelpers.CosmosAsyncDatabaseHelper.setCosmosAsyncDatabaseAccessor(
new ImplementationBridgeHelpers.CosmosAsyncDatabaseHelper.CosmosAsyncDatabaseAccessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ public GlobalThroughputControlConfigBuilder createGlobalThroughputControlConfigB
return new GlobalThroughputControlConfigBuilder(this.asyncClientWrapper, databaseId, containerId);
}

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

static {
ImplementationBridgeHelpers.CosmosClientHelper.setCosmosClientAccessor(
cosmosClient -> cosmosClient.asyncClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,12 @@ private void ifThrowIllegalArgException(boolean value, String error) {
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////

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

static {
CosmosClientBuilderHelper.setCosmosClientBuilderAccessor(
new CosmosClientBuilderHelper.CosmosClientBuilderAccessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ private AtomicBoolean isDiagnosticsCapturedInPagedFlux(){
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////

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

static {
ImplementationBridgeHelpers.CosmosDiagnosticsHelper.setCosmosDiagnosticsAccessor(
new ImplementationBridgeHelpers.CosmosDiagnosticsHelper.CosmosDiagnosticsAccessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ void setRntbdPendingRequestQueueSize(int rntbdPendingRequestQueueSize) {
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////

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

static {
ImplementationBridgeHelpers.CosmosExceptionHelper.setCosmosExceptionAccessor(
new ImplementationBridgeHelpers.CosmosExceptionHelper.CosmosExceptionAccessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ public String toString() {
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////

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

static {
ImplementationBridgeHelpers.DirectConnectionConfigHelper.setDirectConnectionConfigAccessor(
new ImplementationBridgeHelpers.DirectConnectionConfigHelper.DirectConnectionConfigAccessor() {
Expand Down
Loading

0 comments on commit 2a25c89

Please sign in to comment.