-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[ISSUE #3140]nacos-client module replace http client #3142
Conversation
# Conflicts: # client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java # common/src/main/java/com/alibaba/nacos/common/http/BaseHttpMethod.java # common/src/main/java/com/alibaba/nacos/common/http/HttpClientBeanHolder.java # common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java # common/src/main/java/com/alibaba/nacos/common/http/handler/ResponseHandler.java
The nacos-client module http client has been replaced by NacosRestTemplate,please help to review this pr, thanks. @chuntaojun @KomachiSion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great implement!
Only some style problem.
@@ -49,7 +49,7 @@ | |||
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a> | |||
*/ | |||
public enum BaseHttpMethod { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not change the indent.
@@ -34,21 +34,15 @@ | |||
* @author mai.jh | |||
*/ | |||
public final class HttpClientBeanHolder { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not change indent please
@@ -78,14 +78,22 @@ | |||
String contentType = headers.getValue(HttpHeaderConsts.CONTENT_TYPE); | |||
InputStream body = response.getBody(); | |||
T extractBody = null; | |||
boolean typeToStr = String.class.toString().equals(type.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the tmp variable is only used once, I suggest do not change.
} | ||
if (extractBody == null) { | ||
if (!String.class.toString().equals(type.toString())) { | ||
if (!typeToStr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the tmp variable is only used once, I suggest do not change.
* @return {@link HttpRestResult} | ||
* @throws Exception ex | ||
*/ | ||
public <T> HttpRestResult<T> exchangeFrom(String url, Header header, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the mean of From
I read the method think it should be exchangeForm
, is it?
Header header = Header.newInstance(); | ||
header.addParam(HttpHeaderConsts.USER_AGENT_HEADER, "Nacos-Server"); | ||
|
||
HttpRestResult<String> result = nacosRestTemplate.putFrom(url, header, Query.EMPTY, new HashMap<>(), String.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the mean of From I read the method think it should be putFrom
, is it?
I have adjusted the code.please help to review this pr again, thanks. @KomachiSion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check all file, do not change indent please.
@@ -59,14 +59,14 @@ protected HttpRequestBase createRequest(String url) { | |||
return new HttpGet(url); | |||
} | |||
}, | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not change intend
private static final AtomicBoolean ALREADY_SHUTDOWN = new AtomicBoolean(false); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not change indent
*/ | ||
public interface HttpClientResponse extends Closeable { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not change indent
Please do not create a Pull Request without creating an issue first.
What is the purpose of the change
nacos-client module replace http client
Brief changelog
fix: #3140 refer: #2858, #3192
Unified use of httpclient
use
nacosRestTemplate
replacenacos-client
modulehttpClient
Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.