@Override
    public UUID deserialize(String topic, Headers headers, ByteBuffer data) {
        try {
            if (data == null) {
                return null;
            }

            if (data.hasArray()) {
                return UUID.fromString(new String(data.array(), data.arrayOffset() + data.position(), data.remaining(), encoding));
            }
            return UUID.fromString(new String(Utils.toArray(data), encoding));
        } catch (UnsupportedEncodingException e) {
            throw new SerializationException("Error when deserializing ByteBuffer to UUID due to unsupported encoding " + encoding, e);
        } catch (IllegalArgumentException e) {
            throw new SerializationException("Error parsing data into UUID", e);
        }
    }
We are converting the byte array to String before deserializing to UUID. String encoding defaults to UTF8 and can be customized by setting
 the property key.deserializer.encoding, value.deserializer.encoding or deserializer.encoding. The first two take precedence over the last.
clients/src/main/java/org/apache/kafka/common/serialization/UUIDDeserializer.java