- Notifications
You must be signed in to change notification settings - Fork46
flattened out that do/while loop that only ran once in DataChannelRer…#778
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| byteBuffer.clear(); | ||
| channel.position(0); | ||
| intn =channel.read(byteBuffer); | ||
| if (n == -1) { |
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 think this branch should handle then == 0 case as well. I'm not sure when would this happen, but if it happens then the code below will break (bytes[-1] is invalid).
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 is not a bad idea.
I will merge this version and later we will refine with that idea
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 was already added:c1b7897 (later commit in this PR)
| }while (n <=0); | ||
| byteBuffer.clear(); | ||
| channel.position(0); | ||
| intn =channel.read(byteBuffer); |
JakubVanekDec 30, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Theposition() +read() calls can be merged together:
| intn =channel.read(byteBuffer,0); |
EDIT: javadocs:https://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#read(java.nio.ByteBuffer,%20long)
…d tightened up the readString method - Jakub's review comments
No description provided.