Skip to content

Commit

Permalink
read till end-of-file
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsanjay committed Mar 30, 2024
1 parent 4c16404 commit 19ec489
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,9 @@ private int fetchPackets(FastInputStream fis) throws Exception {
boolean isContentReceived = false;
try {
while (true) {
if(fis.peek() == -1){
return NO_CONTENT;
}
if (stop) {
stop = false;
aborted = true;
Expand All @@ -1825,13 +1828,11 @@ private int fetchPackets(FastInputStream fis) throws Exception {
long checkSumServer = -1;

fis.readFully(intbytes);

// read the size of the packet
int packetSize = readInt(intbytes);
if (packetSize <= 0) {
fis.read(); // read till end-of-file

This comment has been minimized.

Copy link
@dsmiley

dsmiley Mar 30, 2024

Contributor

The peek() would seem to best belong here not at the head of the loop. Is there another scenario that would be missed?
BTW peek has no javadocs; can you add a little something to signify that -1 means EOF?

if (!isContentReceived) log.warn("No content received for file: {}", fileName);
return NO_CONTENT;
continue;
}
isContentReceived = true;
// TODO consider recoding the remaining logic to not use/need buf[]; instead use the
Expand Down

0 comments on commit 19ec489

Please sign in to comment.