stevedlawrence commented on code in PR #1067:
URL: https://github.com/apache/daffodil/pull/1067#discussion_r1293703608
##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -226,14 +226,30 @@ class CLIConf(arguments: Array[String], stdout:
PrintStream, stderr: PrintStream
implicit def rootNSConverter =
org.rogach.scallop.singleArgConverter[RefQName](qnameConvert _)
implicit def fileResourceURIConverter = singleArgConverter[URI]((s: String)
=> {
- val file = new File(s)
- val uri =
- if (file.isFile()) {
- Some(file.toURI)
- } else {
- Misc.getResourceRelativeOption(s, None)
+ val optURI = None
+ .orElse {
+ val file = new File(s)
+ if (file.isFile) Some(file.toURI)
+ else None
+ }
+ .orElse {
+ if (s.startsWith("/")) {
+ val resource = this.getClass.getResource(s)
+ Option(resource.toURI)
Review Comment:
Yep, good catch. At one point this was just `Option(resource)`, and null
was fine. But the `toURI` is needed since the resource is a URL. I fixed it in
the XMLUtils function but not here. Will fix.
I'll see if I can add some CLI tests that hit these code paths. These are
important use cases we want to make sure we don't accidentally break. I don't
think we had tests for them before and that's probably a mistake.
--
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]