8290740: Catalog not used when the handler is null
Reviewed-by: lancea, naoto, iris
This commit is contained in:
parent
dd9bd31b86
commit
470c0eb216
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
@ -128,7 +128,7 @@ import org.xml.sax.InputSource;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @see XIncludeNamespaceSupport
|
* @see XIncludeNamespaceSupport
|
||||||
* @LastModified: May 2021
|
* @LastModified: July 2022
|
||||||
*/
|
*/
|
||||||
public class XIncludeHandler
|
public class XIncludeHandler
|
||||||
implements XMLComponent, XMLDocumentFilter, XMLDTDFilter {
|
implements XMLComponent, XMLDocumentFilter, XMLDTDFilter {
|
||||||
@ -1638,8 +1638,8 @@ public class XIncludeHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
XMLInputSource includedSource = null;
|
XMLInputSource includedSource = null;
|
||||||
if (fEntityResolver != null) {
|
|
||||||
try {
|
try {
|
||||||
|
if (fEntityResolver != null) {
|
||||||
XMLResourceIdentifier resourceIdentifier =
|
XMLResourceIdentifier resourceIdentifier =
|
||||||
new XMLResourceIdentifierImpl(
|
new XMLResourceIdentifierImpl(
|
||||||
null,
|
null,
|
||||||
@ -1652,7 +1652,7 @@ public class XIncludeHandler
|
|||||||
|
|
||||||
includedSource =
|
includedSource =
|
||||||
fEntityResolver.resolveEntity(resourceIdentifier);
|
fEntityResolver.resolveEntity(resourceIdentifier);
|
||||||
|
}
|
||||||
if (includedSource == null && fUseCatalog) {
|
if (includedSource == null && fUseCatalog) {
|
||||||
if (fCatalogFeatures == null) {
|
if (fCatalogFeatures == null) {
|
||||||
fCatalogFeatures = JdkXmlUtils.getCatalogFeatures(fDefer, fCatalogFile, fPrefer, fResolve);
|
fCatalogFeatures = JdkXmlUtils.getCatalogFeatures(fDefer, fCatalogFile, fPrefer, fResolve);
|
||||||
@ -1702,7 +1702,6 @@ public class XIncludeHandler
|
|||||||
new Object[] { href, e.getMessage()}, e);
|
new Object[] { href, e.getMessage()}, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (includedSource == null) {
|
if (includedSource == null) {
|
||||||
// setup an HTTPInputSource if either of the content negotation attributes were specified.
|
// setup an HTTPInputSource if either of the content negotation attributes were specified.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,7 +41,7 @@ import org.xml.sax.InputSource;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 8158084 8162438 8162442 8166220 8166398
|
* @bug 8158084 8162438 8162442 8166220 8166398 8290740
|
||||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||||
* @run testng/othervm -DrunSecMngr=true -Djava.security.manager=allow catalog.CatalogSupport
|
* @run testng/othervm -DrunSecMngr=true -Djava.security.manager=allow catalog.CatalogSupport
|
||||||
* @run testng/othervm catalog.CatalogSupport
|
* @run testng/othervm catalog.CatalogSupport
|
||||||
@ -103,6 +103,17 @@ public class CatalogSupport extends CatalogSupportBase {
|
|||||||
testXInclude(setUseCatalog, useCatalog, catalog, xml, handler, expected);
|
testXInclude(setUseCatalog, useCatalog, catalog, xml, handler, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Verifies that the Catalog is used when the handler is null. The test shall
|
||||||
|
run through without an Exception (that was thrown before the fix).
|
||||||
|
*/
|
||||||
|
@Test(dataProvider = "data_XIA")
|
||||||
|
public void testXIncludeA_NullHandler(boolean setUseCatalog, boolean useCatalog, String catalog,
|
||||||
|
String xml, MyHandler handler, String expected) throws Exception {
|
||||||
|
handler = null;
|
||||||
|
testXInclude(setUseCatalog, useCatalog, catalog, xml, handler, expected);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Verifies the Catalog support on DOM parser.
|
Verifies the Catalog support on DOM parser.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -306,11 +306,14 @@ public class CatalogSupportBase {
|
|||||||
public void testXInclude(boolean setUseCatalog, boolean useCatalog, String catalog,
|
public void testXInclude(boolean setUseCatalog, boolean useCatalog, String catalog,
|
||||||
String xml, MyHandler handler, String expected) throws Exception {
|
String xml, MyHandler handler, String expected) throws Exception {
|
||||||
SAXParser parser = getSAXParser(setUseCatalog, useCatalog, catalog);
|
SAXParser parser = getSAXParser(setUseCatalog, useCatalog, catalog);
|
||||||
|
|
||||||
parser.parse(new InputSource(new StringReader(xml)), handler);
|
parser.parse(new InputSource(new StringReader(xml)), handler);
|
||||||
|
// the test verifies the result if handler != null, or no exception
|
||||||
|
// is thrown if handler == null.
|
||||||
|
if (handler != null) {
|
||||||
debugPrint("handler.result:" + handler.getResult());
|
debugPrint("handler.result:" + handler.getResult());
|
||||||
Assert.assertEquals(handler.getResult().trim(), expected);
|
Assert.assertEquals(handler.getResult().trim(), expected);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Verifies the Catalog support on DOM parser.
|
Verifies the Catalog support on DOM parser.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user