src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/packaging/mime/internet/BMMimeMultipart.java

Print this page
rev 447 : 8029237: Update copyright year to match last edit in jdk8 jaxws repository (2013)
Summary: Fixing Copyrights for year 2013
Reviewed-by: chegar
rev 472 : 8036030: Update JAX-WS RI integration to latest version

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -38,11 +38,10 @@
 
 import com.sun.xml.internal.messaging.saaj.packaging.mime.*;
 import com.sun.xml.internal.messaging.saaj.packaging.mime.util.*;
 
 import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
-import com.sun.xml.internal.messaging.saaj.util.FinalArrayList;
 
 /**
  * The MimeMultipart class is an implementation of the abstract Multipart
  * class that uses MIME conventions for the multipart data. <p>
  *

@@ -391,17 +390,16 @@
     public boolean find(InputStream is, byte[] pattern, SharedInputStream sin)
         throws Exception {
         int i;
         int l = pattern.length;
         int lx = l -1;
-        int bufferLength = 0;
         BitSet eof = new BitSet(1);
         long[] posVector = new long[1];
 
         while (true) {
             is.mark(l);
-            bufferLength = readNext(is, buffer, l, eof, posVector, sin);
+            readNext(is, buffer, l, eof, posVector, sin);
             if (eof.get(0)) {
                 // End of stream
                 return false;
             }
 

@@ -559,11 +557,11 @@
 
             if ((s > 0) && (sin == null)) {
                 if (prevBuffer[s-1] == (byte)13) {
                     // if buffer[0] == (byte)10
                     if (buffer[0] == (byte)10) {
-                        int j=lx-1;
+                        int j;
                         for(j = lx-1; j > 0; j--) {
                             if (buffer[j+1] != pattern[j]) {
                                 break;
                              }
                          }

@@ -693,11 +691,10 @@
 
     /**
      * Iterates through all the parts and outputs each Mime part
      * separated by a boundary.
      */
-    byte[] buf = new byte[1024];
 
     public void writeTo(OutputStream os)
             throws IOException, MessagingException {
 
         // inputStream was not null

@@ -713,18 +710,24 @@
         }
 
         if (in != null) {
             OutputUtil.writeln(bnd, os); // put out boundary
             if ((os instanceof ByteOutputStream) && lazyAttachments) {
-                ((ByteOutputStream)os).write(in);
+                ((ByteOutputStream) os).write(in);
             } else {
-                ByteOutputStream baos = new ByteOutputStream(in.available());
+                ByteOutputStream baos = null;
+                try {
+                    baos = new ByteOutputStream(in.available());
                 baos.write(in);
                 baos.writeTo(os);
                 // reset the inputstream so that we can support a
-                //getAttachment later
+                    // getAttachment later
                 in = baos.newInputStream();
+                } finally {
+                    if (baos != null)
+                        baos.close();
+                }
             }
 
             // this will endup writing the end boundary
         } else {
         // put out last boundary