public static <T extends IOReadableWritable> T createCopyWritable(T original)
            throws IOException {
        if (original == null) {
            return null;
        }

        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try (DataOutputViewStreamWrapper out = new DataOutputViewStreamWrapper(baos)) {
            original.write(out);
        }

        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        try (DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais)) {

            @SuppressWarnings("unchecked")
            T copy = (T) instantiate(original.getClass());
            copy.read(in);
            return copy;
        }
    }
@Test
    void testCopyWritable() throws Exception {
        WritableType original = new WritableType();
        WritableType copy = InstantiationUtil.createCopyWritable(original);

        assertThat(copy).isNotSameAs(original);
        assertThat(copy).isEqualTo(original);
    }