jmsnell 2003/02/17 17:09:35 Modified: java/src/org/apache/axis/attachments DimeBodyPart.java Log: FIX: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17001 Closing the DataHandler input stream so the JVM isn't left holding an open handle Revision Changes Path 1.16 +32 -17 xml-axis/java/src/org/apache/axis/attachments/DimeBodyPart.java Index: DimeBodyPart.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/DimeBodyPart.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- DimeBodyPart.java 12 Jan 2003 01:46:46 -0000 1.15 +++ DimeBodyPart.java 18 Feb 2003 01:09:35 -0000 1.16 @@ -294,25 +294,40 @@ void send(java.io.OutputStream os, byte position, DataHandler dh, final long maxchunk) throws java.io.IOException { - byte chunknext = 0; - - long dataSize = getDataSize(); - java.io.InputStream 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; +// START FIX: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17001 + 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)); } - while (bytesread > -1); - os.write(pad, 0, dimePadding(totalsent)); + finally { + if (in != null) { + try { + in.close(); + } + catch (IOException e) { + // ignore + } + } + } +// END FIX: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17001 } protected void sendChunk(java.io.OutputStream os,
