This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit c4966fd8e9e21034a92127bbd1d7d66a345482c2
Author: Jörn Gebhardt <[email protected]>
AuthorDate: Fri Dec 8 16:22:59 2017 +0100

    [CXF-7585] Close InputStream in AttachmentSerializer when base64 encoding 
is used
    
    (cherry picked from commit e48f90234162cb1b2766d6bc9a245c4d04502335)
---
 .../main/java/org/apache/cxf/attachment/AttachmentSerializer.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java 
b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
index 1599407..66e7b28 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
@@ -278,7 +278,9 @@ public class AttachmentSerializer {
                              headers, writer);
                 out.write(writer.getBuffer().toString().getBytes(encoding));
                 if ("base64".equals(contentTransferEncoding)) {
-                    encodeBase64(handler.getInputStream(), out, 
IOUtils.DEFAULT_BUFFER_SIZE);
+                    try (InputStream inputStream = handler.getInputStream()) {
+                        encodeBase64(inputStream, out, 
IOUtils.DEFAULT_BUFFER_SIZE);
+                    }
                 } else {
                     handler.writeTo(out);
                 }
@@ -308,7 +310,7 @@ public class AttachmentSerializer {
             if (n == 0) {
                 throw new IOException("0 bytes read in violation of 
InputStream.read(byte[])");
             }
-            Base64Utility.encodeAndStream(buffer, 0, n, out);
+            Base64Utility.encodeAndStream(buffer, 0, n, output);
             total += n;
             n = input.read(buffer);
         }

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to