This is an automated email from the ASF dual-hosted git repository.
kkarantasis pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new f6f6e52 KAFKA-13139: Empty response after requesting to restart a
connector without the tasks results in NPE (#11132)
f6f6e52 is described below
commit f6f6e52c7416e8bacef4b5fc265dc1aa0ff52520
Author: Konstantine Karantasis <[email protected]>
AuthorDate: Tue Jul 27 13:47:16 2021 -0700
KAFKA-13139: Empty response after requesting to restart a connector without
the tasks results in NPE (#11132)
Even after the implementation of KIP-745 it makes sense to return a
response code of 204 NO CONTENT when the request is to restart the connector
but not the tasks.
This maintains the current behavior for this existing REST call and is also
aligned with the description in the RFC:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5
Reviewers: Kalpesh Patel <[email protected]>, Randall Hauch
<[email protected]>
---
.../connect/runtime/rest/resources/ConnectorsResource.java | 2 +-
.../runtime/rest/resources/ConnectorsResourceTest.java | 11 ++++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git
a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java
index ae8b735..18b10c9 100644
---
a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java
+++
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java
@@ -269,7 +269,7 @@ public class ConnectorsResource {
FutureCallback<Void> cb = new FutureCallback<>();
herder.restartConnector(connector, cb);
completeOrForwardRequest(cb, forwardingPath, "POST", headers,
null, forward);
- return Response.ok().build();
+ return Response.noContent().build();
}
// In all other cases, submit the async restart request and return
connector state
diff --git
a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResourceTest.java
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResourceTest.java
index 1e94fa16..3a419b8 100644
---
a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResourceTest.java
+++
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResourceTest.java
@@ -803,7 +803,8 @@ public class ConnectorsResourceTest {
PowerMock.replayAll();
- connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS,
restartRequest.includeTasks(), restartRequest.onlyFailed(), null);
+ Response response =
connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS,
restartRequest.includeTasks(), restartRequest.onlyFailed(), null);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(),
response.getStatus());
PowerMock.verifyAll();
}
@@ -874,7 +875,9 @@ public class ConnectorsResourceTest {
PowerMock.replayAll();
- connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS,
false, false, null);
+ Response response =
connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS, false, false,
null);
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(),
response.getStatus());
+ PowerMock.verifyAll();
PowerMock.verifyAll();
}
@@ -892,7 +895,9 @@ public class ConnectorsResourceTest {
PowerMock.replayAll();
- connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS,
false, false, true);
+ Response response =
connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS, false, false,
true);
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(),
response.getStatus());
+ PowerMock.verifyAll();
PowerMock.verifyAll();
}