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

Changing isServerEncrypted parameter to Boolean to avoid NPE #32312

Merged
merged 7 commits into from
Dec 1, 2022

Conversation

ibrahimrabab
Copy link
Contributor

Description

resolves #32255

NullPointerException occurred due to null value passed in for isXMsRequestServerEncrypted. Changed to Boolean to handle nulls.

@ghost ghost added the Storage Storage Service (Queues, Blobs, Files) label Nov 24, 2022
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-storage-blob

@@ -31,7 +31,7 @@ public class BlockBlobItem {
* @param encryptionKeySha256 The encryption key used to encrypt the block blob.
*/
public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5,
final boolean isServerEncrypted, final String encryptionKeySha256) {
final Boolean isServerEncrypted, final String encryptionKeySha256) {
Copy link
Member

@alzimmermsft alzimmermsft Nov 28, 2022

Choose a reason for hiding this comment

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

This breaks the public API, instead my recommendation would be changing the code calling into this constructor to convert null to false (or true if that is the default for the service). Or, make all constructors taking boolean deprecated and add a new overload with Boolean that should be used.

Copy link
Member

Choose a reason for hiding this comment

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

I recommend new constructor with Boolean and deprecating old constructors. Since the value describes the state of the data as the FE tells us, I would not want to make assumptions as to the state of the data if the FE has failed to tell us for whatever reason. Since the getter returns Boolean already, this should be safe that it sometimes is null instead of an explicit value, as we are meant to communicate the server response.

@jaschrep-msft
Copy link
Member

If we're fixing a bug we should be adding tests to confirm the fix.

Copy link
Member

@jaschrep-msft jaschrep-msft left a comment

Choose a reason for hiding this comment

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

You should not be re-overloading every single constructor. These are additive constructors where we've been forced to add a new parameter. You should be adding only one new constructor to the bottom of this list, which has all the current parameters and uses Boolean instead of boolean. Then mark all the others as deprecated, as the use of boolean is potentially unsafe.

@ibrahimrabab
Copy link
Contributor Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jaschrep-msft jaschrep-msft left a comment

Choose a reason for hiding this comment

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

Small nitpick otherwise good

* @param encryptionScope The encryption scope used to encrypt the block blob.
* @param versionId The version identifier of the block blob.
*/
public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5,
Copy link
Member

Choose a reason for hiding this comment

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

adding this below the constructors instead of above will maintain the chronological progression of these constructors, making it easier to decipher later.

@ibrahimrabab ibrahimrabab enabled auto-merge (squash) December 1, 2022 19:21
@ibrahimrabab ibrahimrabab merged commit 1d481ad into Azure:main Dec 1, 2022
@ibrahimrabab ibrahimrabab deleted the blockBlobItemNPEFix branch December 1, 2022 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
4 participants