Skip to content

Commit 5be1b2e

Browse files
authored
Merge pull request #9830 from mbien/improve-auxiliary-config
Improve AuxiliaryConfigImpl: use new XMLUtil code paths
2 parents b8b201d + e5602a3 commit 5be1b2e

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

‎ide/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,11 @@ public Element run() {
7979
FileObject config = dir.getFileObject(AUX_CONFIG_FILENAME);
8080
if (config != null) {
8181
try {
82-
InputStream is = config.getInputStream();
83-
try {
82+
try (InputStream is = config.getInputStream()) {
8483
InputSource input = new InputSource(is);
8584
input.setSystemId(config.toURL().toString());
86-
Element root = XMLUtil.parse(input, false, true, /*XXX*/null, null).getDocumentElement();
85+
Element root = XMLUtil.parse(input, false, true, true, /*XXX*/null, null).getDocumentElement();
8786
return XMLUtil.findElement(root, elementName, namespace);
88-
} finally {
89-
is.close();
9087
}
9188
} catch (Exception x) {
9289
LOG.log(Level.INFO, "Cannot parse" + config, x);
@@ -97,7 +94,7 @@ public Element run() {
9794
Object attr = dir.getAttribute(attrName);
9895
if (attr instanceof String) {
9996
try {
100-
Element fragment = XMLUtil.parse(new InputSource(new StringReader((String) attr)), false, true,
97+
Element fragment = XMLUtil.parse(new InputSource(new StringReader((String) attr)), false, true, true,
10198
/*XXX #136595: need utility method*/null, null).getDocumentElement();
10299
if (elementName.equals(fragment.getLocalName()) && namespace.equals(fragment.getNamespaceURI())) {
103100
return fragment;
@@ -138,13 +135,10 @@ public Void run() {
138135
Document doc;
139136
FileObject config = dir.getFileObject(AUX_CONFIG_FILENAME);
140137
if (config != null) {
141-
InputStream is = config.getInputStream();
142-
try {
138+
try (InputStream is = config.getInputStream()) {
143139
InputSource input = new InputSource(is);
144140
input.setSystemId(config.toURL().toString());
145-
doc = XMLUtil.parse(input, false, true, /*XXX*/ null, null);
146-
} finally {
147-
is.close();
141+
doc = XMLUtil.parse(input, false, true, true, /*XXX*/ null, null);
148142
}
149143
} else {
150144
config = dir.createData(AUX_CONFIG_FILENAME);
@@ -209,13 +203,10 @@ private boolean removeFallbackImpl(final String elementName, final String namesp
209203
if (config != null) {
210204
try {
211205
Document doc;
212-
InputStream is = config.getInputStream();
213-
try {
206+
try (InputStream is = config.getInputStream()) {
214207
InputSource input = new InputSource(is);
215208
input.setSystemId(config.toURL().toString());
216-
doc = XMLUtil.parse(input, false, true, /*XXX*/ null, null);
217-
} finally {
218-
is.close();
209+
doc = XMLUtil.parse(input, false, true, true, /*XXX*/ null, null);
219210
}
220211
Element root = doc.getDocumentElement();
221212
Element toRemove = XMLUtil.findElement(root, elementName, namespace);

0 commit comments

Comments
 (0)