Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making CosmosPatchOperations thread-safe #29143

Conversation

FabianMeiswinkel
Copy link
Member

@FabianMeiswinkel FabianMeiswinkel commented May 30, 2022

Description

CosmosPatchOperations is not thread-safe - this can result in NullPointerExceptions (see below) when customers do patch operations (point operation on single document) and add path instructions concurrently from multiple threads.

java.lang.NullPointerException: null
        at com.azure.cosmos.implementation.patch.PatchUtil.cosmosPatchToJsonSerializable(PatchUtil.java:43)
        at com.azure.cosmos.implementation.patch.PatchUtil.serializeCosmosPatchToByteArray(PatchUtil.java:22)
        at com.azure.cosmos.implementation.RxDocumentClientImpl.patchDocumentInternal(RxDocumentClientImpl.java:1914)
        at com.azure.cosmos.implementation.RxDocumentClientImpl.lambda$patchDocument$46(RxDocumentClientImpl.java:1896)
        at com.azure.cosmos.implementation.ObservableHelper.lambda$inlineIfPossibleAsObs$1(ObservableHelper.java:44)
        at com.azure.cosmos.implementation.BackoffRetryUtility.lambda$executeRetry$0(BackoffRetryUtility.java:36)

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

Copy link
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the quick fix 👍

@FabianMeiswinkel FabianMeiswinkel merged commit 240243e into Azure:main Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants