Browse Source

fix buffer

pull/7512/head
chrislu 2 weeks ago
parent
commit
c239150b53
  1. 7
      other/java/client/src/test/java/seaweedfs/client/SeaweedStreamIntegrationTest.java

7
other/java/client/src/test/java/seaweedfs/client/SeaweedStreamIntegrationTest.java

@ -128,10 +128,15 @@ public class SeaweedStreamIntegrationTest {
assertNotNull("Entry should not be null", entry); assertNotNull("Entry should not be null", entry);
SeaweedInputStream inputStream = new SeaweedInputStream(filerClient, testPath, entry); SeaweedInputStream inputStream = new SeaweedInputStream(filerClient, testPath, entry);
// Read file in chunks to handle large files properly
byte[] readData = new byte[fileSize]; byte[] readData = new byte[fileSize];
int totalRead = 0; int totalRead = 0;
int bytesRead; int bytesRead;
while ((bytesRead = inputStream.read(readData, totalRead, fileSize - totalRead)) > 0) {
byte[] buffer = new byte[8192]; // Read in 8KB chunks
while ((bytesRead = inputStream.read(buffer)) > 0) {
System.arraycopy(buffer, 0, readData, totalRead, bytesRead);
totalRead += bytesRead; totalRead += bytesRead;
} }
inputStream.close(); inputStream.close();

Loading…
Cancel
Save