title: Using piped streams and jaxb
body: <p>I cannot figure out whether I am using piped streams improperly or whether my problem is elsewhere in the issue below.</p>
  
  <p>I have an object (called 'adi') that I marshal into a file as shown below:</p>
  
  <pre><code>  final PipedInputStream pipedInputStream = new PipedInputStream();
    OutputStream pipedOutputStream = null;
    pipedOutputStream = new PipedOutputStream(pipedInputStream);
    log.info("marshalling away");
    final OutputStream outputStream = new FileOutputStream(new File(
            "target/test.xml"));
    m.marshal(adi, outputStream);
    outputStream.flush();
    outputStream.close();
    pipedOutputStream.write("test".getBytes());
    // m.marshal(adi, pipedOutputStream);
    pipedOutputStream.flush();
    pipedOutputStream.close();
    log.info("marshalling done");
    return pipedInputStream;
  </code></pre>
  
  <ul>
  <li>That code generates a file target/test.xml with the content that I expect (marshalled object), validating that the marshalling into the outputStream works properly.  </li>
  <li>The code also generates a pipedInputStream. If I iterate through the bytes pulled from that stream and print them, it displays "test", validating the fact that my input/output pipe stream is properly setup and working.</li>
  </ul>
  
  <p>Yet, when I uncomment  </p>
  
  <pre><code>  //m.marshal(adi, pipedOutputStream);  
  </code></pre>
  
  <p>the code hangs forever (never displaying "marshalling done") while I would expect the code to return an input stream containing "test" followed by my marshalled object.</p>
  
  <p>What am I missing?</p>
  
  <p>Thanks</p>