Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
final class FallbackIgnoreLSResourceResolver implements LSResourceResolver {

/** DOM Level 3 Load/Save implementation used to build the empty input for unresolved lookups. */
private static final DOMImplementationLS DOM_LS = domImplementationLS();
private static final DOMImplementationLS DOM_LS;

private static DOMImplementationLS domImplementationLS() {
static {
try {
return (DOMImplementationLS) DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new HardeningException("No DOM Level 3 Load/Save implementation available to build the empty schema input", e);
DOM_LS = (DOMImplementationLS) DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
} catch (final ReflectiveOperationException e) {
throw new ExceptionInInitializerError(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.function.Supplier;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
Expand Down Expand Up @@ -53,11 +52,10 @@
* Backing for the default ignore outcome. Consumers parse the resolved {@link Source}, and an empty character stream is not a well-formed XML document
* (XSLTC rejects it for {@code document()} and for an ignored {@code xsl:include}/{@code xsl:import}), so the default supplier answers with a well-formed
* empty document that evaluates to no content. It is never mutated, so one instance serves every resolution.
*
* @see #newEmptyDocument()
*/
private static final Document EMPTY_DOCUMENT = newEmptyDocument();
private static final Document EMPTY_DOCUMENT;

static {
/**
* Creates a new empty document.
*
Expand All @@ -66,11 +64,12 @@
* @throws FactoryConfigurationError Thrown from a factory in case of a {@link java.util.ServiceConfigurationError service
* configuration error} or if the implementation is not available or cannot be instantiated.
*/
private static Document newEmptyDocument() {

Check failure on line 67 in src/main/java/org/apache/commons/xml/FallbackIgnoreURIResolver.java

View workflow job for this annotation

GitHub Actions / build (android, API 33)

illegal start of expression

Check failure on line 67 in src/main/java/org/apache/commons/xml/FallbackIgnoreURIResolver.java

View workflow job for this annotation

GitHub Actions / build (android, API 33)

illegal start of expression

Check failure on line 67 in src/main/java/org/apache/commons/xml/FallbackIgnoreURIResolver.java

View workflow job for this annotation

GitHub Actions / build (android, API 35)

illegal start of expression

Check failure on line 67 in src/main/java/org/apache/commons/xml/FallbackIgnoreURIResolver.java

View workflow job for this annotation

GitHub Actions / build (android, API 35)

illegal start of expression

Check failure on line 67 in src/main/java/org/apache/commons/xml/FallbackIgnoreURIResolver.java

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, graalvm 25)

illegal start of expression

Check failure on line 67 in src/main/java/org/apache/commons/xml/FallbackIgnoreURIResolver.java

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, graalvm 25)

illegal start of expression
try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
EMPTY_DOCUMENT = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (final ParserConfigurationException e) {
throw new HardeningException("A DocumentBuilder cannot be created which satisfies the configuration requested.", e);
// Checked exceptions cannot escape static initialization; a FactoryConfigurationError from newInstance() already can and propagates as-is.
throw new ExceptionInInitializerError(e);
}
}

Expand Down
Loading