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 "
- causes
-
JENKINS-38520 Every message in agent log appears twice with the -agentLog option
- Closed
- links to