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

unused connectionManager in RestProtocol #4614

Merged
merged 1 commit into from
Jul 22, 2019

Conversation

finalcola
Copy link
Contributor

@finalcola finalcola commented Jul 20, 2019

What is the purpose of the change

Configured PoolingHttpClientConnectionManager in RestProtocol may not work.

PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
        // 20 is the default maxTotal of current PoolingClientConnectionManager
        connectionManager.setMaxTotal(url.getParameter(CONNECTIONS_KEY, HTTPCLIENTCONNECTIONMANAGER_MAXTOTAL));
        connectionManager.setDefaultMaxPerRoute(url.getParameter(CONNECTIONS_KEY, HTTPCLIENTCONNECTIONMANAGER_MAXPERROUTE));

        if (connectionMonitor == null) {
            connectionMonitor = new ConnectionMonitor();
            connectionMonitor.start();
        }
        connectionMonitor.addConnectionManager(connectionManager);
// ...
CloseableHttpClient httpClient = HttpClientBuilder.create()
                .setKeepAliveStrategy((response, context) -> {
                    HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
                    while (it.hasNext()) {
                        HeaderElement he = it.nextElement();
                        String param = he.getName();
                        String value = he.getValue();
                        if (value != null && param.equalsIgnoreCase(TIMEOUT_KEY)) {
                            return Long.parseLong(value) * 1000;
                        }
                    }
                    return HTTPCLIENT_KEEPALIVEDURATION;
                })
                .setDefaultRequestConfig(requestConfig)
                .setDefaultSocketConfig(socketConfig)
                .build();

Configured PoolingHttpClientConnectionManager is used by connectionMonitor, but not set to HttpClient, which may cause a problem.

Brief changelog

XXXXX

Verifying this change

XXXXX

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

  • Make sure there is a GITHUB_issue field 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 [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. 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 sample in dubbo samples project.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@codecov-io
Copy link

Codecov Report

Merging #4614 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4614      +/-   ##
============================================
+ Coverage     64.16%   64.16%   +<.01%     
  Complexity      452      452              
============================================
  Files           768      768              
  Lines         32873    32874       +1     
  Branches       5181     5181              
============================================
+ Hits          21093    21094       +1     
+ Misses         9363     9360       -3     
- Partials       2417     2420       +3
Impacted Files Coverage Δ Complexity Δ
...g/apache/dubbo/rpc/protocol/rest/RestProtocol.java 68.21% <100%> (+0.24%) 0 <0> (ø) ⬇️
...onfig/spring/extension/SpringExtensionFactory.java 78.04% <0%> (-7.32%) 0% <0%> (ø)
.../apache/dubbo/remoting/transport/AbstractPeer.java 58.69% <0%> (-4.35%) 0% <0%> (ø)
...he/dubbo/registry/multicast/MulticastRegistry.java 67.87% <0%> (-1.81%) 0% <0%> (ø)
...g/apache/dubbo/registry/consul/ConsulRegistry.java 61.87% <0%> (-0.63%) 29% <0%> (ø)
.../java/org/apache/dubbo/config/ReferenceConfig.java 59.85% <0%> (+0.36%) 0% <0%> (ø) ⬇️
...pache/dubbo/registry/support/AbstractRegistry.java 80.07% <0%> (+1.53%) 0% <0%> (ø) ⬇️
...ache/dubbo/remoting/p2p/support/AbstractGroup.java 56.81% <0%> (+11.36%) 0% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9960d23...150fa36. Read the comment docs.

Copy link
Member

@beiwei30 beiwei30 left a comment

Choose a reason for hiding this comment

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

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants