-
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
fixes for enforce final fields checkstyle rule - Azure Storage #5010
fixes for enforce final fields checkstyle rule - Azure Storage #5010
Conversation
* Move Storage to official swagger files There are no (meaningful) code changes except the attribute in BlobHierarchyListSegment that I can't trace to the swagger * Upgrade blobs swagger to 2019-02-02 Note that additional work will have to be done to patch our higher level code to pass new parameters to existing APIs * Fixes to Swagger generation and updating to use new protocol layer * Fixed appendBlock content-type, added SpotBug exclusions for autogen code * Update README.md * Fixed incorrect exclude
* Migrate queue to spock test framework * Remove all Junit tests and dependencies
} | ||
|
||
this.internalWriteThreshold = (int) BlockBlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE; | ||
this(parentBlob, accessCondition != null ? new BlobAccessConditions().modifiedAccessConditions( |
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 is hard to discern. I wouldn't add the constructor above.
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.
yeah, this was one of the most annoying classes to fix XD
Constructor sets fields based on multiple conditions.
I added the private constructor to make sure all fields are always assigned so fields can be final
without duplicating the code in each constructor.
The other option is to add private method that set fields but that would make fields not final
Options here are:
- Update code to make fields not final by adding private methods to set fields. This will simplify constructor logic
- Add some code duplicity for assigning fields in two constructors to enhance readability for this constructor.
- Avoid code duplicity by adding hard-to-discern calls (like it is right now)
- Create a ticket and assign to some code owner to decide what he/she wants to do and assign a suppress rule for it
- Any other idea is welcome
what do you think @conniey
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 makes it hard to read. There are several ternary operators here and not clear what it's doing. Given that it's calling another overloaded constructor, you can't have any other statements before calling this()
either. So, I would lean towards making it readable/maintainable even if that results in a tiny bit of code duplication.
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 could be a case to break this down into four classes, one which handles the interface/abstract methods, and three more which implement that for each individual use case.
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.
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 made a mistake while trying to fix this PR and had it all wrong.
PR got closed after deleting branch from origin
I created a new one as this one should have been #5022
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.
LGTM, ignoring the issue Connie raises. Once that is fixed to her satisfaction, this can be merged.
this.streamType = BlobType.BLOCK_BLOB; | ||
this.internalWriteThreshold = (int) BlockBlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE; | ||
this(parentBlob, accessCondition, null, UUID.randomUUID().toString() + "-", new TreeMap<>(), 0, | ||
BlobType.BLOCK_BLOB, BlockBlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE); |
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.
The last argument is BlockBlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE
, but the argument name is internalWriteThreshold
. I can see this is what used to be there, but it is weird naming? // @alzimmermsft
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.
It's the threshold used until another page, block, etc is requested. Maybe this could be renamed to bufferSize? Could just remove the internal and have writeThreshold.
// .doOnComplete(() -> completionSink.complete()); | ||
private BlobOutputStream(final BlobAsyncClient blobClient, final BlobAccessConditions accessCondition, | ||
final AppendPositionAccessConditions appendPositionAccessConditions, | ||
final String blockIdPrefix, final TreeMap<Long, String> blockList, |
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.
Does it have to be a TreeMap
? Can a Map
be used instead?
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.
@jianghaolu was TreeMap used to maintain some ordering?
|
||
/** | ||
* Used for block blobs, holds the block list. | ||
*/ | ||
private TreeMap<Long, String> blockList; | ||
private final TreeMap<Long, String> blockList; |
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.
It's not related to this PR but curious if Map
can be used instead? Also, why is it called a list?
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.
It's called blockList given that it is used by BlockBlob's Put Blob List method. Given that this is the property on the class this can be changed to Map.
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.
How do we like to handle this? Do you want me to update the name as part of this same PR? or should we create a new issue to request this change to have an independent commit for that refactoring?
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.
Issue created. Since there is more things to address than just names or type updating
#5021
} | ||
|
||
this.internalWriteThreshold = (int) BlockBlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE; | ||
this(parentBlob, accessCondition != null ? new BlobAccessConditions().modifiedAccessConditions( |
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 makes it hard to read. There are several ternary operators here and not clear what it's doing. Given that it's calling another overloaded constructor, you can't have any other statements before calling this()
either. So, I would lean towards making it readable/maintainable even if that results in a tiny bit of code duplication.
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.
LGTM, just need to resolve the questions.
…literals usage (#4994) * Adding javaDoc formating rule * Adding fixes for javadoc formatting
No description provided.