@Override
    public Schema readSchema(InputStream in) throws IOException {
        DataInputStream dataInputStream = new DataInputStream(in);

        if (dataInputStream.readByte() != 0) {
            throw new IOException("Unknown data format. Magic number does not match");
        } else {
            int schemaId = dataInputStream.readInt();

            try {
                return schemaRegistryClient.getById(schemaId);
            } catch (RestClientException e) {
                throw new IOException(
                        format("Could not find schema with id %s in registry", schemaId), e);
            }
        }
    }
@Test
    void testMagicByteVerification() throws Exception {
        MockSchemaRegistryClient client = new MockSchemaRegistryClient();
        int schemaId = client.register("testTopic", Schema.create(Schema.Type.BOOLEAN));

        ConfluentSchemaRegistryCoder coder = new ConfluentSchemaRegistryCoder(client);
        ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
        DataOutputStream dataOutputStream = new DataOutputStream(byteOutStream);
        dataOutputStream.writeByte(5);
        dataOutputStream.writeInt(schemaId);
        dataOutputStream.flush();

        try (ByteArrayInputStream byteInStream =
                new ByteArrayInputStream(byteOutStream.toByteArray())) {
            assertThatThrownBy(() -> coder.readSchema(byteInStream))
                    .isInstanceOf(IOException.class);
        }
    }