mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-07 18:45:58 +01:00
Make sure to close the file after reading in. The parse(File) method does not close the file under all circumstances.
This commit is contained in:
parent
5d383e4a62
commit
5359ac0ef5
@ -16,25 +16,31 @@
|
|||||||
*/
|
*/
|
||||||
package brut.androlib.res.xml;
|
package brut.androlib.res.xml;
|
||||||
|
|
||||||
import brut.androlib.AndrolibException;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import javax.xml.xpath.XPath;
|
||||||
|
import javax.xml.xpath.XPathConstants;
|
||||||
|
import javax.xml.xpath.XPathExpression;
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import brut.androlib.AndrolibException;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.transform.OutputKeys;
|
|
||||||
import javax.xml.transform.Transformer;
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
import javax.xml.transform.TransformerFactory;
|
|
||||||
import javax.xml.transform.dom.DOMSource;
|
|
||||||
import javax.xml.transform.stream.StreamResult;
|
|
||||||
import javax.xml.xpath.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Connor Tumbleson <connor.tumbleson@gmail.com>
|
* @author Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||||
@ -249,7 +255,14 @@ public final class ResXmlPatcher {
|
|||||||
docFactory.setFeature(FEATURE_DISABLE_DOCTYPE_DECL, true);
|
docFactory.setFeature(FEATURE_DISABLE_DOCTYPE_DECL, true);
|
||||||
|
|
||||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||||
return docBuilder.parse(file);
|
// Not using the parse(File) method on purpose, so that we can control when
|
||||||
|
// to close it. Somehow parse(File) does not seem to close the file in all cases.
|
||||||
|
FileInputStream inputStream = new FileInputStream(file);
|
||||||
|
try {
|
||||||
|
return docBuilder.parse(inputStream);
|
||||||
|
} finally {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user