xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Harrison <matthew.harri...@equinox.co.nz>
Subject Parsing a file inside a zip file locking zip file on windows
Date Mon, 16 Jul 2018 19:56:24 GMT
I've hit a bit of an odd case, that I'm hoping someone can tell me what I'm doing wrong, or
how to fix it.
As part of a transform (using Saxon), we're processing files that are inside a zip file. 
To access the files we're using a 'jar' URI, however after accessing/parsing the file it seems
to be locked, and so cannot be deleted until the java program terminates.
I believe I've created a reproducing case:

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import com.google.common.io.Files;

public class CleanupInvestigation {
public static void main(String[] args)
throws IOException, SAXException, ParserConfigurationException, URISyntaxException, InterruptedException
File input = new File("src/test/resources/books.zip");
File inputCopy = new File("src/test/resources/booksCopy.zip");
Files.copy(input, inputCopy);

DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse("jar:file:src/test/resources/booksCopy.zip!/app.xml");

System.out.println("File delete (booksCopy.zip): " + inputCopy.delete());

I'm running this using Xerces 2.12.0 running on a Windows 10 machine, talking with the Saxon
guys its looks like it works ok on a Mac (i.e. the booksCopy.zip file can be deleted).

If anyone has any ideas on what the issue might be that would be great.



View raw message