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-8591: WorkerConfigTransformer NPE on connector configuration reloading #6991

Merged
merged 3 commits into from Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,6 +21,7 @@
import org.apache.kafka.common.config.ConfigTransformer;
import org.apache.kafka.common.config.ConfigTransformerResult;
import org.apache.kafka.connect.runtime.Herder.ConfigReloadAction;
import org.apache.kafka.connect.util.Callback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -86,7 +87,15 @@ private void scheduleReload(String connectorName, String path, long ttl) {
}
}
log.info("Scheduling a restart of connector {} in {} ms", connectorName, ttl);
HerderRequest request = worker.herder().restartConnector(ttl, connectorName, null);
Callback<Void> cb = new Callback<Void>() {
@Override
public void onCompletion(Throwable error, Void result) {
if (error != null) {
log.error("Unexpected error during connector restart: ", error);
}
}
};
HerderRequest request = worker.herder().restartConnector(ttl, connectorName, cb);
connectorRequests.put(path, request);
}
}
Expand Up @@ -20,6 +20,8 @@
import org.apache.kafka.common.config.ConfigData;
import org.apache.kafka.common.config.provider.ConfigProvider;
import org.easymock.EasyMock;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.eq;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -84,8 +86,7 @@ public void testReplaceVariableWithTTL() {
@Test
public void testReplaceVariableWithTTLAndScheduleRestart() {
EasyMock.expect(worker.herder()).andReturn(herder);
EasyMock.expect(herder.restartConnector(1L, MY_CONNECTOR, null)).andReturn(requestId);

EasyMock.expect(herder.restartConnector(eq(1L), eq(MY_CONNECTOR), anyObject())).andReturn(requestId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. These tests all pass even if the callback is null. Perhaps we can use EasyMock.notNull()?

replayAll();

Map<String, String> result = configTransformer.transform(MY_CONNECTOR, Collections.singletonMap(MY_KEY, "${test:testPath:testKeyWithTTL}"));
Expand All @@ -95,13 +96,13 @@ public void testReplaceVariableWithTTLAndScheduleRestart() {
@Test
public void testReplaceVariableWithTTLFirstCancelThenScheduleRestart() {
EasyMock.expect(worker.herder()).andReturn(herder);
EasyMock.expect(herder.restartConnector(1L, MY_CONNECTOR, null)).andReturn(requestId);
EasyMock.expect(herder.restartConnector(eq(1L), eq(MY_CONNECTOR), anyObject())).andReturn(requestId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra space before anyObject


EasyMock.expect(worker.herder()).andReturn(herder);
EasyMock.expectLastCall();
requestId.cancel();
EasyMock.expectLastCall();
EasyMock.expect(herder.restartConnector(10L, MY_CONNECTOR, null)).andReturn(requestId);
EasyMock.expect(herder.restartConnector(eq(10L), eq(MY_CONNECTOR), anyObject())).andReturn(requestId);

replayAll();

Expand Down