vlsi commented on PR #133:
URL: https://github.com/apache/xalan-java/pull/133#issuecomment-1836476466

   > It is called defensive programming
   
   In any case, if you want to be extremely defensive (I do not see reasons for 
this specific case), you can have try-catch:
   
   ```diff
   @@ -77,7 +77,14 @@ public class Version {
        // Because we expect the properties file to be in the same 
directory/package
        // as this class, the relative path comes in handy and as a bonus is 
also
        // relocation-friendly (think Maven Shade).
   -    return Version.class.getResourceAsStream("version.properties");
   +    try {
   +      return Version.class.getResourceAsStream("version.properties");
   +    } catch(Exception e) {
   +      new IllegalStateException("Unable to find Xalan's version.properties 
resource", e)
   +              .printStackTrace();
   +      // It must not happen, however, we keep it just in case
   +      return null;
   +    }
      }
   ```
   
   Frankly, I do not see why one would have that (we should trust 
`Class.getResourceAsStream` to a degree), however, adding try-catch there does 
not break the code, it fulfills all your requests, it yields the same backward 
compatibility, the same test coverage, and it yields better error messages as I 
can have separate messages to clarify the error condition (e.g. unable to parse 
resource vs unable to find the resource in the first place)
   
   At least, I truly do not see why you said `Not true`. Of course, the very 
same tests could be written without Mockito with exactly same efforts.


-- 
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: dev-unsubscr...@xalan.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org
For additional commands, e-mail: dev-h...@xalan.apache.org

Reply via email to