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

Sönke Liebau commented on KAFKA-5563:
-------------------------------------

As KAFKA-4930 is approaching a stable state I looked at this again and found 
that a check like this is already implemented for [updating a 
connectorconfig|https://github.com/apache/kafka/blob/e31c0c9bdbad432bc21b583bd3c084f05323f642/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java#L135]
 

I've prepared a pull request that moves this check into a small helper function 
and call this from the createConnector method as well. 

I've also tested merging this with the PR for 4930 which works nicely (for 
now), if any problems occur I'll rebase whichever PR gets merged later.

> Clarify handling of connector name in config 
> ---------------------------------------------
>
>                 Key: KAFKA-5563
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5563
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>    Affects Versions: 0.11.0.0
>            Reporter: Sönke Liebau
>            Assignee: Sönke Liebau
>            Priority: Minor
>
> The connector name is currently being stored in two places, once at the root 
> level of the connector and once in the config:
> {code:java}
> {
>       "name": "test",
>       "config": {
>               "connector.class": 
> "org.apache.kafka.connect.tools.MockSinkConnector",
>               "tasks.max": "3",
>               "topics": "test-topic",
>               "name": "test"
>       },
>       "tasks": [
>               {
>                       "connector": "test",
>                       "task": 0
>               }
>       ]
> }
> {code}
> If no name is provided in the "config" element, then the name from the root 
> level is [copied there when the connector is being 
> created|https://github.com/apache/kafka/blob/trunk/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java#L95].
>  If however a name is provided in the config then it is not touched, which 
> means it is possible to create a connector with a different name at the root 
> level and in the config like this:
> {code:java}
> {
>       "name": "test1",
>       "config": {
>               "connector.class": 
> "org.apache.kafka.connect.tools.MockSinkConnector",
>               "tasks.max": "3",
>               "topics": "test-topic",
>               "name": "differentname"
>       },
>       "tasks": [
>               {
>                       "connector": "test1",
>                       "task": 0
>               }
>       ]
> }
> {code}
> I am not aware of any issues that this currently causes, but it is at least 
> confusing and probably not intended behavior and definitely bears potential 
> for bugs, if different functions take the name from different places.
> Would it make sense to add a check to reject requests that provide different 
> names in the request and the config section?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to