Skip to content
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

Merged
merged 8 commits into from
Jun 22, 2020
Merged

[ISSUE #3140]nacos-client module replace http client #3142

merged 8 commits into from
Jun 22, 2020

Conversation

Maijh97
Copy link
Collaborator

@Maijh97 Maijh97 commented Jun 22, 2020

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 replace nacos-client module httpClient

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

Maijh97 added 2 commits June 22, 2020 09:48
# 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
@Maijh97 Maijh97 changed the title nacos-client module http client replace [ISSUE #3140]nacos-client module http client replace Jun 22, 2020
@Maijh97 Maijh97 changed the title [ISSUE #3140]nacos-client module http client replace [ISSUE #3140]nacos-client module replace http client Jun 22, 2020
@Maijh97
Copy link
Collaborator Author

Maijh97 commented Jun 22, 2020

The nacos-client module http client has been replaced by NacosRestTemplate,please help to review this pr, thanks. @chuntaojun @KomachiSion

Copy link
Collaborator

@KomachiSion KomachiSion left a 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 {

Copy link
Collaborator

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 {

Copy link
Collaborator

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());
Copy link
Collaborator

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) {
Copy link
Collaborator

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,
Copy link
Collaborator

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);
Copy link
Collaborator

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?

@Maijh97
Copy link
Collaborator Author

Maijh97 commented Jun 22, 2020

Great implement!
Only some style problem.

I have adjusted the code.please help to review this pr again, thanks. @KomachiSion

Copy link
Collaborator

@KomachiSion KomachiSion left a 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);
}
},

Copy link
Collaborator

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);

Copy link
Collaborator

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 {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change indent

@KomachiSion KomachiSion merged commit 6ce8d8c into alibaba:develop Jun 22, 2020
@KomachiSion KomachiSion added this to the 1.3.1 milestone Jun 22, 2020
@Maijh97 Maijh97 deleted the refactor_http_client branch June 23, 2020 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nacos-client module replace http client
2 participants