mirror of https://github.com/apache/poi.git
[github-343] use try-with-resources. Thanks to XenoAmess. This closes #343
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
67a4ac400e
commit
619db4dde5
|
@ -109,9 +109,10 @@ public final class XPathHelper {
|
|||
public static <T extends XmlObject> T selectProperty(XmlObject startObject, Class<T> resultClass, XSLFShape.ReparseFactory<T> factory, QName[]... path)
|
||||
throws XmlException {
|
||||
XmlObject xo = startObject;
|
||||
XmlCursor innerCur = null;
|
||||
try (XmlCursor cur = startObject.newCursor()) {
|
||||
innerCur = selectProperty(cur, path, 0, factory != null, false);
|
||||
try (
|
||||
XmlCursor cur = startObject.newCursor();
|
||||
XmlCursor innerCur = selectProperty(cur, path, 0, factory != null, false)
|
||||
) {
|
||||
if (innerCur == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -131,10 +132,6 @@ public final class XPathHelper {
|
|||
}
|
||||
|
||||
return (T) xo;
|
||||
} finally {
|
||||
if (innerCur != null) {
|
||||
innerCur.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue