Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
1c73664c
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c73664c
编写于
7月 01, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Defensively access deprecated AbstractHttpClient class from Apache HttpComponents
Issue: SPR-14422
上级
8389e3fc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
6 deletion
+37
-6
spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java
...k/http/client/HttpComponentsClientHttpRequestFactory.java
+18
-3
spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java
...httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java
+19
-3
未找到文件。
spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java
浏览文件 @
1c73664c
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -39,6 +39,7 @@ import org.apache.http.protocol.HttpContext;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
/**
* {@link org.springframework.http.client.ClientHttpRequestFactory} implementation that
...
...
@@ -58,6 +59,20 @@ import org.springframework.util.Assert;
*/
public
class
HttpComponentsClientHttpRequestFactory
implements
ClientHttpRequestFactory
,
DisposableBean
{
private
static
Class
<?>
abstractHttpClientClass
;
static
{
try
{
// Looking for AbstractHttpClient class (deprecated as of HttpComponents 4.3)
abstractHttpClientClass
=
ClassUtils
.
forName
(
"org.apache.http.impl.client.AbstractHttpClient"
,
HttpComponentsClientHttpRequestFactory
.
class
.
getClassLoader
());
}
catch
(
ClassNotFoundException
ex
)
{
// Probably removed from HttpComponents in the meantime...
}
}
private
HttpClient
httpClient
;
private
RequestConfig
requestConfig
;
...
...
@@ -130,7 +145,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
*/
@SuppressWarnings
(
"deprecation"
)
private
void
setLegacyConnectionTimeout
(
HttpClient
client
,
int
timeout
)
{
if
(
org
.
apache
.
http
.
impl
.
client
.
AbstractHttpClient
.
c
lass
.
isInstance
(
client
))
{
if
(
abstractHttpClientClass
!=
null
&&
abstractHttpClientC
lass
.
isInstance
(
client
))
{
client
.
getParams
().
setIntParameter
(
org
.
apache
.
http
.
params
.
CoreConnectionPNames
.
CONNECTION_TIMEOUT
,
timeout
);
}
}
...
...
@@ -171,7 +186,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
*/
@SuppressWarnings
(
"deprecation"
)
private
void
setLegacySocketTimeout
(
HttpClient
client
,
int
timeout
)
{
if
(
org
.
apache
.
http
.
impl
.
client
.
AbstractHttpClient
.
c
lass
.
isInstance
(
client
))
{
if
(
abstractHttpClientClass
!=
null
&&
abstractHttpClientC
lass
.
isInstance
(
client
))
{
client
.
getParams
().
setIntParameter
(
org
.
apache
.
http
.
params
.
CoreConnectionPNames
.
SO_TIMEOUT
,
timeout
);
}
}
...
...
spring-web/src/main/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutor.java
浏览文件 @
1c73664c
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -43,6 +43,7 @@ import org.springframework.context.i18n.LocaleContext;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.remoting.support.RemoteInvocationResult
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -69,6 +70,21 @@ public class HttpComponentsHttpInvokerRequestExecutor extends AbstractHttpInvoke
private
static
final
int
DEFAULT_READ_TIMEOUT_MILLISECONDS
=
(
60
*
1000
);
private
static
Class
<?>
abstractHttpClientClass
;
static
{
try
{
// Looking for AbstractHttpClient class (deprecated as of HttpComponents 4.3)
abstractHttpClientClass
=
ClassUtils
.
forName
(
"org.apache.http.impl.client.AbstractHttpClient"
,
HttpComponentsHttpInvokerRequestExecutor
.
class
.
getClassLoader
());
}
catch
(
ClassNotFoundException
ex
)
{
// Probably removed from HttpComponents in the meantime...
}
}
private
HttpClient
httpClient
;
private
RequestConfig
requestConfig
;
...
...
@@ -156,7 +172,7 @@ public class HttpComponentsHttpInvokerRequestExecutor extends AbstractHttpInvoke
*/
@SuppressWarnings
(
"deprecation"
)
private
void
setLegacyConnectionTimeout
(
HttpClient
client
,
int
timeout
)
{
if
(
org
.
apache
.
http
.
impl
.
client
.
AbstractHttpClient
.
c
lass
.
isInstance
(
client
))
{
if
(
abstractHttpClientClass
!=
null
&&
abstractHttpClientC
lass
.
isInstance
(
client
))
{
client
.
getParams
().
setIntParameter
(
org
.
apache
.
http
.
params
.
CoreConnectionPNames
.
CONNECTION_TIMEOUT
,
timeout
);
}
}
...
...
@@ -198,7 +214,7 @@ public class HttpComponentsHttpInvokerRequestExecutor extends AbstractHttpInvoke
*/
@SuppressWarnings
(
"deprecation"
)
private
void
setLegacySocketTimeout
(
HttpClient
client
,
int
timeout
)
{
if
(
org
.
apache
.
http
.
impl
.
client
.
AbstractHttpClient
.
c
lass
.
isInstance
(
client
))
{
if
(
abstractHttpClientClass
!=
null
&&
abstractHttpClientC
lass
.
isInstance
(
client
))
{
client
.
getParams
().
setIntParameter
(
org
.
apache
.
http
.
params
.
CoreConnectionPNames
.
SO_TIMEOUT
,
timeout
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录