Skip to content

Commit ca83fd7

Browse files
committed
[Java] Don't create xpath factory until needed and set character encoding for test.
1 parent 4ace22a commit ca83fd7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/xml/XmlSchemaParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,10 @@ public static MessageSchema parse(final InputSource is, final ParserOptions opti
129129
}
130130

131131
final Document document = factory.newDocumentBuilder().parse(is);
132-
final XPath xPath = XPathFactory.newInstance().newXPath();
133-
134132
final ErrorHandler errorHandler = new ErrorHandler(options);
135133
document.setUserData(ERROR_HANDLER_KEY, errorHandler, null);
136134

135+
final XPath xPath = XPathFactory.newInstance().newXPath();
137136
final Map<String, Type> typeByNameMap = findTypes(document, xPath);
138137
errorHandler.checkIfShouldExit();
139138

sbe-tool/src/test/java/uk/co/real_logic/sbe/generation/csharp/Issue567GroupSizeTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@
3030

3131
import java.io.IOException;
3232
import java.io.InputStream;
33+
import java.io.InputStreamReader;
3334
import java.io.PrintStream;
35+
import java.nio.charset.StandardCharsets;
3436

3537
import static org.junit.jupiter.api.Assertions.assertThrows;
3638
import static org.mockito.Mockito.mock;
3739
import static org.mockito.Mockito.verify;
3840
import static uk.co.real_logic.sbe.xml.XmlSchemaParser.parse;
3941

40-
@EnabledForJreRange(min = JRE.JAVA_8, max = JRE.JAVA_17)
42+
@EnabledForJreRange(min = JRE.JAVA_8, max = JRE.JAVA_18)
4143
public class Issue567GroupSizeTest
4244
{
4345
public static final String ERR_MSG =
@@ -65,8 +67,7 @@ public void shouldThrowWhenUsingATypeThatIsNotConstrainedToFitInAnIntAsTheGroupS
6567
{
6668
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
6769
final InputStream in = Tests.getLocalResource("issue567-invalid.xml");
68-
final InputSource is = new InputSource(in);
69-
is.setEncoding("UTF-8");
70+
final InputSource is = new InputSource(new InputStreamReader(in, StandardCharsets.UTF_8));
7071

7172
assertThrows(IllegalArgumentException.class, () -> parse(is, options));
7273
}
@@ -76,8 +77,7 @@ public void shouldGenerateWhenUsingATypeThatIsConstrainedToFitInAnIntAsTheGroupS
7677
{
7778
final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
7879
final InputStream in = Tests.getLocalResource("issue567-valid.xml");
79-
final InputSource is = new InputSource(in);
80-
is.setEncoding("UTF-8");
80+
final InputSource is = new InputSource(new InputStreamReader(in, StandardCharsets.UTF_8));
8181

8282
final MessageSchema schema = parse(is, options);
8383
final IrGenerator irg = new IrGenerator();

0 commit comments

Comments
 (0)