@Override
    public void write(int b) throws IOException {

        if (buffer.length <= bufferIdx) {
            flushInternalBuffer();
        }

        buffer[bufferIdx] = (byte) b;
        ++bufferIdx;
    }
@Test
    void testFailingPrimaryWriteArrayFail() throws Exception {
        DuplicatingCheckpointOutputStream duplicatingStream =
                createDuplicatingStreamWithFailingPrimary();
        testFailingPrimaryStream(duplicatingStream, () -> duplicatingStream.write(new byte[512]));
    }