Source:
<code>private KafkaConsumer<byte[], byte[]> getKafkaConsumer() { final Map<String, Object> consumerConfigs = KafkaConsumerConfigs.getConsumerProperties(); final Properties props = new Properties(); addConsumerPropertiesFromConfig(props, sortingMapper, consumerProperties); props.putAll(consumerConfigs); ClassLoader currCtxCl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Deserializer keyDeserializerObject; Deserializer valueDeserializerObject; try { Class keyDeserializerClass = Class.forName(props.getProperty("key.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer")); Method keyDeserializerMethod = keyDeserializerClass.getMethod("deserialize", String.class, byte[].class); Type keyDeserializerReturnType = keyDeserializerMethod.getGenericReturnType(); if (keyDeserializerReturnType.getTypeName().equals("byte[]")) { keyDeserializerObject = (Deserializer) keyDeserializerClass.getConstructor().newInstance(); } else { throw new IllegalArgumentException("Key deserializer must return a byte array (byte[]), " + keyDeserializerClass.getName() + " returns " + keyDeserializerReturnType.getTypeName()); } } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new StreamException(e); } try { <START> Class valueDeserializerClass = Class.forName(props.getProperty("value.deserializer", "org.apache.kafka.common.serialization.ByteArrayDeserializer")); <END> Method valueDeserializerMethod = valueDeserializerClass.getMethod("deserialize", String.class, byte[].class); Type valueDeserializerReturnType = valueDeserializerMethod.getGenericReturnType(); if (valueDeserializerReturnType.getTypeName().equals("byte[]")) { valueDeserializerObject = (Deserializer) valueDeserializerClass.getConstructor().newInstance(); } else { throw new IllegalArgumentException("Key deserializer must return a byte array (byte[]), " + valueDeserializerClass.getName() + " returns " + valueDeserializerReturnType.getTypeName()); } } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new StreamException(e); } return new KafkaConsumer<>(props, keyDeserializerObject, valueDeserializerObject); } finally { Thread.currentThread().setContextClassLoader(currCtxCl); } }</code><technical_language>Instead of "org.apache.kafka.common.serialization.ByteArrayDeserializer" consider ByteArrayDeserializer.getClass().getTypeName()</technical_language>

Target:
private KafkaConsumer<byte[], byte[]> getKafkaConsumer() { final Map<String, Object> consumerConfigs = KafkaConsumerConfigs.getConsumerProperties(); final Properties props = new Properties(); addConsumerPropertiesFromConfig(props, sortingMapper, consumerProperties); props.putAll(consumerConfigs); ClassLoader currCtxCl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Deserializer keyDeserializerObject = getKafkaDeserializer(props, "key.deserializer"); Deserializer valueDeserializerObject = getKafkaDeserializer(props, "value.deserializer"); return new KafkaConsumer<>(props, keyDeserializerObject, valueDeserializerObject); } finally { Thread.currentThread().setContextClassLoader(currCtxCl); } }