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

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

        buffer[bufferIdx] = (byte) b;
        ++bufferIdx;
    }
@Test
    void testPrimaryWriteFail() throws Exception {
        DuplicatingCheckpointOutputStream duplicatingStream =
                createDuplicatingStreamWithFailingPrimary();
        testFailingPrimaryStream(
                duplicatingStream,
                () -> {
                    for (int i = 0; i < 128; i++) {
                        duplicatingStream.write(42);
                    }
                });
    }