ppkarwasz commented on code in PR #42:
URL: https://github.com/apache/commons-xml/pull/42#discussion_r3856844083


##########
src/main/java/org/apache/commons/xml/FallbackIgnoreLSResourceResolver.java:
##########
@@ -60,10 +65,21 @@ LSResourceResolver getDelegate() {
         return delegate;
     }
 
+    /**
+     * Tells whether the input carries content, so the consumer never falls 
back to resolving its identifiers itself.
+     *
+     * @param input The input the caller's resolver returned.
+     * @return Whether a character stream, byte stream, or non-empty string 
data is present.
+     */
+    private static boolean hasContent(final LSInput input) {
+        // Empty string data counts as no content: the JDK's 
DOMEntityResolverWrapper discards it (see the unresolved branch below).
+        return input.getCharacterStream() != null || input.getByteStream() != 
null || input.getStringData() != null && !input.getStringData().isEmpty();
+    }
+
     @Override
     public LSInput resolveResource(final String type, final String 
namespaceURI, final String publicId, final String systemId, final String 
baseURI) {
         final LSInput resolved = delegate != null ? 
delegate.resolveResource(type, namespaceURI, publicId, systemId, baseURI) : 
null;
-        if (resolved != null) {
+        if (resolved != null && hasContent(resolved)) {

Review Comment:
   Good catch!
   
   However, I rolled back the changes to `FallbackIgnoreLSResourceResolver` in 
https://github.com/apache/commons-xml/pull/42/commits/ae189aac6d2fabcd49f418e6202d027f2df8540a,
 because I don't think they make sense (explication below), so this no longer 
applies.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to