Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Santos Izaguirre <[email protected]>
  • Loading branch information
antoniosanct authored Feb 15, 2024
1 parent bf9b3e1 commit ebf13ac
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down 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 ebf13ac

Please sign in to comment.