-
Bug
-
Resolution: Fixed
-
P3
-
11, 12
-
b03
-
x86_64
-
windows_7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8222560 | 12.0.2 | Aleksej Efimov | P3 | Resolved | Fixed | master |
JDK-8217460 | 12.0.1 | Aleksej Efimov | P3 | Resolved | Fixed | b04 |
JDK-8216286 | 11.0.3-oracle | Aleksej Efimov | P3 | Resolved | Fixed | b04 |
JDK-8219235 | 11.0.3 | Joe Wang | P3 | Resolved | Fixed | master |
ADDITIONAL SYSTEM INFORMATION :
Tested JDK 9, JDK 10.0.2, OpenJDK 11.0.1
A DESCRIPTION OF THE PROBLEM :
An XML <Catalog> with a <group> of <uriSuffix> matchers fails to match.
Match succeeds if similar matcher is not in a <group>.
Possible diagnosis:
Stepping through the code, the problem appears to be with javax.xml.catalog.CatalogResolverImpl, specifically in javax.xml.catalog.GroupEntry.matchURI.
GroupEntry.matchURI: 376
Util.resolve: 94
CatalogResolverImpl.resolve: 143
The REWRITEURI and URISUFFIX cases set both the match and the length of the match, but the GROUP case only sets the match, not the length. Therefore, upon exiting the loop, the length is still zero, and it behaves as if there was no match.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run test files given below.
src/main/java/XmlCatalogURISuffixFailsInGroup.java
src/main/resources/XmlCatalogURISuffixFailsInGroup.xml
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Runs with no exceptions thrown.
ACTUAL -
javax.xml.catalog.CatalogException: JAXP09040002: No match found for href 'http://www.example.com/B/CommonFileB1.xml' and base 'null'.
at java.xml/javax.xml.catalog.CatalogMessages.reportError(CatalogMessages.java:74)
at java.xml/javax.xml.catalog.CatalogResolverImpl.resolve(CatalogResolverImpl.java:153)
at XMLCatalogURISuffixFailsInGroup.testB1_groupWithoutBase(XMLCatalogURISuffixFailsInGroup.java:45)
at XMLCatalogURISuffixFailsInGroup.main(XMLCatalogURISuffixFailsInGroup.java:19)
---------- BEGIN SOURCE ----------
---- Java: XmlCatalogURISuffixFailsInGroup.java ----
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.MissingResourceException;
import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogManager;
import javax.xml.catalog.CatalogResolver;
import javax.xml.transform.Source;
public class XMLCatalogURISuffixFailsInGroup {
public static void main(String[] ignore) throws MissingResourceException {
XMLCatalogURISuffixFailsInGroup tst = new XMLCatalogURISuffixFailsInGroup();
tst.setup();
try { tst.testA1_noGroup(); }
catch (Throwable th) { th.printStackTrace(); }
try { tst.testB1_groupWithoutBase(); }
catch (Throwable th) { th.printStackTrace(); }
try { tst.testC1_groupWithBase(); }
catch (Throwable th) { th.printStackTrace(); }
}
private CatalogResolver resolver;
private void setup() {
String catalogName = "XMLCatalogURISuffixFailsInGroup.xml";
URI catalogUri = getResourceURI(catalogName);
this.resolver =
CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogUri);
}
public void testA1_noGroup() {
// srcA1 succeeds
Source srcA1 =
this.resolver.resolve("http://www.example.com/A/CommonFileA1.xml", null);
assert srcA1.getSystemId().endsWith("LocalFileA1.xml"): srcA1.getSystemId();
System.out.println("srcA1: "+srcA1.getSystemId());
System.out.println();
}
public void testB1_groupWithoutBase() {
// srcB fails because it is in a catalog group
Source srcB1 =
this.resolver.resolve("http://www.example.com/B/CommonFileB1.xml", null);
assert srcB1.getSystemId().endsWith("LocalFileB1.xml"): srcB1.getSystemId();
System.out.println("srcB1: "+srcB1.getSystemId());
System.out.println();
}
public void testC1_groupWithBase() {
// srcC1 fails because it is in a catalog group
Source srcC1 =
this.resolver.resolve("http://www.example.com/C/CommonFileC1.xml", null);
assert srcC1.getSystemId().endsWith("LocalFileC1.xml"): srcC1.getSystemId();
System.out.println("srcC1: "+srcC1.getSystemId());
System.out.println();
}
private static URI getResourceURI(String resourceName)
throws MissingResourceException {
Class<?> loader = XMLCatalogURISuffixFailsInGroup.class;
URL resourceUrl = loader.getResource(resourceName);
if (resourceUrl == null)
throw new MissingResourceException(resourceName, loader.getName(), null);
URI resourceUri;
try { resourceUri = resourceUrl.toURI(); }
catch (URISyntaxException never) { throw new AssertionError(never); }
return resourceUri;
}
}
---- resource: XmlCatalogURISuffixFailsInGroup.xml ---
<!DOCTYPE catalog
PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "XML_Catalogs_v1.1.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="system" resolve="strict">
<uriSuffix uriSuffix="/A/CommonFileA1.xml"
uri="localMirrorA/LocalFileA1.xml"/>
<group>
<uriSuffix uriSuffix="/B/CommonFileB1.xml"
uri="localMirrorB/LocalFileB1.xml"/>
<uriSuffix uriSuffix="/B/CommonFileB2.xml"
uri="localMirrorB/LocalFileB2.xml"/>
</group>
<group baseURI="localMirrorC">
<uriSuffix uriSuffix="/C/CommonFileC1.xml"
uri="LocalFileC1.xml"/>
<uriSuffix uriSuffix="/C/CommonFileC2.xml"
uri="LocalFileC2.xml"/>
</group>
</catalog>
---------- END SOURCE ----------
FREQUENCY : always
Tested JDK 9, JDK 10.0.2, OpenJDK 11.0.1
A DESCRIPTION OF THE PROBLEM :
An XML <Catalog> with a <group> of <uriSuffix> matchers fails to match.
Match succeeds if similar matcher is not in a <group>.
Possible diagnosis:
Stepping through the code, the problem appears to be with javax.xml.catalog.CatalogResolverImpl, specifically in javax.xml.catalog.GroupEntry.matchURI.
GroupEntry.matchURI: 376
Util.resolve: 94
CatalogResolverImpl.resolve: 143
The REWRITEURI and URISUFFIX cases set both the match and the length of the match, but the GROUP case only sets the match, not the length. Therefore, upon exiting the loop, the length is still zero, and it behaves as if there was no match.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run test files given below.
src/main/java/XmlCatalogURISuffixFailsInGroup.java
src/main/resources/XmlCatalogURISuffixFailsInGroup.xml
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Runs with no exceptions thrown.
ACTUAL -
javax.xml.catalog.CatalogException: JAXP09040002: No match found for href 'http://www.example.com/B/CommonFileB1.xml' and base 'null'.
at java.xml/javax.xml.catalog.CatalogMessages.reportError(CatalogMessages.java:74)
at java.xml/javax.xml.catalog.CatalogResolverImpl.resolve(CatalogResolverImpl.java:153)
at XMLCatalogURISuffixFailsInGroup.testB1_groupWithoutBase(XMLCatalogURISuffixFailsInGroup.java:45)
at XMLCatalogURISuffixFailsInGroup.main(XMLCatalogURISuffixFailsInGroup.java:19)
---------- BEGIN SOURCE ----------
---- Java: XmlCatalogURISuffixFailsInGroup.java ----
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.MissingResourceException;
import javax.xml.catalog.CatalogFeatures;
import javax.xml.catalog.CatalogManager;
import javax.xml.catalog.CatalogResolver;
import javax.xml.transform.Source;
public class XMLCatalogURISuffixFailsInGroup {
public static void main(String[] ignore) throws MissingResourceException {
XMLCatalogURISuffixFailsInGroup tst = new XMLCatalogURISuffixFailsInGroup();
tst.setup();
try { tst.testA1_noGroup(); }
catch (Throwable th) { th.printStackTrace(); }
try { tst.testB1_groupWithoutBase(); }
catch (Throwable th) { th.printStackTrace(); }
try { tst.testC1_groupWithBase(); }
catch (Throwable th) { th.printStackTrace(); }
}
private CatalogResolver resolver;
private void setup() {
String catalogName = "XMLCatalogURISuffixFailsInGroup.xml";
URI catalogUri = getResourceURI(catalogName);
this.resolver =
CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogUri);
}
public void testA1_noGroup() {
// srcA1 succeeds
Source srcA1 =
this.resolver.resolve("http://www.example.com/A/CommonFileA1.xml", null);
assert srcA1.getSystemId().endsWith("LocalFileA1.xml"): srcA1.getSystemId();
System.out.println("srcA1: "+srcA1.getSystemId());
System.out.println();
}
public void testB1_groupWithoutBase() {
// srcB fails because it is in a catalog group
Source srcB1 =
this.resolver.resolve("http://www.example.com/B/CommonFileB1.xml", null);
assert srcB1.getSystemId().endsWith("LocalFileB1.xml"): srcB1.getSystemId();
System.out.println("srcB1: "+srcB1.getSystemId());
System.out.println();
}
public void testC1_groupWithBase() {
// srcC1 fails because it is in a catalog group
Source srcC1 =
this.resolver.resolve("http://www.example.com/C/CommonFileC1.xml", null);
assert srcC1.getSystemId().endsWith("LocalFileC1.xml"): srcC1.getSystemId();
System.out.println("srcC1: "+srcC1.getSystemId());
System.out.println();
}
private static URI getResourceURI(String resourceName)
throws MissingResourceException {
Class<?> loader = XMLCatalogURISuffixFailsInGroup.class;
URL resourceUrl = loader.getResource(resourceName);
if (resourceUrl == null)
throw new MissingResourceException(resourceName, loader.getName(), null);
URI resourceUri;
try { resourceUri = resourceUrl.toURI(); }
catch (URISyntaxException never) { throw new AssertionError(never); }
return resourceUri;
}
}
---- resource: XmlCatalogURISuffixFailsInGroup.xml ---
<!DOCTYPE catalog
PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "XML_Catalogs_v1.1.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="system" resolve="strict">
<uriSuffix uriSuffix="/A/CommonFileA1.xml"
uri="localMirrorA/LocalFileA1.xml"/>
<group>
<uriSuffix uriSuffix="/B/CommonFileB1.xml"
uri="localMirrorB/LocalFileB1.xml"/>
<uriSuffix uriSuffix="/B/CommonFileB2.xml"
uri="localMirrorB/LocalFileB2.xml"/>
</group>
<group baseURI="localMirrorC">
<uriSuffix uriSuffix="/C/CommonFileC1.xml"
uri="LocalFileC1.xml"/>
<uriSuffix uriSuffix="/C/CommonFileC2.xml"
uri="LocalFileC2.xml"/>
</group>
</catalog>
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8216286 javax.xml.catalog.CatalogResolverImpl: GroupEntry.matchURI fails to match
- Resolved
-
JDK-8217460 javax.xml.catalog.CatalogResolverImpl: GroupEntry.matchURI fails to match
- Resolved
-
JDK-8219235 javax.xml.catalog.CatalogResolverImpl: GroupEntry.matchURI fails to match
- Resolved
-
JDK-8222560 javax.xml.catalog.CatalogResolverImpl: GroupEntry.matchURI fails to match
- Resolved