Project

Profile

Help

Is there any way that Saxon 11 might stop writing to System.out?

Added by Martin Honnen about 1 year ago

I have run into a strange problem, I have written some sample Java code compiled with Java 8 Temurin doing e.g.

    public static void main(String[] args) throws FileNotFoundException, SaxonApiException {
        Processor processor = new Processor(false);

        System.out.println("Example 1:");

        JsonAsXdmValue2XdmValue(processor);

        System.out.println();

        System.out.println("Example 2:");

        Json2Xml2Xml2Json(processor);
    }

and for reasons I don't understand both in the IntelliJ IDE (both when I just run the code or when I debug it) as well as when I run the compiled code directly with java.exe from the command line the output is cut off or not produced after the first method call to JsonAsXdmValue2XdmValue(processor); so I get only e.g.

Example 1:
[
  { "Date 2":"31\/12\/2021", "OS":9, "Paid":23, "Category 1":"Marine", "Date 1":"31\/03\/2003" },
  { "Date 2":"31\/03\/2022", "OS":5, "Paid":2, "Category 1":"Marine", "Date 1":"31\/12\/2021" },
  {
    "Date 2": "31\/12\/2022",
    "OS": 4754,
    "Paid": 521,
    "Category 1": "Engineering",
    "Date 1": "31\/03\/2005"
  },
  {
    "Date 2": "31\/03\/2022",
    "OS": 533,
    "Paid": 134,
    "Category 1": "Engineering",
    "Date 1": "31\/12\/2021"
  }
]

instead of the full output I get when I switch to Java 11 and Saxon 12.0 where I get e.g.

Example 1:
[
  { "Date 2":"31\/12\/2021", "OS":9, "Paid":23, "Category 1":"Marine", "Date 1":"31\/03\/2003" },
  { "Date 2":"31\/03\/2022", "OS":5, "Paid":2, "Category 1":"Marine", "Date 1":"31\/12\/2021" },
  {
    "Date 2": "31\/12\/2022",
    "OS": 4754,
    "Paid": 521,
    "Category 1": "Engineering",
    "Date 1": "31\/03\/2005"
  },
  {
    "Date 2": "31\/03\/2022",
    "OS": 533,
    "Paid": 134,
    "Category 1": "Engineering",
    "Date 1": "31\/12\/2021"
  }
]
Example 2:

 [ 
  { "Category 1" : "Marine",
   "Date 1" : "31\/03\/2003",
   "Date 2" : "31\/12\/2021",
   "Paid" : 23,
   "OS" : 9 },
  
  { "Category 1" : "Marine",
   "Date 1" : "31\/12\/2021",
   "Date 2" : "31\/03\/2022",
   "Paid" : 2,
   "OS" : 5 },
  
  { "Category 1" : "Engineering",
   "Date 1" : "31\/03\/2005",
   "Date 2" : "31\/12\/2022",
   "Paid" : 521,
   "OS" : 4754 },
  
  { "Category 1" : "Engineering",
   "Date 1" : "31\/12\/2021",
   "Date 2" : "31\/03\/2022",
   "Paid" : 134,
   "OS" : 533 } ]

I am not sure what goes wrong, I have put the full Java 8/Saxon 11.5 project online at https://github.com/martin-honnen/SaxonJson2JsonExample1.

I have no idea whether it is a JRE or Saxon problem but I can't explain why there is no output written to System.out for the after the first function call.


Replies (6)

Please register to reply

RE: Is there any way that Saxon 11 might stop writing to System.out? - Added by Martin Honnen about 1 year ago

I have tried it on a second system with Eclipse JRE 8. With both System.out or passing the same PrintStream over a File the output ends after the first example. With a StringWriter I get all output (i.e. of both examples).

Is there any chance the Saxon Serializer is closing the System.out or any PrintStream it is handed over with Saxon HE 11(.5) but not with Saxon 12?

Or am I shooting myself somewhere in the foot or it the JRE kind of messed up?

But I have also tried Saxon HE 11.5 with JRE 11 and the System.out output is terminated after the first example.

RE: Is there any way that Saxon 11 might stop writing to System.out? - Added by Martin Honnen about 1 year ago

Is that related to https://saxonica.plan.io/issues/5552#note-18 which says a fix to 12 has been applied: "On the 12.x branch (but not 11.x), while working on this bug, I changed the JsonEmitter and AdaptiveEmitter to have a mustClose flag, and to use it in the same way as the Emitter -- specifically, the output writer is not closed at close() time unless the mustClose flag is set". Does that mean 11.5 is closing the Stream for JSON output?

RE: Is there any way that Saxon 11 might stop writing to System.out? - Added by Norm Tovey-Walsh about 1 year ago

Norm really needs to get the HE 11.5 and 12.0 branch into
https://saxonica.plan.io/projects/saxonmirrorhe/repository.

I will do that today.

Be seeing you,
norm

--
Norm Tovey-Walsh
Saxonica

RE: Is there any way that Saxon 11 might stop writing to System.out? - Added by Norm Tovey-Walsh about 1 year ago

Norm really needs to get the HE 11.5 and 12.0 branch into
https://saxonica.plan.io/projects/saxonmirrorhe/repository.

Done: 10.9, 11.5, and 12.0 pushed and tagged.

Be seeing you,
norm

--
Norm Tovey-Walsh
Saxonica

    (1-6/6)

    Please register to reply