This repository was archived by the owner on Nov 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
nucleus/admin/config-api/src/main/java/org/glassfish/config/support Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change 4646import java .io .InputStream ;
4747import java .net .*;
4848import java .net .URL ;
49+ import java .nio .charset .Charset ;
4950import java .util .*;
5051import javax .xml .stream .XMLInputFactory ;
5152import javax .xml .stream .XMLStreamException ;
@@ -88,15 +89,15 @@ private DomainXmlPreParserException(String s) {
8889 if (domainXml == null || xif == null || !StringUtils .ok (instanceNameIn ))
8990 throw new IllegalArgumentException ();
9091
91- InputStream in = null ;
92-
93- try {
94- instanceName = instanceNameIn ;
95- in = domainXml . openStream ();
96- reader = xif .createXMLStreamReader (domainXml .toExternalForm (), in );
97- parse ();
98- postProcess ();
99- validate ();
92+ instanceName = instanceNameIn ;
93+ try (
94+ InputStream in = domainXml . openStream ();
95+ InputStreamReader isr = new InputStreamReader ( in , Charset . defaultCharset (). toString ())
96+ ) {
97+ reader = xif .createXMLStreamReader (domainXml .toExternalForm (), isr );
98+ parse ();
99+ postProcess ();
100+ validate ();
100101 }
101102 catch (DomainXmlPreParserException e ) {
102103 throw e ;
@@ -105,7 +106,7 @@ private DomainXmlPreParserException(String s) {
105106 throw new DomainXmlPreParserException (e2 );
106107 }
107108 finally {
108- cleanup (in );
109+ cleanup ();
109110 }
110111 }
111112
@@ -143,13 +144,11 @@ private void parse() throws XMLStreamException {
143144 }
144145 }
145146
146- private void cleanup (InputStream in ) {
147+ private void cleanup () {
147148 // this code is so ugly that it lives here!!
148149 try {
149150 if (reader != null )
150151 reader .close ();
151- if (in != null )
152- in .close ();
153152 reader = null ;
154153 }
155154 catch (Exception ex ) {
You can’t perform that action at this time.
0 commit comments