Skip to content

Commit

Permalink
Merge pull request #519 from metafacture/518-java11compat
Browse files Browse the repository at this point in the history
Provide Java 11 forward compatibility.
  • Loading branch information
blackwinter authored Feb 6, 2024
2 parents d1a00a4 + 80d89a4 commit 0b85363
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ subprojects {
'guava': '29.0-jre',
'jackson_databind': '2.15.1',
'junit': '4.12',
'mockito': '2.5.7',
'mockito': '2.27.0',
'slf4j': '1.7.36',
'wiremock_jre': '2.35.0'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ComplexTypeEncoder implements TypeEncoder {

private static Object createInstance(final Class<?> clazz) {
try {
return clazz.newInstance();
return clazz.getDeclaredConstructor().newInstance();
}
catch (final Exception e) { // checkstyle-disable-line IllegalCatch
throw new MetafactureException("Can't instantiate object of class: " + clazz, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

import java.io.IOException;
import java.io.Reader;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;

/**
* Reads an XML file and passes the XML events to a receiver.
Expand All @@ -56,9 +57,12 @@ public final class XmlDecoder extends DefaultObjectPipe<Reader, XmlReceiver> {
*/
public XmlDecoder() {
try {
saxReader = XMLReaderFactory.createXMLReader();
final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);

saxReader = parserFactory.newSAXParser().getXMLReader();
}
catch (final SAXException e) {
catch (final ParserConfigurationException | SAXException e) {
throw new MetafactureException(e);
}
}
Expand Down

0 comments on commit 0b85363

Please sign in to comment.