XSLTMediator doesn't close/delete temporary files properly
----------------------------------------------------------
Key: SYNAPSE-212
URL: https://issues.apache.org/jira/browse/SYNAPSE-212
Project: Synapse
Issue Type: Bug
Components: Core
Affects Versions: 1.1, NIGHTLY
Reporter: Andreas Veithen
When a temporary file is used for the transformation result, XSLTMediator will
read it back using the following instructions:
StAXOMBuilder builder = new StAXOMBuilder(new FileInputStream(tempTargetFile));
result = builder.getDocumentElement();
Since Axiom constructs the XML tree on demand, this will actually not read the
entire file but only a small part of it. Also, since nobody ever closes the
input stream explicitly, the file will only be closed when the FileInputStream
object is garbage collected.
Immediately after the above instructions, XSLTMediator executes the following
piece of code:
boolean deleted = tempTargetFile.delete();
if (!deleted) {
tempTargetFile.deleteOnExit();
}
Since the file is still open at that moment, on Windows platforms, the delete
operation will fail. Therefore the file will not be deleted until Synapse is
shut down or restarted. On Unix systems, only the directory entry will be
removed, but not the inode (and the content). On these systems, the file will
be deleted by the OS when the file is closed, i.e. when the FileInputStream
object is garbage collected.
This problem is not easy to solve because the input stream can't be closed
inside the mediate method (the whole purpose of having a temporary file being
to allow streaming). It can only be closed (and deleted) safely once the
sequence containing the XSLT mediation is completed and the message has been
sent. Unfortunately, there seems to be no generic mechanism in Synapse to do
this. Actually what would be needed is something similar to the flowComplete
method in org.apache.axis2.engine.Handler.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]