Uploaded image for project: 'Synapse'
  1. Synapse
  2. SYNAPSE-212

XSLTMediator doesn't close/delete temporary files properly


    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1, NIGHTLY
    • Fix Version/s: 1.2
    • Component/s: Core
    • Labels:


      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) {

      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.


          Issue Links



              • Assignee:
                veithen Andreas Veithen
                veithen Andreas Veithen
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: