Class FailOnCloseDataSink

  • All Implemented Interfaces:
    DataSink

    public final class FailOnCloseDataSink
    extends Object
    implements DataSink
    A DataSink that can simulate caching the bytes being written to it, and then failing to persist them when close() is called.
    • Method Detail

      • open

        public void open​(DataSpec dataSpec)
                  throws IOException
        Description copied from interface: DataSink
        Opens the sink to consume the specified data.

        Note: If an IOException is thrown, callers must still call DataSink.close() to ensure that any partial effects of the invocation are cleaned up.

        Specified by:
        open in interface DataSink
        Parameters:
        dataSpec - Defines the data to be consumed.
        Throws:
        IOException - If an error occurs opening the sink.
      • write

        public void write​(byte[] buffer,
                          int offset,
                          int length)
                   throws IOException
        Description copied from interface: DataSink
        Consumes the provided data.
        Specified by:
        write in interface DataSink
        Parameters:
        buffer - The buffer from which data should be consumed.
        offset - The offset of the data to consume in buffer.
        length - The length of the data to consume, in bytes.
        Throws:
        IOException - If an error occurs writing to the sink.