Package org.pentaho.di.workarounds
Class BufferedOutputStreamWithCloseDetection
- java.lang.Object
 - 
- java.io.OutputStream
 - 
- java.io.FilterOutputStream
 - 
- java.io.BufferedOutputStream
 - 
- org.pentaho.di.workarounds.BufferedOutputStreamWithCloseDetection
 
 
 
 
 
- 
- All Implemented Interfaces:
 Closeable,Flushable,AutoCloseable
public class BufferedOutputStreamWithCloseDetection extends BufferedOutputStream
Workaround for stream close issue under Java 8. The problem is: during Workbook writing to stream, Apache POI closes output stream itself. After that, ExcelWriteStep closes this stream also because it was open in the ExcelWriterStep. But Java 8 contains bug https://bugs.openjdk.java.net/browse/JDK-8042377 with second stream closing. As result, second close() throws exception. 
- 
- 
Field Summary
- 
Fields inherited from class java.io.BufferedOutputStream
buf, count 
- 
Fields inherited from class java.io.FilterOutputStream
out 
 - 
 
- 
Constructor Summary
Constructors Constructor Description BufferedOutputStreamWithCloseDetection(OutputStream out) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close only once.voidflush()Don't flush empty buffer if already closed.- 
Methods inherited from class java.io.BufferedOutputStream
write, write 
- 
Methods inherited from class java.io.FilterOutputStream
write 
- 
Methods inherited from class java.io.OutputStream
nullOutputStream 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
BufferedOutputStreamWithCloseDetection
public BufferedOutputStreamWithCloseDetection(OutputStream out)
 
 - 
 
- 
Method Detail
- 
flush
public void flush() throws IOExceptionDon't flush empty buffer if already closed.- Specified by:
 flushin interfaceFlushable- Overrides:
 flushin classBufferedOutputStream- Throws:
 IOException
 
- 
close
public void close() throws IOExceptionClose only once.- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Overrides:
 closein classFilterOutputStream- Throws:
 IOException
 
 - 
 
 -