chia7712 commented on code in PR #16282:
URL: https://github.com/apache/kafka/pull/16282#discussion_r1637109956
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java:
##########
@@ -189,9 +190,13 @@ private <T> HttpResponse<T> httpRequest(HttpClient client,
String url, String me
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"Unexpected status code when handling forwarded
request: " + responseCode);
}
- } catch (IOException | InterruptedException | TimeoutException |
ExecutionException e) {
+ } catch (IOException | TimeoutException | ExecutionException e) {
log.error("IO error forwarding REST request to {} :", url, e);
throw new
ConnectRestException(Response.Status.INTERNAL_SERVER_ERROR, "IO Error trying to
forward REST request: " + e.getMessage(), e);
+ } catch (InterruptedException e) {
+ log.error("Thread was interrupted forwarding REST request to {}
:", url, e);
+ Thread.currentThread().interrupt();
Review Comment:
> I believe it is not required because this httpRequest is an overloaded
method that is only used by another httpRequest method invoked in
RestClientTest.java.
not sure whether I catch your point. It seems the `httpRequest` you fix is
used by other variety `httpRequest` of `RestClient`. It is used by production,
and so it is worthwhile to have a simple test case in `RestClientTest`. For
example:
```java
@Test
public void testInterruptCall() throws ExecutionException,
InterruptedException, TimeoutException {
Request req = mock(Request.class);
doThrow(new InterruptedException()).when(req).send();
doReturn(req).when(req).header(anyString(), anyString());
doReturn(req).when(httpClient).newRequest(anyString());
ConnectRestException e =
assertThrows(ConnectRestException.class, () -> httpRequest(
httpClient, MOCK_URL, TEST_METHOD, TEST_TYPE,
TEST_SIGNATURE_ALGORITHM
));
assertIsInternalServerError(e);
assertInstanceOf(InterruptedException.class, e.getCause());
assertTrue(Thread.interrupted());
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]