fix: optimize resumable uploads to allow sending bytes during finalization#2146
Merged
BenWhitehead merged 1 commit intomainfrom Jul 31, 2023
Merged
fix: optimize resumable uploads to allow sending bytes during finalization#2146BenWhitehead merged 1 commit intomainfrom
BenWhitehead merged 1 commit intomainfrom
Conversation
BenWhitehead
commented
Jul 28, 2023
| if (exception instanceof IllegalArgumentException) { | ||
| IllegalArgumentException illegalArgumentException = (IllegalArgumentException) exception; | ||
| if (illegalArgumentException.getMessage().equals("no JSON input found")) { | ||
| if ("no JSON input found".equals(illegalArgumentException.getMessage())) { |
Collaborator
Author
There was a problem hiding this comment.
Move the constant to the left side to avoid NullPointerException if there is ever an IllegalArgumentException which doesn't have a message.
4e299bd to
c710b7b
Compare
…ization Add new methods to UnbufferedWritableByteChannel to allow writing and closing in a single call * writeAndClose(ByteBuffer) * writeAndClose(ByteBuffer[]) * writeAndClose(ByteBuffer[], int, int) Update grpc and json implementation to leverage new methods and to write and finalize in the same call. DefaultBufferedWritableByteChannel will use the new methods as appropriate.
c710b7b to
78f8ca9
Compare
frankyn
reviewed
Jul 31, 2023
| @Override | ||
| default int write(ByteBuffer src) throws IOException { | ||
| return Math.toIntExact(write(new ByteBuffer[] {src})); | ||
| return Math.toIntExact(write(new ByteBuffer[] {src}, 0, 1)); |
Contributor
There was a problem hiding this comment.
Does 0, 1 represent there's only 1 buffer right now?
Collaborator
Author
There was a problem hiding this comment.
Correct. These values represent the index to start from in the provided array and how many indices to consume.
This is reducing a stack entry where before it would do write(ByteBuffer) -> write(ByteBuffer[]) -> write(ByteBuffer[], int, int). While logically equivalent (and the JVM can probably inline the method to reduce impact anyway) doing this makes sure we don't add another stack frame.
frankyn
approved these changes
Jul 31, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add new methods to UnbufferedWritableByteChannel to allow writing and closing in a single call
Update grpc and json implementation to leverage new methods and to write and finalize in the same call.
DefaultBufferedWritableByteChannel will use the new methods as appropriate.