jkesselm commented on code in PR #129:
URL: https://github.com/apache/xalan-java/pull/129#discussion_r1408586736


##########
serializer/src/main/java/org/apache/xml/serializer/Version.java:
##########
@@ -55,7 +55,16 @@ public final class Version
 
   private static void readProperties() {
     Properties pomProperties = new Properties();
-    try (InputStream fromResource = 
Version.class.getClassLoader().getResourceAsStream(POM_PROPERTIES_PATH)) {
+    ClassLoader classLoader = Version.class.getClassLoader();
+    if (classLoader == null) {
+      // Oops! Someone put Xalan is on the bootstrap class loader (BCL) -> fall
+      // back to the system class loader, because there is no Classloader
+      // instance for the BCL (native code). Due to class loader hierarchy,
+      // however, the resource will also be found when asking for it from a
+      // level below the BCL.
+      classLoader = ClassLoader.getSystemClassLoader();
+    }
+    try (InputStream fromResource = 
classLoader.getResourceAsStream(POM_PROPERTIES_PATH)) {

Review Comment:
   @vlsi: Xalan's tests currently live in the xalan-test project. I've done a 
quick grep there and indeed I don't see a regression test for Version. 
   
   If you think we need one Right Now, may I suggest you write and submit one 
rather than asking someone else to do so? That would require either working 
with the existing API test driver (to be ported later), or with Maven's 
approach to testing (running ahead of test being moved into the main project).
   
   Note that since this value will change over time, a naive test probably 
can't do much more than check for self-consistency. Checking against a 
reference value raises the same questions of how that value is obtained, 
until/unless that can be driven from the same Source Of Truth as the build. 
   
   Though. I suppose one could check that the semantic version is equal to or 
more recent than the version active when this test was last modified. 
Personally I'd consider that, or even the bare consistency check, adequate for 
first draft. 



-- 
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