slfan1989 commented on code in PR #7453:
URL: https://github.com/apache/hadoop/pull/7453#discussion_r1980304547
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/AbstractTimelineReaderHBaseTestBase.java:
##########
@@ -132,39 +135,38 @@ protected ClientResponse getResponse(Client client, URI
uri)
return resp;
}
- protected void verifyHttpResponse(Client client, URI uri, Status status) {
- ClientResponse resp =
- client.resource(uri).accept(MediaType.APPLICATION_JSON)
- .type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ protected void verifyHttpResponse(Client client, URI uri, Response.Status
status) {
+ Response resp =
client.target(uri).request(MediaType.APPLICATION_JSON).get();
assertNotNull(resp);
assertTrue("Response from server should have been " + status,
resp.getStatusInfo().getStatusCode() == status.getStatusCode());
- System.out.println("Response is: " + resp.getEntity(String.class));
+ System.out.println("Response is: " + resp.readEntity(String.class));
}
protected List<FlowActivityEntity> verifyFlowEntites(Client client, URI uri,
int noOfEntities) throws Exception {
- ClientResponse resp = getResponse(client, uri);
+ Response resp = getResponse(client, uri);
List<FlowActivityEntity> entities =
- resp.getEntity(new GenericType<List<FlowActivityEntity>>() {
+ resp.readEntity(new GenericType<List<FlowActivityEntity>>() {
});
assertNotNull(entities);
assertEquals(noOfEntities, entities.size());
return entities;
}
- protected static class DummyURLConnectionFactory
- implements HttpURLConnectionFactory {
-
- @Override
- public HttpURLConnection getHttpURLConnection(final URL url)
- throws IOException {
- try {
- return (HttpURLConnection) url.openConnection();
- } catch (UndeclaredThrowableException e) {
- throw new IOException(e.getCause());
- }
- }
+ @VisibleForTesting
+ protected HttpUrlConnectorProvider getHttpURLConnectionFactory() {
+ return new HttpUrlConnectorProvider().connectionFactory(
+ url -> {
+ HttpURLConnection conn;
+ try {
+ HttpURLConnection.setFollowRedirects(false);
Review Comment:
That's a good question, and you're right, it's unnecessary. I can remove the
code `HttpURLConnection.setFollowRedirects(false);`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]