Skip to content

Commit

Permalink
check bytesRead
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed Nov 4, 2024
1 parent 047442b commit 643206b
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
*/
package org.apache.parquet.bytes;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.Channels;
Expand Down Expand Up @@ -380,7 +376,11 @@ void writeInto(ByteBuffer buffer) {
ReadableByteChannel channel = Channels.newChannel(in);
int remaining = byteCount;
while (remaining > 0) {
remaining -= channel.read(workBuf);
int bytesRead = channel.read(workBuf);
if (bytesRead < 0) {
throw new EOFException("Reached the end of stream with " + remaining + " bytes left to read");
}
remaining -= bytesRead;
}
buffer.position(pos + byteCount);
} catch (IOException e) {
Expand Down

0 comments on commit 643206b

Please sign in to comment.