private static PipedInputStream createInputStream ( final Jar jar ) throws IOException { final CloseAwarePipedInputStream pin = new CloseAwarePipedInputStream ( ) ; final PipedOutputStream pout = new PipedOutputStream ( pin ) ; new Thread ( ) { public void run ( ) { try { jar . write ( pout ) ; } catch ( Exception e ) { if ( pin . closed ) { // logging the message at DEBUG logging instead // -- reading thread probably stopped reading LOG . debug ( "Bundle cannot be generated, pipe closed by reader" , e ) ; } else { LOG . warn ( "Bundle cannot be generated" , e ) ; } } finally { try { jar . close ( ) ; pout . close ( ) ; } catch ( IOException ignore ) { // if we get here something is very wrong LOG . error ( "Bundle cannot be generated" , ignore ) ; } } } } . start ( ) ; return pin ; }
Creates an piped input stream for the wrapped jar . This is done in a thread so we can return quickly .