-
Notifications
You must be signed in to change notification settings - Fork 2
bridge: be tolerant to missing references #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -164,7 +164,7 @@ protected void initializeAnimation() { | |||
t = element.getParentNode(); | |||
} else { | |||
t = ctx.getReferencedElement(element, uri); | |||
if (t.getOwnerDocument() != element.getOwnerDocument()) { | |||
if (t == null || t.getOwnerDocument() != element.getOwnerDocument()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this still throw an exception when the referenced element cannot be found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this still throw an exception when the referenced element cannot be found?
Yes, and it's the only thing that can be done with the current API, unless you want to silently ignore the problem.
I could change the API so the error can be processed, but that should be a different commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ba1fbcd
@@ -265,6 +266,15 @@ public static String getChainableAttributeNS(Element element, String namespaceUR | |||
URIResolver resolver = ctx.createURIResolver(svgDoc, loader); | |||
e = resolver.getElement(purl.toString(), e); | |||
refs.add(purl); | |||
} catch (FileNotFoundException ioEx) { | |||
BridgeException ex = new BridgeException(ctx, e, ioEx, ERR_URI_IO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about isolating this duplicated code, possibly by delegating to the UserAgent
using a static method?
catch(final FileNotFoundException fnfEx) {
final BridgeExceptoin ex = new BridgeException(...);
UserAgent.handle( ex, ctx );
return "";
}
Doesn't have to go to the UserAgent
, but it would be nice to see the duplication in one spot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could be a non-static method call to ctx
but the code would be less readable (one has to look at what that method does) and more bytecode would be generated.
Instead of throwing an exception (and stop processing) on a missing reference, just report the error via the user agent and keep processing. This is what a conformant user agent is supposed to do. There are other circumstances (like other I/O errors) where it would make sense to behave in the same way, but this is deferred to future updates. The `slideshow` and `extension` modules are also affected.
0020ede
to
ba1fbcd
Compare
Instead of throwing an exception (and stop processing) on a missing reference, just report the error via the user agent and keep processing. This is what a conformant user agent is supposed to do.
There are other circumstances (like other I/O errors) where it would make sense to behave in the same way, but this may break POLA for legacy applications and is deferred to future updates. User feedback is encouraged.
The
slideshow
andextension
modules are also affected by this PR.Fixes #80.