Skip to content
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

Merged
merged 3 commits into from
Jun 17, 2018
Merged

Conversation

chia7712
Copy link
Contributor

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@rajinisivaram
Copy link
Contributor

@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.
Copy link
Contributor

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.
Copy link
Contributor

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...

@rayokota
Copy link
Contributor

@rajinisivaram , just some small changes to JavaDoc, otherwise LGTM

@chia7712
Copy link
Contributor Author

Thank @rayokota for the reviews. Have addressed your comment.

Copy link
Contributor

@rayokota rayokota left a 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.
Copy link
Contributor

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.
Copy link
Contributor

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

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

@chia7712 chia7712 Jun 16, 2018

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.

Copy link
Contributor Author

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

@guozhangwang guozhangwang merged commit 6810617 into apache:trunk Jun 17, 2018
guozhangwang pushed a commit that referenced this pull request Jun 17, 2018
Reviewers: Robert Yokota <rayokota@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
@guozhangwang
Copy link
Contributor

Cherry-picked to 2.0

ying-zheng pushed a commit to ying-zheng/kafka that referenced this pull request Jul 6, 2018
Reviewers: Robert Yokota <rayokota@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
@chia7712 chia7712 deleted the KAFKA-7048 branch March 25, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants