Uploaded image for project: 'Axis'
  1. Axis
  2. AXIS-664

DimeBodyPart.send() needs to close the input stream

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Operating System: Windows NT/2K
      Platform: PC
    • Bugzilla Id:
      17001

      Description

      DimeBodyPart.send() needs to close the input stream.

      My application produces dynamically-generated files and returns their contents
      as an Attachment in the SOAP response. Because DimeBodyPart.send() does not
      close the InputStream it acquires from the DataHandler, I am unable to delete a
      file (wrapped by a FileDataSource) after AXIS serializes the response because
      the jvm process still has an open handle on the file. Eventually this will get
      gc'd and then I can delete it but I don't want to queue up this work.

      By changing this method to something like the following...

      void send(java.io.OutputStream os, byte position, DataHandler dh,
      final long maxchunk) throws java.io.IOException {

      java.io.InputStream in = null;
      try {
      byte chunknext = 0;

      long dataSize = getDataSize();
      in = dh.getInputStream();
      byte[] readbuf = new byte[64 * 1024];
      int bytesread;

      sendHeader(os, position, dataSize, (byte) 0);
      long totalsent = 0;

      do {
      bytesread = in.read(readbuf);
      if (bytesread > 0)

      { os.write(readbuf, 0, bytesread); totalsent += bytesread; }

      }
      while (bytesread > -1);
      os.write(pad, 0, dimePadding(totalsent));
      }
      finally {
      if (in != null) {
      try

      { in.close(); }

      catch (IOException e )

      { // Ignore. }

      }
      }
      }

      I am able to reliably delete my files after AXIS has serialized the response.

      I haven't investigated whether a similar issue exists for outgoing MIME
      attachments (but it makes sense for this to be checked as well).

      Thanks!

      -Sam

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sambrow@iname.com Sam Brow
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: