8150969: DEFER from Features API is taking precedence over defer preference in catalog file
Reviewed-by: lancea
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java Wed Jul 05 21:31:37 2017 +0200
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java Wed Apr 06 14:31:38 2016 -0700
@@ -186,7 +186,7 @@
}
//override property settings with those from the catalog file
catalog.setResolve(resolve);
- catalog.setPrefer(defer);
+ catalog.setDeferred(defer);
catalogEntry = new CatalogEntry(base, prefer, defer, resolve);
} else {
catalogEntry = new CatalogEntry(base, prefer);
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Wed Jul 05 21:31:37 2017 +0200
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Wed Apr 06 14:31:38 2016 -0700
@@ -24,6 +24,7 @@
import java.io.IOException;
import javax.xml.catalog.Catalog;
+import javax.xml.catalog.CatalogException;
import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogFeatures.Feature;
import javax.xml.catalog.CatalogManager;
@@ -42,11 +43,29 @@
import org.xml.sax.ext.DefaultHandler2;
/*
- * @bug 8081248, 8144966, 8146606, 8146237, 8151154
+ * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969
* @summary Tests basic Catalog functions.
*/
public class CatalogTest {
/**
+ * @bug 8150969
+ * Verifies that the defer attribute set in the catalog file takes precedence
+ * over other settings, in which case, whether next and delegate Catalogs will
+ * be loaded is determined by the defer attribute.
+ */
+ @Test(dataProvider = "invalidAltCatalogs", expectedExceptions = CatalogException.class)
+ public void testDeferAltCatalogs(String file) {
+ String catalogFile = getClass().getResource(file).getFile();
+ CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "true").build();
+ /*
+ Since the defer attribute is set to false in the specified catalog file,
+ the parent catalog will try to load the alt catalog, which will fail
+ since it points to an invalid catalog.
+ */
+ Catalog catalog = CatalogManager.catalog(features, catalogFile);
+ }
+
+ /**
* @bug 8151154
* Verifies that the CatalogFeatures' builder throws IllegalArgumentException
* on invalid file inputs.
@@ -214,6 +233,18 @@
}
/*
+ DataProvider: catalogs that contain invalid next or delegate catalogs.
+ The defer attribute is set to false.
+ */
+ @DataProvider(name = "invalidAltCatalogs")
+ Object[][] getCatalogs() {
+ return new Object[][]{
+ {"defer_false_2.xml"},
+ {"defer_del_false.xml"}
+ };
+ }
+
+ /*
DataProvider: for testing the verification of file paths by
the CatalogFeatures builder
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/bad_cat.xml Wed Apr 06 14:31:38 2016 -0700
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+ <public
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/defer_del_false.xml Wed Apr 06 14:31:38 2016 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" defer="false">
+ <delegatePublic publicIdStartString="DELEGATE-DEFER" catalog="bad_cat.xml"/>
+ <!--<nextCatalog catalog="file_cat.xml"/>-->
+</catalog>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/defer_false_2.xml Wed Apr 06 14:31:38 2016 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" defer="false">
+ <nextCatalog catalog="bad_cat.xml"/>
+ <!--<nextCatalog catalog="file_cat.xml"/>-->
+</catalog>
+