[ https://issues.apache.org/jira/browse/KAFKA-7048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16509911#comment-16509911 ]
ASF GitHub Bot commented on KAFKA-7048: --------------------------------------- chia7712 opened a new pull request #5202: KAFKA-7048 NPE when creating connector URL: https://github.com/apache/kafka/pull/5202 ### Committer Checklist (excluded from commit message) - [ ] Verify design and implementation - [ ] Verify test coverage and CI build status - [ ] Verify documentation (including upgrade notes) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > NPE when creating connector > --------------------------- > > Key: KAFKA-7048 > URL: https://issues.apache.org/jira/browse/KAFKA-7048 > Project: Kafka > Issue Type: Bug > Reporter: Chia-Ping Tsai > Assignee: Chia-Ping Tsai > Priority: Blocker > Fix For: 2.0.0 > > > KAFKA-6886 introduced the ConfigTransformer to transform the given > configuration data. ConfigTransformer#transform(Map<String, String>) expect > the passed config won't be null but DistributedHerder#putConnectorConfig call > the #transform before updating the snapshot (see below). Hence, it cause the > NPE. > {code:java} > // Note that we use the updated connector config despite the fact that we > don't have an updated > // snapshot yet. The existing task info should still be accurate. > Map<String, String> map = configState.connectorConfig(connName); > ConnectorInfo info = new ConnectorInfo(connName, config, > configState.tasks(connName), > map == null ? null : > connectorTypeForClass(map.get(ConnectorConfig.CONNECTOR_CLASS_CONFIG))); > callback.onCompletion(null, new Created<>(!exists, info)); > return null;{code} > We can add a null check to "configs" (see below) to resolve the NPE. It means > we WON'T pass the null configs to configTransformer > {code:java} > public Map<String, String> connectorConfig(String connector) { > Map<String, String> configs = connectorConfigs.get(connector); > if (configTransformer != null) { // add a condition "configs != null" > configs = configTransformer.transform(connector, configs); > } > return configs; > }{code} > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)