You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2003/02/12 16:39:01 UTC
DO NOT REPLY [Bug 17001] New: -
DimeBodyPart.send() needs to close the input stream
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17001>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17001
DimeBodyPart.send() needs to close the input stream
Summary: DimeBodyPart.send() needs to close the input stream
Product: Axis
Version: 1.0
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Major
Priority: Other
Component: Serialization/Deserialization
AssignedTo: axis-dev@ws.apache.org
ReportedBy: sambrow@iname.com
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