From b24d8ca779cacbff53f55e4f45c9f1e5364eeff1 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 19 Jun 2022 13:37:14 +0000 Subject: [PATCH] remove use of some calls to deprecated cursor dispose() git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902065 13f79535-47bb-0310-9956-ffa450edef68 --- .../XWPFAbstractFootnoteEndnote.java | 47 +++++------- .../poi/xwpf/usermodel/XWPFDocument.java | 71 ++++++++----------- .../apache/poi/xwpf/usermodel/XWPFHeader.java | 41 +++++------ .../poi/xwpf/usermodel/XWPFHeaderFooter.java | 45 +++--------- 4 files changed, 74 insertions(+), 130 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java index 0be1a2f74b..083ede0968 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java @@ -72,8 +72,7 @@ public abstract class XWPFAbstractFootnoteEndnote implements Iterable(); // parse the document with cursor and add // the XmlObject to its lists - XmlCursor cursor = headerFooter.newCursor(); - try { + try (XmlCursor cursor = headerFooter.newCursor()) { cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); @@ -542,8 +517,6 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo bodyElements.add(t); } } - } finally { - cursor.dispose(); } }