提交 39a9b8fe 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-8042] Fixed a file handle leak

上级 266510f3
...@@ -58,6 +58,9 @@ Upcoming changes</a> ...@@ -58,6 +58,9 @@ Upcoming changes</a>
<li class=bug> <li class=bug>
Restart button does not restart jenkins after plugin upload Restart button does not restart jenkins after plugin upload
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10044">issue 10044</a>) (<a href="https://issues.jenkins-ci.org/browse/JENKINS-10044">issue 10044</a>)
<li class=bug>
Fixed a file handle leak in <tt>GET config.xml</tt> API call
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-8042">issue 8042</a>)
<li class=rfe> <li class=rfe>
Groovy script console is now syntax highlighted. Groovy script console is now syntax highlighted.
<li class=rfe> <li class=rfe>
......
...@@ -31,8 +31,10 @@ import com.thoughtworks.xstream.io.xml.XppReader; ...@@ -31,8 +31,10 @@ import com.thoughtworks.xstream.io.xml.XppReader;
import hudson.model.Descriptor; import hudson.model.Descriptor;
import hudson.util.AtomicFileWriter; import hudson.util.AtomicFileWriter;
import hudson.util.IOException2; import hudson.util.IOException2;
import hudson.util.IOUtils;
import hudson.util.XStream2; import hudson.util.XStream2;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator; import org.xml.sax.Locator;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2; import org.xml.sax.ext.Locator2;
...@@ -234,8 +236,11 @@ public final class XmlFile { ...@@ -234,8 +236,11 @@ public final class XmlFile {
this.encoding = encoding; this.encoding = encoding;
} }
} }
InputSource input = new InputSource(file.toURI().toASCIIString());
input.setByteStream(new FileInputStream(file));
try { try {
JAXP.newSAXParser().parse(file,new DefaultHandler() { JAXP.newSAXParser().parse(input,new DefaultHandler() {
private Locator loc; private Locator loc;
@Override @Override
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
...@@ -275,6 +280,9 @@ public final class XmlFile { ...@@ -275,6 +280,9 @@ public final class XmlFile {
throw new IOException2("Failed to detect encoding of "+file,e); throw new IOException2("Failed to detect encoding of "+file,e);
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
throw new AssertionError(e); // impossible throw new AssertionError(e); // impossible
} finally {
// some JAXP implementations appear to leak the file handle if we just call parse(File,DefaultHandler)
input.getByteStream().close();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册