Skip to content

Commit

Permalink
fix: throw NullPointerException when InboxEntryStream.EntryStreamList…
Browse files Browse the repository at this point in the history
…ener.onNextChunkRequest returns null during sending file (#4)
  • Loading branch information
djenczewski committed Dec 6, 2024
1 parent ed3bb00 commit 45aa509
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public synchronized void sendFiles(
}
}));
});
System.out.println("Start waiting 2");
for (Future<?> future : sendingFiles) {
if (Thread.interrupted()) {
cancel();
Expand All @@ -140,8 +139,7 @@ public synchronized void sendFiles(
// catch when in async mode someone call cancel on result Future.
cancel();
return;
} catch (Exception e) {
System.out.println("Break waiting on other exception");
} catch (Exception ignore) {
}
}
if (sendingFiles.stream().allMatch(Future::isDone)) {
Expand Down Expand Up @@ -173,7 +171,11 @@ public void onChunkProcessed(Long processedBytes) {
if (controller.isStopped()) {
break;
}
fileHandle.write(inboxHandle, entryStreamListener.onNextChunkRequest(fileInfo));
byte[] nextChunk = entryStreamListener.onNextChunkRequest(fileInfo);
if (nextChunk == null) {
throw new NullPointerException("Data chunk cannot be null");
}
fileHandle.write(inboxHandle, nextChunk);
}
} else {
fileHandle.writeStream(inboxHandle, fileInfo.fileStream, controller);
Expand Down

0 comments on commit 45aa509

Please sign in to comment.