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 void
close()
Close only once.void
flush()
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 IOException
Don't flush empty buffer if already closed.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classBufferedOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
Close only once.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
-