Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71856

TeeOutputStream writes to second OutputStream twice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • remoting
    • None
    • org.jenkins-ci.main:remoting:4.3@jar
    • 3148.v532a_7e715ee3

      The following simple reproduction demonstrates that the second OutputStream passed to hudons.remoting.TeeOutputStream gets data written to it twice (unexpected/bug), wheres the first OutputStream only gets it once (as expected). The issue is so simple, I have no idea how this isn't a known bug causing all sorts of issues, so I assume I'm missing something.  Although maybe it only affects local FilePaths, and maybe this ticket is related (was closed as can't reproduce):

      https://issues.jenkins.io/browse/JENKINS-38520

      Also of note, I switched the import to 
      import org.apache.commons.io.output.TeeOutputStream and it behaves as expected, (each stream/file getting messages once.)
       
       

      import hudson.remoting.TeeOutputStream  
      //import org.apache.commons.io.output.TeeOutputStream 
      
      File file = new File("test.txt")
      File file2 = new File("test2.txt")
      OutputStream os = new FileOutputStream(file)
      OutputStream os2 = new FileOutputStream(file2)
      TeeOutputStream tos = new TeeOutputStream(os, os2)
      PrintWriter writer = tos.newPrintWriter()
      writer.write("testing ")
      writer.flush()
      assert file.getText() == "testing "
      assert file2.getText() == "testing testing "

       

            basil Basil Crow
            solvingj jerry wiltse
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: