Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit 88312fe

Browse files
mukumawayaminikb
authored andcommitted
Fixes #21893 Unable to start cluster if Japanese (or Non-ASCII) characters are ent… (#21947)
1 parent 398869d commit 88312fe

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

nucleus/admin/config-api/src/main/java/org/glassfish/config/support/DomainXmlPreParser.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.io.InputStream;
4747
import java.net.*;
4848
import java.net.URL;
49+
import java.nio.charset.Charset;
4950
import java.util.*;
5051
import javax.xml.stream.XMLInputFactory;
5152
import 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) {

0 commit comments

Comments
 (0)