-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
24e86f0
changing isServerEncrypted parameter to Boolean to avoid NPE
ibrahimrabab 7488687
deprecating previous constructors that used boolean instead of Boolean
ibrahimrabab 82dea2e
fixing indentation
ibrahimrabab f4e3858
adding test to handle x-ms-request-server-encrypted returned as null
ibrahimrabab caef629
using LiveOnly to see if test passes
ibrahimrabab 4953b35
adding basic test to verify if BlockBlobItem handles null values
ibrahimrabab e1dd61a
moving newly added constructor to the bottom
ibrahimrabab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, null); | ||
} | ||
|
||
|
@@ -46,7 +46,7 @@ public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final | |
* @param encryptionScope The encryption scope used to encrypt the block blob. | ||
*/ | ||
public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, | ||
final boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope) { | ||
final Boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope) { | ||
this(eTag, lastModified, contentMd5, isServerEncrypted, encryptionKeySha256, encryptionScope, null); | ||
} | ||
|
||
|
@@ -62,8 +62,8 @@ public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final | |
* @param versionId The version identifier of the block blob. | ||
*/ | ||
public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
final boolean isServerEncrypted, final String encryptionKeySha256, | ||
final String encryptionScope, final String versionId) { | ||
final Boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, | ||
final String versionId) { | ||
this.eTag = eTag; | ||
this.lastModified = lastModified; | ||
this.contentMd5 = CoreUtils.clone(contentMd5); | ||
|
@@ -73,6 +73,58 @@ public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final | |
this.versionId = versionId; | ||
} | ||
|
||
/** | ||
* Constructs a {@link BlockBlobItem}. | ||
* | ||
* @param eTag ETag of the block blob. | ||
* @param lastModified Last modified time of the block blob. | ||
* @param contentMd5 Content MD5 of the block blob. | ||
* @param isServerEncrypted Flag indicating if the block blob is encrypted on the server. | ||
* @param encryptionKeySha256 The encryption key used to encrypt the block blob. | ||
* @deprecated Use {@link #BlockBlobItem(String, OffsetDateTime, byte[], Boolean, String)} instead. | ||
*/ | ||
@Deprecated | ||
public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, | ||
final boolean isServerEncrypted, final String encryptionKeySha256) { | ||
this(eTag, lastModified, contentMd5, (Boolean) isServerEncrypted, encryptionKeySha256); | ||
} | ||
|
||
/** | ||
* Constructs a {@link BlockBlobItem}. | ||
* | ||
* @param eTag ETag of the block blob. | ||
* @param lastModified Last modified time of the block blob. | ||
* @param contentMd5 Content MD5 of the block blob. | ||
* @param isServerEncrypted Flag indicating if the block blob is encrypted on the server. | ||
* @param encryptionKeySha256 The encryption key used to encrypt the block blob. | ||
* @param encryptionScope The encryption scope used to encrypt the block blob. | ||
* @deprecated Use {@link #BlockBlobItem(String, OffsetDateTime, byte[], Boolean, String, String)} instead. | ||
*/ | ||
@Deprecated | ||
public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, | ||
final boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope) { | ||
this(eTag, lastModified, contentMd5, (Boolean) isServerEncrypted, encryptionKeySha256, encryptionScope); | ||
} | ||
|
||
/** | ||
* Constructs a {@link BlockBlobItem}. | ||
* | ||
* @param eTag ETag of the block blob. | ||
* @param lastModified Last modified time of the block blob. | ||
* @param contentMd5 Content MD5 of the block blob. | ||
* @param isServerEncrypted Flag indicating if the block blob is encrypted on the server. | ||
* @param encryptionKeySha256 The encryption key used to encrypt the block blob. | ||
* @param encryptionScope The encryption scope used to encrypt the block blob. | ||
* @param versionId The version identifier of the block blob. | ||
* @deprecated Use {@link #BlockBlobItem(String, OffsetDateTime, byte[], Boolean, String, String, String)} instead. | ||
*/ | ||
@Deprecated | ||
public BlockBlobItem(final String eTag, final OffsetDateTime lastModified, final byte[] contentMd5, | ||
final boolean isServerEncrypted, final String encryptionKeySha256, final String encryptionScope, | ||
final String versionId) { | ||
this(eTag, lastModified, contentMd5, (Boolean) isServerEncrypted, encryptionKeySha256, encryptionScope, versionId); | ||
} | ||
|
||
/** | ||
* @return the eTag of the block blob | ||
*/ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 withBoolean
that should be used.There was a problem hiding this comment.
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 returnsBoolean
already, this should be safe that it sometimes is null instead of an explicit value, as we are meant to communicate the server response.