garydgregory commented on code in PR #94:
URL: https://github.com/apache/commons-secure-xml/pull/94#discussion_r4000284373
##########
src/main/java/org/apache/commons/xml/secure/SecureTransformerFactory.java:
##########
@@ -308,10 +308,21 @@ public TransformerHandler newTransformerHandler(final
Source source) throws Tran
return
secure(delegate.newTransformerHandler(SecureSAXParserFactory.secure(source,
overrideDefaultParser())));
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>Most implementations reject a {@link Templates} they did not
compile, some in the TrAX shape, others by casting it or its Transformer to
their
+ * own type. Both reach the caller as a {@link
TransformerConfigurationException}.</p>
+ */
@Override
public TransformerHandler newTransformerHandler(final Templates
templates) throws TransformerConfigurationException {
// Implementations cast templates.newTransformer() to their own
Transformer type, so hand them the wrapped implementation Templates, not the
wrapper.
- return secure(delegate.newTransformerHandler(unwrap(templates)));
+ final Templates unwrapped = unwrap(templates);
+ try {
+ return secure(delegate.newTransformerHandler(unwrapped));
+ } catch (final ClassCastException e) {
+ throw new TransformerConfigurationException("Underlying
implementation does not accept foreign Templates: " +
unwrapped.getClass().getName(), e);
Review Comment:
This message assumes too much IMO. The CCE could be caused by anything
really. I would just make the message functional and not interpret anything.
--
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]