This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git
The following commit(s) were added to refs/heads/master by this push:
new f5505610 [CODEC-334] Add tests in Base64OutputStreamTest
f5505610 is described below
commit f55056104a73b19f978a67cebdffaac1f7320b6c
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Mar 12 07:48:21 2026 -0400
[CODEC-334] Add tests in Base64OutputStreamTest
---
.../codec/binary/Base64OutputStreamTest.java | 30 ++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git
a/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
b/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
index 058e7ac3..6e4df673 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
@@ -25,10 +25,14 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import org.apache.commons.codec.CodecPolicy;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
/**
* Tests {@link Base64OutputStream}.
@@ -275,6 +279,32 @@ class Base64OutputStreamTest extends
AbstractBaseNOutputStreamTest {
assertArrayEquals(decoded, output, "Streaming byte-by-byte base64
wrap-wrap-wrap!");
}
+ /**
+ * Tests https://issues.apache.org/jira/browse/CODEC-334
+ */
+ @Test
+ void testCloseIdempotentCreateTempFile() throws Exception {
+ final Path tmp = Files.createTempFile("codec-test", ".bin");
+ try {
+ final OutputStream out = new Base64OutputStream(new
FileOutputStream(tmp.toFile()));
+ out.close();
+ out.close();
+ } finally {
+ Files.deleteIfExists(tmp);
+ }
+ }
+
+ /**
+ * Tests https://issues.apache.org/jira/browse/CODEC-334
+ */
+ @Test
+ void testCloseIdempotentFileOutputStream(@TempDir final Path tempDir)
throws Exception {
+ final Path tmp =
Files.createFile(tempDir.resolve(getClass().getSimpleName() + ".tmp"));
+ try (OutputStream out = new Base64OutputStream(new
FileOutputStream(tmp.toFile()))) {
+ out.close();
+ }
+ }
+
/**
* Test the Base64OutputStream implementation against the special NPE
inducing input
* identified in the CODEC-98 bug.