Browse Source

* MINOR: Catching null pointer exception for empty leader URL when assignment is null (#4798)

Catch null pointer exception for empty leader URL when assignment is null.

Reviewers: Randall Hauch <rhauch@gmail.com>, Konstantine Karantasis <konstantine@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
pull/5924/head
Benedict Jin 6 years ago committed by Guozhang Wang
parent
commit
b21e933592
  1. 9
      connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java

9
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java

@ -1031,7 +1031,14 @@ public class DistributedHerder extends AbstractHerder implements Runnable {
@Override @Override
public void run() { public void run() {
try { try {
String reconfigUrl = RestServer.urlJoin(leaderUrl(), "/connectors/" + connName + "/tasks"); String leaderUrl = leaderUrl();
if (leaderUrl == null || leaderUrl.trim().isEmpty()) {
cb.onCompletion(new ConnectException("Request to leader to " +
"reconfigure connector tasks failed " +
"because the URL of the leader's REST interface is empty!"), null);
return;
}
String reconfigUrl = RestServer.urlJoin(leaderUrl, "/connectors/" + connName + "/tasks");
RestClient.httpRequest(reconfigUrl, "POST", rawTaskProps, null, config); RestClient.httpRequest(reconfigUrl, "POST", rawTaskProps, null, config);
cb.onCompletion(null, null); cb.onCompletion(null, null);
} catch (ConnectException e) { } catch (ConnectException e) {

Loading…
Cancel
Save