Chris Egerton created KAFKA-8550:
------------------------------------
Summary: Connector validation fails with aliased converters
Key: KAFKA-8550
URL: https://issues.apache.org/jira/browse/KAFKA-8550
Project: Kafka
Issue Type: Bug
Components: KafkaConnect
Reporter: Chris Egerton
Assignee: Chris Egerton
During connector config validation,
[ConfigDef.validateAll(...)|https://github.com/apache/kafka/blob/1ae92914e28919a97520e91bfd0e588d55eb1774/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java#L497-L513]
is invoked using a [Connector
ConfigDef|https://github.com/apache/kafka/blob/trunk/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectorConfig.java].
This ConfigDef contains definitions for the [key and value
converters|https://github.com/apache/kafka/blob/1ae92914e28919a97520e91bfd0e588d55eb1774/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectorConfig.java#L72-L78],
which have the type
[ConfigDef.Type.CLASS|https://github.com/apache/kafka/blob/1ae92914e28919a97520e91bfd0e588d55eb1774/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectorConfig.java#L167-L168].
When plugin aliases are used for these configs, an error is encountered and
the connector configuration is rejected.
This error occurs because
[Class.forName(...)|https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#forName-java.lang.String-boolean-java.lang.ClassLoader-]
is used to load the classes for these configs during validation. Even though
the DelegatingClassLoader used by Connect successfully loads the requested
class in its
[loadClass(...)|https://github.com/apache/kafka/blob/1ae92914e28919a97520e91bfd0e588d55eb1774/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/DelegatingClassLoader.java#L358-L376]
method, some (if not all) implementations of the Java runtime will then
perform a check in their native Class.forName method to verify that the name of
the loaded class matches the requested class name. For example, see [this
section of
OpenJDK|https://github.com/openjdk/jdk/blob/515e7600df738ebf8c42d38e322def012385e1b9/src/hotspot/share/classfile/systemDictionary.cpp#L1508-L1528]
that performs the aforementioned check.
A few possible fixes that come to mind include altering the connector
validation in the AbstractHerder class to not use the
ConfigDef.validateAll(...) method, or altering the logic used by the ConfigDef
in its validateAll method for configs of type ConfigDef.Type.CLASS to use
[ClassLoader.loadClass(...)|https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html#loadClass-java.lang.String-]
either instead of or in addition to Class.forName(...).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)