stevedlawrence commented on a change in pull request #216: Do not abort when an
import/includes fails
URL: https://github.com/apache/incubator-daffodil/pull/216#discussion_r282934428
##########
File path:
daffodil-lib/src/main/scala/org/apache/daffodil/xml/DaffodilXMLLoader.scala
##########
@@ -237,12 +237,7 @@ class DFDLCatalogResolver private ()
optURI match {
case None => null
case Some(uri) => {
- val resourceAsStream =
- try {
- uri.toURL.openStream() // This will work.
- } catch {
- case _: java.io.IOException => Assert.invariantFailed("found
resource but couldn't open")
- }
+ val resourceAsStream = uri.toURL.openStream()
Review comment:
The DFDLCatalogResolver, where this code lives, doesn't mixin ThrowsSDE, so
that would be a change to allow it to do that. In fact, this function actually
gets called from deep within Xerces, and looking at the Xerces code, I think
this function actually shouldn't ever throw an exception, including an SDE or
IOException. I believe it should should return either an Input or null. And if
null, Xerces then does some stuff to figure out why it failed and throw an
actual exception, which Daffodil already handles and converts to an SDE
appropriately.
So I think we should actually just catch the IOException and return null
here instead.
Interestingly, the error ends up the same whether we catch and return null
or let it bubble up, which is something like this:
> [error] Schema Definition Error: Error loading schema due to
/this/path/does/not/exist (No such file or directory)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services