-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-7048 NPE when creating connector #5202
Conversation
@rayokota Can you review this PR? |
@@ -112,12 +112,13 @@ public boolean contains(String connector) { | |||
* {@link org.apache.kafka.common.config.ConfigTransformer} by having all variable | |||
* references replaced with the current values from external instances of | |||
* {@link ConfigProvider}, and may include secrets. | |||
* NOTED: WorkerConfigTransformer#transform won't be called if the configuration of task doesn't exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps replace this NOTE with If the configuration is not null, it will have been transformed...
@@ -137,12 +138,13 @@ public TargetState targetState(String connector) { | |||
* {@link org.apache.kafka.common.config.ConfigTransformer} by having all variable | |||
* references replaced with the current values from external instances of | |||
* {@link ConfigProvider}, and may include secrets. | |||
* NOTED: WorkerConfigTransformer#transform won't be called if the configuration of task doesn't exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps replace this NOTE with If the configuration is not null, it will have been transformed...
@rajinisivaram , just some small changes to JavaDoc, otherwise LGTM |
Thank @rayokota for the reviews. Have addressed your comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nits (because I wasn't that clear), but otherwise LGTM
@@ -112,12 +112,13 @@ public boolean contains(String connector) { | |||
* {@link org.apache.kafka.common.config.ConfigTransformer} by having all variable | |||
* references replaced with the current values from external instances of | |||
* {@link ConfigProvider}, and may include secrets. | |||
* NOTED: If the configuration is not null, it will have been transformed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Sorry, I wasn't that a clear. I meant to remove this NOTE and start the JavaDoc with:
/**
* Get the configuration for a connector. If the configuration is not null,
* it will have been transformed by
@@ -137,12 +138,13 @@ public TargetState targetState(String connector) { | |||
* {@link org.apache.kafka.common.config.ConfigTransformer} by having all variable | |||
* references replaced with the current values from external instances of | |||
* {@link ConfigProvider}, and may include secrets. | |||
* NOTED: If the configuration is not null, it will have been transformed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Sorry, I wasn't that a clear. I meant to remove this NOTE and start the JavaDoc with:
/**
* Get the configuration for a task. If the configuration is not null,
* it will have been transformed by
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. :(
Will correct the docs in next commit.
* @param connector name of the connector | ||
* @return a map containing configuration parameters | ||
*/ | ||
public Map<String, String> connectorConfig(String connector) { | ||
Map<String, String> configs = connectorConfigs.get(connector); | ||
if (configTransformer != null) { | ||
if (configs != null && configTransformer != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if a better location for null
checking configs is inside transform
. To me, it seems it is, because this way the check is in one place and we are protected against future uses of tranform
with a null
argument.
Also, in contrast, seems that configTransformer
can not be null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, in contrast, seems that configTransformer can not be null.
Not really. In DistributedHerder's constructor, the first configState is ClusterConfigState.EMPTY. And the ClusterConfigState.EMPTY has a null configTransformer.
We can introduce a interface of WorkerConfigTransformer and then pass a do-nothing impl to create an empty ClusterConfigState. Consequently, we can make the configTransformer in ClusterConfigState non-nullable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if a better location for null checking configs is inside transform. To me, it seems it is, because this way the check is in one place and we are protected against future uses of tranform with a null argument.
It makes sense to me. Will address this comment in next commit
Reviewers: Robert Yokota <rayokota@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
Cherry-picked to 2.0 |
Reviewers: Robert Yokota <rayokota@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
Committer Checklist (excluded from commit message)