Hi,

In certain cases FOP needs to write temporary files. For example 
org.apache.fop.afp.AFPStreamer needs to concatenate the AFP resources with the 
main document. After the vote and merge of the Temp_URI_Resolution branch (Sept 
2012), the actual pattern of using temp files has changed from:

File tmpFile = File.createTempFile(....);
// Write and read from the file
tmpFile.delete();

to:
File tmpFile = new File(System.getProperty("java.io.tmpdir"), 
counterStartingFrom1AsString);
tmpFile.deleteOnExit();
// Write and read from the file


This introduces  a number of bad side effects:
1. Different FOP processes can't be executed in parallel on the same system 
because creating the same temp file fails.

2. If the JVM is not normally terminated, the temp files are never deleted and 
the next invocation of the JVM fails to run.

3. deleteOnExit() keeps for the life of the JVM an unknown number of temp files 
both on disk and a reference in memory.


I am volunteering to prepare a patch for both XGC and FOP to fix those issues. 
I was thinking of adding a cleanup() method on 
org.apache.xmlgraphics.io.TempResourceResolver interface so it gets a 
notification to delete the temp files, moving there the isTempURI() and 
generate() methods of TempResourceURIGenerator class and then deleting it.

I am also tempted to delete the org.apache.xmlgraphics.io.Resource and change 
in ResourceResolver the 
Resource getResource(URI uri)
to 
InputStream getInputStream(URI uri)


Although in [1] there is a reason for having it, in practice the "type" is used 
nowhere. 


WDYT ?

Alexis Giotis




[1] http://wiki.apache.org/xmlgraphics-fop/URIResolution

Reply via email to