tuxji commented on code in PR #821:
URL: https://github.com/apache/daffodil/pull/821#discussion_r1037779388


##########
daffodil-japi/src/test/java/org/apache/daffodil/example/TestJavaAPI.java:
##########
@@ -873,7 +873,7 @@ public void testJavaAPI20() throws IOException, 
ClassNotFoundException {
         InputSourceDataInputStream disDP = new 
InputSourceDataInputStream(fisDP);
         InputSourceDataInputStream disSAX = new 
InputSourceDataInputStream(fisSAX);
         ByteArrayOutputStream xmlBos = new ByteArrayOutputStream();
-        XMLTextInfosetOutputter outputter = new 
XMLTextInfosetOutputter(xmlBos, true);
+        XMLTextInfosetOutputter outputter = new 
XMLTextInfosetOutputter(xmlBos, true, null);

Review Comment:
   I'm surprised the Java compiler allowed null here instead of 
XMLOutputStyle.standard or XMLOutputStyle.prettyPrintSafe.  Even if the 
compiler doesn't complain, null is still passed into the Scala 
XMLTextInfosetOutputter (see 
<https://stackoverflow.com/questions/13059528/instantiate-a-scala-class-from-java-and-use-the-default-parameters-of-the-const>).
  
   
   The Java-API XMLTextInfosetOutputter has two overloaded 2-arg and 3-arg 
constructors.  There's no need to even call the 3-arg constructor here unless 
you want to cover the 3-arg constructor with a test, but 
XMLTestInfosetOutputter ended up making the wrong comparison anyway.  
XMLTextInfosetOutputter used an if statement with identity comparison to 
compare the null parameter to only one of XMLOutputStyle.standard or 
XMLOutputStyle.prettyPrintSafe so the identity comparison failed silently 
without throwing either NullPointerException or NoMatchException.



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

Reply via email to