You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/08/17 07:47:09 UTC
[GitHub] diecui1202 closed pull request #2103: replace the method httpclient which is annotated with “@Deprecated”
diecui1202 closed pull request #2103: replace the method httpclient which is annotated with “@Deprecated”
URL: https://github.com/apache/incubator-dubbo/pull/2103
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java
index ebe1cbd8d7..8a7e0e99bb 100644
--- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java
@@ -109,7 +109,9 @@ public void run() {
hessianProxyFactory.setOverloadEnabled(isOverloadEnabled);
String client = url.getParameter(Constants.CLIENT_KEY, Constants.DEFAULT_HTTP_CLIENT);
if ("httpclient".equals(client)) {
- hessianProxyFactory.setConnectionFactory(new HttpClientConnectionFactory());
+ HessianConnectionFactory factory = new HttpClientConnectionFactory();
+ factory.setHessianProxyFactory(hessianProxyFactory);
+ hessianProxyFactory.setConnectionFactory(factory);
} else if (client != null && client.length() > 0 && !Constants.DEFAULT_HTTP_CLIENT.equals(client)) {
throw new IllegalStateException("Unsupported http protocol client=\"" + client + "\"!");
} else {
diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java
index 24becb4c0c..36b1e2b1eb 100644
--- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java
+++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java
@@ -18,11 +18,14 @@
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.rpc.RpcContext;
+
import com.caucho.hessian.client.HessianConnection;
import com.caucho.hessian.client.HessianConnectionFactory;
import com.caucho.hessian.client.HessianProxyFactory;
import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.params.HttpConnectionParams;
import java.io.IOException;
@@ -33,16 +36,19 @@
*/
public class HttpClientConnectionFactory implements HessianConnectionFactory {
- private final HttpClient httpClient = new DefaultHttpClient();
+ private HttpClient httpClient;
@Override
public void setHessianProxyFactory(HessianProxyFactory factory) {
- HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), (int) factory.getConnectTimeout());
- HttpConnectionParams.setSoTimeout(httpClient.getParams(), (int) factory.getReadTimeout());
+ RequestConfig requestConfig = RequestConfig.custom()
+ .setConnectionRequestTimeout((int) factory.getConnectTimeout())
+ .setSocketTimeout((int) factory.getReadTimeout())
+ .build();
+ httpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build();
}
@Override
- public HessianConnection open(URL url) throws IOException {
+ public HessianConnection open(URL url) {
HttpClientConnection httpClientConnection = new HttpClientConnection(httpClient, url);
RpcContext context = RpcContext.getContext();
for (String key : context.getAttachments().keySet()) {
@@ -50,5 +56,4 @@ public HessianConnection open(URL url) throws IOException {
}
return httpClientConnection;
}
-
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org