Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Santos Izaguirre <antoniosanct@gmail.com>
  • Loading branch information
antoniosanct committed Dec 3, 2023
1 parent b023399 commit 245bf7d
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller
*/
protected AbstractUnmarshallerImpl() {}

private SAXParserFactory parserFactory;

private SAXParserFactory getSAXParserFactory() {
if (null == parserFactory) {
parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
// there is no point in asking a validation because
// there is no guarantee that the document will come with
// a proper schemaLocation.
parserFactory.setValidating(false);
}
return parserFactory;
}
/**
* Obtains a configured XMLReader.
*
Expand All @@ -85,14 +98,7 @@ protected AbstractUnmarshallerImpl() {}
protected XMLReader getXMLReader() throws JAXBException {
if(reader==null) {
try {
SAXParserFactory parserFactory;
parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
// there is no point in asking a validation because
// there is no guarantee that the document will come with
// a proper schemaLocation.
parserFactory.setValidating(false);
reader = parserFactory.newSAXParser().getXMLReader();
reader = getSAXParserFactory().newSAXParser().getXMLReader();
} catch( ParserConfigurationException | SAXException e ) {
throw new JAXBException(e);
}
Expand Down

0 comments on commit 245bf7d

Please sign in to comment.