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

Fix the thread safety problem of obtaining HttpRequestBase through BaseHttpMethod enumeration #3469

Merged
merged 1 commit into from
Jul 29, 2020
Merged

Conversation

Maijh97
Copy link
Collaborator

@Maijh97 Maijh97 commented Jul 29, 2020

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

Since HttpRequestBase is an enum member attribute of BaseHttpMethod, when multiple threads call the init method at the same time, there will be thread safety issues.

Thereby affecting the http client request.
fix: #3366, #3314

Brief changelog

Remove the HttpRequestBase member attribute from the BaseHttpMethod enum, and return the instance directly through the init method

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.

@KomachiSion KomachiSion added the kind/bug Category issues or prs related to bug. label Jul 29, 2020
@KomachiSion KomachiSion added this to the 1.3.2 milestone Jul 29, 2020
@KomachiSion KomachiSion merged commit e9152a9 into alibaba:develop Jul 29, 2020
@itduotai
Copy link

这个好像没有解决吧!使用1.3.2仍然报错

@Maijh97
Copy link
Collaborator Author

Maijh97 commented Sep 10, 2020

这个好像没有解决吧!使用1.3.2仍然报错

报错?麻烦贴一下报错信息,或者贴一下到issue上

@itduotai
Copy link

这个好像没有解决吧!使用1.3.2仍然报错

报错?麻烦贴一下报错信息,或者贴一下到issue上

#3799

@wangdm0824
Copy link

1.3.2 还是有
ERROR [com.alibaba.nacos.client.naming.updater] com.alibaba.nacos.client.naming

@Maijh97
Copy link
Collaborator Author

Maijh97 commented Nov 3, 2020

@wangdm0824 可以提供一下更详细的错误信息吗?

@wangdm0824
Copy link

@wangdm0824 可以提供一下更详细的错误信息吗?

ERROR [com.alibaba.nacos.client.naming.updater] com.alibaba.nacos.client.naming [,] - [NA] failed to request
java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
at java.net.Socket.connect(Socket.java:606)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1226)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:990)
at com.alibaba.nacos.client.naming.net.HttpClient.request(HttpClient.java:86)
at com.alibaba.nacos.client.naming.net.NamingProxy.callServer(NamingProxy.java:433)
at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:468)
at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:401)
at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:397)
at com.alibaba.nacos.client.naming.net.NamingProxy.queryList(NamingProxy.java:321)
at com.alibaba.nacos.client.naming.core.HostReactor.updateServiceNow(HostReactor.java:281)
at com.alibaba.nacos.client.naming.core.HostReactor$UpdateTask.run(HostReactor.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

@Maijh97
Copy link
Collaborator Author

Maijh97 commented Nov 4, 2020

@wangdm0824 从错误信息看,可能是因为网络原因导致的连接超时。麻烦检查一下网络是否正常的

@wangdm0824
Copy link

@wangdm0824 从错误信息看,可能是因为网络原因导致的连接超时。麻烦检查一下网络是否正常的

@Maijh97 应该不是,我的项目正常运行(服务注册、发现都没问题), 就是error.log文件中一直打印这个,其他使用都很正常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

升级到1.3.1一直打印error日志
4 participants