Skip to content

Commit 8be8c77

Browse files
Merge pull request #71 from iron-software/automate-merge-code
Copy from IronPolyglot on 2026-02-26
2 parents b8426f0 + a0f6f79 commit 8be8c77

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

IronPdf.SmokeTests/src/test/java/com/ironsoftware/ironpdf/RCTests2026_03.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.junit.jupiter.api.Assertions;
1414
import org.junit.jupiter.api.Test;
1515

16+
import java.io.ByteArrayOutputStream;
1617
import java.io.IOException;
1718
import java.io.InputStream;
1819
import java.nio.file.Files;
@@ -96,8 +97,14 @@ public final void Test01b_CompressToStream() throws IOException {
9697
byte[] originalBytes = pdf.getBinaryData();
9798

9899
InputStream compressedStream = pdf.compressPdfToStream();
99-
byte[] streamBytes = compressedStream.readAllBytes();
100+
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
101+
byte[] tmp = new byte[8192];
102+
int bytesRead;
103+
while ((bytesRead = compressedStream.read(tmp)) != -1) {
104+
buffer.write(tmp, 0, bytesRead);
105+
}
100106
compressedStream.close();
107+
byte[] streamBytes = buffer.toByteArray();
101108

102109
Assertions.assertTrue(streamBytes.length > 0, "Compressed stream should have content");
103110
Assertions.assertTrue(streamBytes.length <= originalBytes.length,

ironpdf/src/test/java/com/ironsoftware/ironpdf/RCTests2026_03.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.junit.jupiter.api.Assertions;
1414
import org.junit.jupiter.api.Test;
1515

16+
import java.io.ByteArrayOutputStream;
1617
import java.io.IOException;
1718
import java.io.InputStream;
1819
import java.nio.file.Files;
@@ -96,8 +97,14 @@ public final void Test01b_CompressToStream() throws IOException {
9697
byte[] originalBytes = pdf.getBinaryData();
9798

9899
InputStream compressedStream = pdf.compressPdfToStream();
99-
byte[] streamBytes = compressedStream.readAllBytes();
100+
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
101+
byte[] tmp = new byte[8192];
102+
int bytesRead;
103+
while ((bytesRead = compressedStream.read(tmp)) != -1) {
104+
buffer.write(tmp, 0, bytesRead);
105+
}
100106
compressedStream.close();
107+
byte[] streamBytes = buffer.toByteArray();
101108

102109
Assertions.assertTrue(streamBytes.length > 0, "Compressed stream should have content");
103110
Assertions.assertTrue(streamBytes.length <= originalBytes.length,

0 commit comments

Comments
 (0)