Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@ protected int require(int required) throws KryoException {
position = 0;
int bytesRead = 0;
int count;
while (true) {
while (bytesRead < required) {
count = fill(buffer, bytesRead, required - bytesRead);
Copy link
Contributor

Choose a reason for hiding this comment

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

@dannycranmer I saw this linked to in slack - I wondered whether we could have junits for the required case and higher than required? Maybe as a follow on issue / pr ? I could code if you were willing to merge for me?


if (count == -1) {
throw new KryoException(new EOFException("No more bytes left."));
}

bytesRead += count;
if (bytesRead == required) {
break;
}
}
limit = required;
return required;
Expand Down Expand Up @@ -121,18 +118,14 @@ public void readBytes(byte[] bytes, int offset, int count) throws KryoException
int bytesRead = 0;
int c;

while (true) {
while (bytesRead < count) {
c = inputStream.read(bytes, offset + bytesRead, count - bytesRead);

if (c == -1) {
throw new KryoException(new EOFException("No more bytes left."));
}

bytesRead += c;

if (bytesRead == count) {
break;
}
}
} catch (IOException ex) {
throw new KryoException(ex);
Expand Down