jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/packaging/mime/internet/MimeMultipart.java
changeset 23782 953bfc3fbe31
parent 22679 d785acd84a14
equal deleted inserted replaced
23403:85dbdc227c5e 23782:953bfc3fbe31
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   316 
   316 
   317         String boundary = "--" + contentType.getParameter("boundary");
   317         String boundary = "--" + contentType.getParameter("boundary");
   318         byte[] bndbytes = ASCIIUtility.getBytes(boundary);
   318         byte[] bndbytes = ASCIIUtility.getBytes(boundary);
   319         int bl = bndbytes.length;
   319         int bl = bndbytes.length;
   320 
   320 
       
   321         ByteOutputStream buf = null;
   321         try {
   322         try {
   322             // Skip the preamble
   323             // Skip the preamble
   323             LineInputStream lin = new LineInputStream(in);
   324             LineInputStream lin = new LineInputStream(in);
   324             String line;
   325             String line;
   325             while ((line = lin.readLine()) != null) {
   326             while ((line = lin.readLine()) != null) {
   368                 }
   369                 }
   369 
   370 
   370                 if (!in.markSupported())
   371                 if (!in.markSupported())
   371                     throw new MessagingException("Stream doesn't support mark");
   372                     throw new MessagingException("Stream doesn't support mark");
   372 
   373 
   373                 ByteOutputStream buf = null;
   374                 buf = null;
   374                 // if we don't have a shared input stream, we copy the data
   375                 // if we don't have a shared input stream, we copy the data
   375                 if (sin == null)
   376                 if (sin == null)
   376                     buf = new ByteOutputStream();
   377                     buf = new ByteOutputStream();
   377                 int b;
   378                 int b;
   378                 boolean bol = true;    // beginning of line flag
   379                 boolean bol = true;    // beginning of line flag
   469                     part = createMimeBodyPart(headers, buf.getBytes(), buf.getCount());
   470                     part = createMimeBodyPart(headers, buf.getBytes(), buf.getCount());
   470                 addBodyPart(part);
   471                 addBodyPart(part);
   471             }
   472             }
   472         } catch (IOException ioex) {
   473         } catch (IOException ioex) {
   473             throw new MessagingException("IO Error", ioex);
   474             throw new MessagingException("IO Error", ioex);
       
   475         } finally {
       
   476             if (buf != null)
       
   477                 buf.close();
   474         }
   478         }
   475 
   479 
   476         if (!ignoreMissingEndBoundary && !foundClosingBoundary && sin== null) {
   480         if (!ignoreMissingEndBoundary && !foundClosingBoundary && sin== null) {
   477             throw new MessagingException("Missing End Boundary for Mime Package : EOF while skipping headers");
   481             throw new MessagingException("Missing End Boundary for Mime Package : EOF while skipping headers");
   478         }
   482         }