Skip to content

Commit 0b85363

Browse files
authored
Merge pull request #519 from metafacture/518-java11compat
Provide Java 11 forward compatibility.
2 parents d1a00a4 + 80d89a4 commit 0b85363

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ subprojects {
3131
'guava': '29.0-jre',
3232
'jackson_databind': '2.15.1',
3333
'junit': '4.12',
34-
'mockito': '2.5.7',
34+
'mockito': '2.27.0',
3535
'slf4j': '1.7.36',
3636
'wiremock_jre': '2.35.0'
3737
]

metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/ComplexTypeEncoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ComplexTypeEncoder implements TypeEncoder {
4343

4444
private static Object createInstance(final Class<?> clazz) {
4545
try {
46-
return clazz.newInstance();
46+
return clazz.getDeclaredConstructor().newInstance();
4747
}
4848
catch (final Exception e) { // checkstyle-disable-line IllegalCatch
4949
throw new MetafactureException("Can't instantiate object of class: " + clazz, e);

metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
import org.xml.sax.SAXNotRecognizedException;
3030
import org.xml.sax.SAXNotSupportedException;
3131
import org.xml.sax.XMLReader;
32-
import org.xml.sax.helpers.XMLReaderFactory;
3332

3433
import java.io.IOException;
3534
import java.io.Reader;
35+
import javax.xml.parsers.ParserConfigurationException;
36+
import javax.xml.parsers.SAXParserFactory;
3637

3738
/**
3839
* Reads an XML file and passes the XML events to a receiver.
@@ -56,9 +57,12 @@ public final class XmlDecoder extends DefaultObjectPipe<Reader, XmlReceiver> {
5657
*/
5758
public XmlDecoder() {
5859
try {
59-
saxReader = XMLReaderFactory.createXMLReader();
60+
final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
61+
parserFactory.setNamespaceAware(true);
62+
63+
saxReader = parserFactory.newSAXParser().getXMLReader();
6064
}
61-
catch (final SAXException e) {
65+
catch (final ParserConfigurationException | SAXException e) {
6266
throw new MetafactureException(e);
6367
}
6468
}

0 commit comments

Comments
 (0)