[ 
https://issues.apache.org/jira/browse/KAFKA-17150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17866541#comment-17866541
 ] 

Greg Harris commented on KAFKA-17150:
-------------------------------------

The difference seems to be caused by the difference between these two calls:

[https://github.com/apache/kafka/blob/b015a83f6d286965af999c39c0902584fb6fb9de/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L428]
 which passes the class alias into Class.forName, and

[https://github.com/apache/kafka/blob/b015a83f6d286965af999c39c0902584fb6fb9de/clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java#L776]
 which uses the alias to first load the class, and then calls Class.forName 
with the full name of the class.

These diverged a long time ago in KAFKA-8550 and the same bug resurfaced when 
we added more validation surrounding the converter classes.

> Connect converter validation does not accept class aliases
> ----------------------------------------------------------
>
>                 Key: KAFKA-17150
>                 URL: https://issues.apache.org/jira/browse/KAFKA-17150
>             Project: Kafka
>          Issue Type: Bug
>          Components: connect
>    Affects Versions: 3.8.0
>            Reporter: Greg Harris
>            Priority: Blocker
>             Fix For: 3.8.0
>
>
> Connect allows users to specify aliases instead of full classes when 
> configuring plugins. For example, the following configuration is valid:
> {noformat}
> {
>         "connector.class": "FileStreamSource",
>         "topic": "anything",
>         "key.converter": "JsonConverter"
> }{noformat}
> In <= 3.7.1 this will pass validation and function correctly.
> In 3.8.0-rc1 this will instead fail with this error message:
> {noformat}
> [2024-07-16 13:58:54,250] ERROR Failed to instantiate key converter class 
> JsonConverter; this should have been caught by prior validation logic 
> (org.apache.kafka.connect.runtime.AbstractHerder:462)
> java.lang.ClassNotFoundException: JsonConverter
>       at java.base/java.lang.Class.forName0(Native Method)
>       at java.base/java.lang.Class.forName(Class.java:534)
>       at java.base/java.lang.Class.forName(Class.java:513)
>       at org.apache.kafka.common.utils.Utils.loadClass(Utils.java:426)
>       at org.apache.kafka.common.utils.Utils.newInstance(Utils.java:415)
>       at 
> org.apache.kafka.connect.runtime.AbstractHerder.validateConverterConfig(AbstractHerder.java:460)
>       at 
> org.apache.kafka.connect.runtime.AbstractHerder.validateKeyConverterConfig(AbstractHerder.java:528)
>       at 
> org.apache.kafka.connect.runtime.AbstractHerder.validateConnectorConfig(AbstractHerder.java:734)
>       at 
> org.apache.kafka.connect.runtime.AbstractHerder.lambda$validateConnectorConfig$3(AbstractHerder.java:574)
>       at 
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
>       at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
>       at 
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
>       at 
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
>       at java.base/java.lang.Thread.run(Thread.java:1583){noformat}
> and this error will eventually be shown to the user:
> {noformat}
> Connector configuration is invalid and contains the following 1 error(s):
> Failed to load class JsonConverter: JsonConverter{noformat}
> When the full class name is specified, the class is found and passes 
> validation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to