Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
spring-framework
提交
11806b92
S
spring-framework
项目概览
dk131072
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
11806b92
编写于
12月 09, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Class identity comparisons wherever possible (and further polishing)
Issue: SPR-12926
上级
4261f34b
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
127 addition
and
109 deletion
+127
-109
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
...java/org/springframework/aop/framework/CglibAopProxy.java
+1
-1
spring-aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java
...work/aop/target/AbstractBeanFactoryBasedTargetSource.java
+1
-1
spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java
...ringframework/beans/AbstractNestablePropertyAccessor.java
+3
-3
spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java
...framework/beans/factory/annotation/InjectionMetadata.java
+2
-2
spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java
...actory/support/CglibSubclassingInstantiationStrategy.java
+1
-1
spring-context/src/main/java/org/springframework/validation/DataBinder.java
.../main/java/org/springframework/validation/DataBinder.java
+1
-1
spring-context/src/main/java/org/springframework/validation/ObjectError.java
...main/java/org/springframework/validation/ObjectError.java
+2
-2
spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
.../springframework/expression/spel/ast/MethodReference.java
+1
-1
spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java
.../org/springframework/jdbc/core/BeanPropertyRowMapper.java
+1
-1
spring-jms/src/main/java/org/springframework/jms/connection/CachedMessageProducer.java
...springframework/jms/connection/CachedMessageProducer.java
+1
-1
spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
...ingframework/jms/connection/CachingConnectionFactory.java
+1
-1
spring-messaging/src/main/java/org/springframework/messaging/handler/AbstractMessageCondition.java
...framework/messaging/handler/AbstractMessageCondition.java
+9
-9
spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java
...ain/java/org/springframework/oxm/jibx/JibxMarshaller.java
+3
-3
spring-test/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java
...work/test/web/client/MockMvcClientHttpRequestFactory.java
+2
-2
spring-test/src/main/java/org/springframework/test/web/client/RequestMatcher.java
...a/org/springframework/test/web/client/RequestMatcher.java
+2
-2
spring-test/src/main/java/org/springframework/test/web/client/RequestMatcherClientHttpRequest.java
...work/test/web/client/RequestMatcherClientHttpRequest.java
+4
-6
spring-test/src/main/java/org/springframework/test/web/client/ResponseActions.java
.../org/springframework/test/web/client/ResponseActions.java
+2
-1
spring-test/src/main/java/org/springframework/test/web/client/ResponseCreator.java
.../org/springframework/test/web/client/ResponseCreator.java
+2
-1
spring-web/src/main/java/org/springframework/http/HttpEntity.java
...eb/src/main/java/org/springframework/http/HttpEntity.java
+1
-1
spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpRequestFactoryWrapper.java
.../http/client/AbstractClientHttpRequestFactoryWrapper.java
+8
-7
spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java
...k/http/client/HttpComponentsClientHttpRequestFactory.java
+9
-6
spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java
...gframework/http/client/InterceptingClientHttpRequest.java
+13
-14
spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequestFactory.java
...ork/http/client/InterceptingClientHttpRequestFactory.java
+8
-6
spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequestFactory.java
...framework/http/client/Netty4ClientHttpRequestFactory.java
+2
-3
spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java
...framework/http/client/SimpleClientHttpRequestFactory.java
+16
-8
spring-web/src/main/java/org/springframework/http/client/support/HttpRequestWrapper.java
...ringframework/http/client/support/HttpRequestWrapper.java
+13
-11
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.java
...eb/servlet/mvc/condition/AbstractMediaTypeExpression.java
+16
-12
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java
...k/web/servlet/mvc/condition/AbstractRequestCondition.java
+1
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java
...gframework/web/servlet/resource/PathResourceResolver.java
+1
-1
未找到文件。
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
浏览文件 @
11806b92
...
...
@@ -922,7 +922,7 @@ class CglibAopProxy implements AopProxy, Serializable {
if
(
aa
==
null
||
ba
==
null
)
{
return
(
aa
==
ba
);
}
return
aa
.
getClass
().
equals
(
ba
.
getClass
());
return
(
aa
.
getClass
()
==
ba
.
getClass
());
}
private
boolean
equalsPointcuts
(
Advisor
a
,
Advisor
b
)
{
...
...
spring-aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java
浏览文件 @
11806b92
...
...
@@ -165,7 +165,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
if
(
this
==
other
)
{
return
true
;
}
if
(
other
==
null
||
!
getClass
().
equals
(
other
.
getClass
()
))
{
if
(
other
==
null
||
getClass
()
!=
other
.
getClass
(
))
{
return
false
;
}
AbstractBeanFactoryBasedTargetSource
otherTargetSource
=
(
AbstractBeanFactoryBasedTargetSource
)
other
;
...
...
spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java
浏览文件 @
11806b92
...
...
@@ -203,7 +203,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
*/
public
void
setWrappedInstance
(
Object
object
,
String
nestedPath
,
Object
rootObject
)
{
Assert
.
notNull
(
object
,
"Target object must not be null"
);
if
(
object
.
getClass
()
.
equals
(
javaUtilOptionalClass
)
)
{
if
(
object
.
getClass
()
==
javaUtilOptionalClass
)
{
this
.
object
=
OptionalUnwrapper
.
unwrap
(
object
);
}
else
{
...
...
@@ -834,7 +834,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
PropertyTokenHolder
tokens
=
getPropertyNameTokens
(
nestedProperty
);
String
canonicalName
=
tokens
.
canonicalName
;
Object
value
=
getPropertyValue
(
tokens
);
if
(
value
==
null
||
(
value
.
getClass
()
.
equals
(
javaUtilOptionalClass
)
&&
OptionalUnwrapper
.
isEmpty
(
value
)))
{
if
(
value
==
null
||
(
value
.
getClass
()
==
javaUtilOptionalClass
&&
OptionalUnwrapper
.
isEmpty
(
value
)))
{
if
(
isAutoGrowNestedPaths
())
{
value
=
setDefaultValue
(
tokens
);
}
...
...
@@ -846,7 +846,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
// Lookup cached sub-PropertyAccessor, create new one if not found.
AbstractNestablePropertyAccessor
nestedPa
=
this
.
nestedPropertyAccessors
.
get
(
canonicalName
);
if
(
nestedPa
==
null
||
nestedPa
.
getWrappedInstance
()
!=
(
value
.
getClass
()
.
equals
(
javaUtilOptionalClass
)
?
OptionalUnwrapper
.
unwrap
(
value
)
:
value
))
{
(
value
.
getClass
()
==
javaUtilOptionalClass
?
OptionalUnwrapper
.
unwrap
(
value
)
:
value
))
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Creating new nested "
+
getClass
().
getSimpleName
()
+
" for property '"
+
canonicalName
+
"'"
);
}
...
...
spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -105,7 +105,7 @@ public class InjectionMetadata {
public
static
boolean
needsRefresh
(
InjectionMetadata
metadata
,
Class
<?>
clazz
)
{
return
(
metadata
==
null
||
!
metadata
.
targetClass
.
equals
(
clazz
)
);
return
(
metadata
==
null
||
metadata
.
targetClass
!=
clazz
);
}
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java
浏览文件 @
11806b92
...
...
@@ -174,7 +174,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
@Override
public
boolean
equals
(
Object
other
)
{
return
(
getClass
()
.
equals
(
other
.
getClass
()
)
&&
return
(
getClass
()
==
other
.
getClass
(
)
&&
this
.
beanDefinition
.
equals
(((
CglibIdentitySupport
)
other
).
beanDefinition
));
}
...
...
spring-context/src/main/java/org/springframework/validation/DataBinder.java
浏览文件 @
11806b92
...
...
@@ -184,7 +184,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
* @param objectName the name of the target object
*/
public
DataBinder
(
Object
target
,
String
objectName
)
{
if
(
target
!=
null
&&
target
.
getClass
()
.
equals
(
javaUtilOptionalClass
)
)
{
if
(
target
!=
null
&&
target
.
getClass
()
==
javaUtilOptionalClass
)
{
this
.
target
=
OptionalUnwrapper
.
unwrap
(
target
);
}
else
{
...
...
spring-context/src/main/java/org/springframework/validation/ObjectError.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -78,7 +78,7 @@ public class ObjectError extends DefaultMessageSourceResolvable {
if
(
this
==
other
)
{
return
true
;
}
if
(
!(
getClass
().
equals
(
other
.
getClass
())
)
||
!
super
.
equals
(
other
))
{
if
(
getClass
()
!=
other
.
getClass
(
)
||
!
super
.
equals
(
other
))
{
return
false
;
}
ObjectError
otherError
=
(
ObjectError
)
other
;
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
浏览文件 @
11806b92
...
...
@@ -376,7 +376,7 @@ public class MethodReference extends SpelNodeImpl {
}
public
boolean
isSuitable
(
Object
value
,
TypeDescriptor
target
,
List
<
TypeDescriptor
>
argumentTypes
)
{
return
((
this
.
staticClass
==
null
||
this
.
staticClass
.
equals
(
value
)
)
&&
return
((
this
.
staticClass
==
null
||
this
.
staticClass
==
value
)
&&
this
.
target
.
equals
(
target
)
&&
this
.
argumentTypes
.
equals
(
argumentTypes
));
}
...
...
spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java
浏览文件 @
11806b92
...
...
@@ -131,7 +131,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
initialize
(
mappedClass
);
}
else
{
if
(
!
this
.
mappedClass
.
equals
(
mappedClass
)
)
{
if
(
this
.
mappedClass
!=
mappedClass
)
{
throw
new
InvalidDataAccessApiUsageException
(
"The mapped class can not be reassigned to map to "
+
mappedClass
+
" since it is already providing mapping for "
+
this
.
mappedClass
);
}
...
...
spring-jms/src/main/java/org/springframework/jms/connection/CachedMessageProducer.java
浏览文件 @
11806b92
...
...
@@ -276,7 +276,7 @@ class CachedMessageProducer implements MessageProducer, QueueSender, TopicPublis
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
try
{
if
(
method
.
getName
().
equals
(
"send"
)
&&
args
!=
null
&&
completionListenerClass
.
equals
(
method
.
getParameterTypes
()[
args
.
length
-
1
])
)
{
completionListenerClass
==
method
.
getParameterTypes
()[
args
.
length
-
1
]
)
{
switch
(
args
.
length
)
{
case
2
:
// send(message, completionListener)
return
sendWithCompletionListenerMethod
.
invoke
(
...
...
spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
浏览文件 @
11806b92
...
...
@@ -528,7 +528,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
}
protected
boolean
destinationEquals
(
DestinationCacheKey
otherKey
)
{
return
(
this
.
destination
.
getClass
()
.
equals
(
otherKey
.
destination
.
getClass
()
)
&&
return
(
this
.
destination
.
getClass
()
==
otherKey
.
destination
.
getClass
(
)
&&
(
this
.
destination
.
equals
(
otherKey
.
destination
)
||
getDestinationString
().
equals
(
otherKey
.
getDestinationString
())));
}
...
...
spring-messaging/src/main/java/org/springframework/messaging/handler/AbstractMessageCondition.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -28,19 +28,12 @@ import java.util.Iterator;
*/
public
abstract
class
AbstractMessageCondition
<
T
extends
AbstractMessageCondition
<
T
>>
implements
MessageCondition
<
T
>
{
/**
* @return the collection of objects the message condition is composed of
* .g. destination patterns), never {@code null}
*/
protected
abstract
Collection
<?>
getContent
();
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
!=
null
&&
getClass
()
.
equals
(
obj
.
getClass
()
))
{
if
(
obj
!=
null
&&
getClass
()
==
obj
.
getClass
(
))
{
AbstractMessageCondition
<?>
other
=
(
AbstractMessageCondition
<?>)
obj
;
return
getContent
().
equals
(
other
.
getContent
());
}
...
...
@@ -66,6 +59,13 @@ public abstract class AbstractMessageCondition<T extends AbstractMessageConditio
return
builder
.
toString
();
}
/**
* Return the collection of objects the message condition is composed of
* (e.g. destination patterns), never {@code null}.
*/
protected
abstract
Collection
<?>
getContent
();
/**
* The notation to use when printing discrete items of content.
* For example " || " for URL patterns or " && " for param expressions.
...
...
spring-oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -236,9 +236,9 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
@Override
public
boolean
supports
(
Class
<?>
clazz
)
{
Assert
.
notNull
(
clazz
,
"
'clazz'
must not be null"
);
Assert
.
notNull
(
clazz
,
"
Class
must not be null"
);
if
(
this
.
targetClass
!=
null
)
{
return
this
.
targetClass
.
equals
(
clazz
);
return
(
this
.
targetClass
==
clazz
);
}
String
[]
mappedClasses
=
this
.
bindingFactory
.
getMappedClasses
();
String
className
=
clazz
.
getName
();
...
...
spring-test/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.test.web.client
;
import
java.io.IOException
;
...
...
@@ -52,7 +53,6 @@ public class MockMvcClientHttpRequestFactory implements ClientHttpRequestFactory
@Override
public
ClientHttpRequest
createRequest
(
final
URI
uri
,
final
HttpMethod
httpMethod
)
throws
IOException
{
return
new
MockClientHttpRequest
(
httpMethod
,
uri
)
{
@Override
public
ClientHttpResponse
executeInternal
()
throws
IOException
{
try
{
...
...
spring-test/src/main/java/org/springframework/test/web/client/RequestMatcher.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.test.web.client
;
import
java.io.IOException
;
...
...
@@ -29,7 +30,6 @@ public interface RequestMatcher {
/**
* Match the given request against some expectations.
*
* @param request the request to make assertions on
* @throws IOException in case of I/O errors
* @throws AssertionError if expectations are not met
...
...
spring-test/src/main/java/org/springframework/test/web/client/RequestMatcherClientHttpRequest.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -46,6 +46,7 @@ class RequestMatcherClientHttpRequest extends MockAsyncClientHttpRequest impleme
this
.
requestMatchers
.
add
(
requestMatcher
);
}
@Override
public
ResponseActions
andExpect
(
RequestMatcher
requestMatcher
)
{
Assert
.
notNull
(
requestMatcher
,
"RequestMatcher is required"
);
...
...
@@ -61,22 +62,19 @@ class RequestMatcherClientHttpRequest extends MockAsyncClientHttpRequest impleme
@Override
public
ClientHttpResponse
executeInternal
()
throws
IOException
{
if
(
this
.
requestMatchers
.
isEmpty
())
{
throw
new
AssertionError
(
"No request expectations to execute"
);
}
if
(
this
.
responseCreator
==
null
)
{
throw
new
AssertionError
(
"No ResponseCreator was set up. Add it after request expectations, "
+
"e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())"
);
throw
new
AssertionError
(
"No ResponseCreator was set up. Add it after request expectations, "
+
"e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())"
);
}
for
(
RequestMatcher
requestMatcher
:
this
.
requestMatchers
)
{
requestMatcher
.
match
(
this
);
}
setResponse
(
this
.
responseCreator
.
createResponse
(
this
));
return
super
.
executeInternal
();
}
...
...
spring-test/src/main/java/org/springframework/test/web/client/ResponseActions.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.test.web.client
;
/**
...
...
spring-test/src/main/java/org/springframework/test/web/client/ResponseCreator.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.test.web.client
;
import
java.io.IOException
;
...
...
spring-web/src/main/java/org/springframework/http/HttpEntity.java
浏览文件 @
11806b92
...
...
@@ -131,7 +131,7 @@ public class HttpEntity<T> {
if
(
this
==
other
)
{
return
true
;
}
if
(
other
==
null
||
!
other
.
getClass
().
equals
(
getClass
()
))
{
if
(
other
==
null
||
other
.
getClass
()
!=
getClass
(
))
{
return
false
;
}
HttpEntity
<?>
otherEntity
=
(
HttpEntity
<?>)
other
;
...
...
spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpRequestFactoryWrapper.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -23,7 +23,8 @@ import org.springframework.http.HttpMethod;
import
org.springframework.util.Assert
;
/**
* Abstract base class for {@link ClientHttpRequestFactory} implementations that decorate another request factory.
* Abstract base class for {@link ClientHttpRequestFactory} implementations
* that decorate another request factory.
*
* @author Arjen Poutsma
* @since 3.1
...
...
@@ -34,11 +35,11 @@ public abstract class AbstractClientHttpRequestFactoryWrapper implements ClientH
/**
* Create
s
a {@code AbstractClientHttpRequestFactoryWrapper} wrapping the given request factory.
* Create a {@code AbstractClientHttpRequestFactoryWrapper} wrapping the given request factory.
* @param requestFactory the request factory to be wrapped
*/
protected
AbstractClientHttpRequestFactoryWrapper
(
ClientHttpRequestFactory
requestFactory
)
{
Assert
.
notNull
(
requestFactory
,
"
'requestFactory'
must not be null"
);
Assert
.
notNull
(
requestFactory
,
"
ClientHttpRequestFactory
must not be null"
);
this
.
requestFactory
=
requestFactory
;
}
...
...
@@ -50,12 +51,12 @@ public abstract class AbstractClientHttpRequestFactoryWrapper implements ClientH
*/
@Override
public
final
ClientHttpRequest
createRequest
(
URI
uri
,
HttpMethod
httpMethod
)
throws
IOException
{
return
createRequest
(
uri
,
httpMethod
,
requestFactory
);
return
createRequest
(
uri
,
httpMethod
,
this
.
requestFactory
);
}
/**
* Create a new {@link ClientHttpRequest} for the specified URI and HTTP method
by using the
* passed-on request factory.
* Create a new {@link ClientHttpRequest} for the specified URI and HTTP method
*
by using the
passed-on request factory.
* <p>Called from {@link #createRequest(URI, HttpMethod)}.
* @param uri the URI to create a request for
* @param httpMethod the HTTP method to execute
...
...
spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java
浏览文件 @
11806b92
...
...
@@ -190,12 +190,14 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
public
ClientHttpRequest
createRequest
(
URI
uri
,
HttpMethod
httpMethod
)
throws
IOException
{
HttpClient
client
=
getHttpClient
();
Assert
.
state
(
client
!=
null
,
"Synchronous execution requires an HttpClient to be set"
);
HttpUriRequest
httpRequest
=
createHttpUriRequest
(
httpMethod
,
uri
);
postProcessHttpRequest
(
httpRequest
);
HttpContext
context
=
createHttpContext
(
httpMethod
,
uri
);
if
(
context
==
null
)
{
context
=
HttpClientContext
.
create
();
}
// Request configuration not set in the context
if
(
context
.
getAttribute
(
HttpClientContext
.
REQUEST_CONFIG
)
==
null
)
{
// Use request configuration given by the user, when available
...
...
@@ -210,6 +212,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
context
.
setAttribute
(
HttpClientContext
.
REQUEST_CONFIG
,
config
);
}
}
if
(
this
.
bufferRequestBody
)
{
return
new
HttpComponentsClientHttpRequest
(
client
,
httpRequest
,
context
);
}
...
...
@@ -285,20 +288,20 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
switch
(
httpMethod
)
{
case
GET:
return
new
HttpGet
(
uri
);
case
DELETE:
return
new
HttpDelete
(
uri
);
case
HEAD:
return
new
HttpHead
(
uri
);
case
OPTIONS:
return
new
HttpOptions
(
uri
);
case
POST:
return
new
HttpPost
(
uri
);
case
PUT:
return
new
HttpPut
(
uri
);
case
TRACE:
return
new
HttpTrace
(
uri
);
case
PATCH:
return
new
HttpPatch
(
uri
);
case
DELETE:
return
new
HttpDelete
(
uri
);
case
OPTIONS:
return
new
HttpOptions
(
uri
);
case
TRACE:
return
new
HttpTrace
(
uri
);
default
:
throw
new
IllegalArgumentException
(
"Invalid HTTP method: "
+
httpMethod
);
}
...
...
spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequest.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -42,52 +42,51 @@ class InterceptingClientHttpRequest extends AbstractBufferingClientHttpRequest {
private
URI
uri
;
protected
InterceptingClientHttpRequest
(
ClientHttpRequestFactory
requestFactory
,
List
<
ClientHttpRequestInterceptor
>
interceptors
,
URI
uri
,
HttpMethod
method
)
{
List
<
ClientHttpRequestInterceptor
>
interceptors
,
URI
uri
,
HttpMethod
method
)
{
this
.
requestFactory
=
requestFactory
;
this
.
interceptors
=
interceptors
;
this
.
method
=
method
;
this
.
uri
=
uri
;
}
@Override
public
HttpMethod
getMethod
()
{
return
method
;
return
this
.
method
;
}
@Override
public
URI
getURI
()
{
return
uri
;
return
this
.
uri
;
}
@Override
protected
final
ClientHttpResponse
executeInternal
(
HttpHeaders
headers
,
byte
[]
bufferedOutput
)
throws
IOException
{
RequestExecution
requestExecution
=
new
RequestExecution
();
InterceptingRequestExecution
requestExecution
=
new
InterceptingRequestExecution
();
return
requestExecution
.
execute
(
this
,
bufferedOutput
);
}
private
class
RequestExecution
implements
ClientHttpRequestExecution
{
private
class
InterceptingRequestExecution
implements
ClientHttpRequestExecution
{
private
final
Iterator
<
ClientHttpRequestInterceptor
>
iterator
;
p
rivate
RequestExecution
()
{
p
ublic
Intercepting
RequestExecution
()
{
this
.
iterator
=
interceptors
.
iterator
();
}
@Override
public
ClientHttpResponse
execute
(
HttpRequest
request
,
byte
[]
body
)
throws
IOException
{
if
(
iterator
.
hasNext
())
{
ClientHttpRequestInterceptor
nextInterceptor
=
iterator
.
next
();
if
(
this
.
iterator
.
hasNext
())
{
ClientHttpRequestInterceptor
nextInterceptor
=
this
.
iterator
.
next
();
return
nextInterceptor
.
intercept
(
request
,
body
,
this
);
}
else
{
ClientHttpRequest
delegate
=
requestFactory
.
createRequest
(
request
.
getURI
(),
request
.
getMethod
());
delegate
.
getHeaders
().
putAll
(
request
.
getHeaders
());
if
(
body
.
length
>
0
)
{
StreamUtils
.
copy
(
body
,
delegate
.
getBody
());
}
...
...
spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequestFactory.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
1
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -32,20 +32,22 @@ public class InterceptingClientHttpRequestFactory extends AbstractClientHttpRequ
private
final
List
<
ClientHttpRequestInterceptor
>
interceptors
;
/**
* Creates a new instance of the {@code InterceptingClientHttpRequestFactory} with the given parameters.
*
* Create a new instance of the {@code InterceptingClientHttpRequestFactory} with the given parameters.
* @param requestFactory the request factory to wrap
* @param interceptors the interceptors that are to be applied
. Can be {@code null}.
* @param interceptors the interceptors that are to be applied
(can be {@code null})
*/
public
InterceptingClientHttpRequestFactory
(
ClientHttpRequestFactory
requestFactory
,
List
<
ClientHttpRequestInterceptor
>
interceptors
)
{
super
(
requestFactory
);
this
.
interceptors
=
interceptors
!=
null
?
interceptors
:
Collections
.<
ClientHttpRequestInterceptor
>
emptyList
(
);
this
.
interceptors
=
(
interceptors
!=
null
?
interceptors
:
Collections
.<
ClientHttpRequestInterceptor
>
emptyList
()
);
}
@Override
protected
ClientHttpRequest
createRequest
(
URI
uri
,
HttpMethod
httpMethod
,
ClientHttpRequestFactory
requestFactory
)
{
return
new
InterceptingClientHttpRequest
(
requestFactory
,
interceptors
,
uri
,
httpMethod
);
return
new
InterceptingClientHttpRequest
(
requestFactory
,
this
.
interceptors
,
uri
,
httpMethod
);
}
}
spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequestFactory.java
浏览文件 @
11806b92
...
...
@@ -39,7 +39,6 @@ import org.springframework.beans.factory.InitializingBean;
import
org.springframework.http.HttpMethod
;
import
org.springframework.util.Assert
;
/**
* {@link org.springframework.http.client.ClientHttpRequestFactory} implementation that
* uses <a href="http://netty.io/">Netty 4</a> to create requests.
...
...
@@ -69,12 +68,12 @@ public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
private
SslContext
sslContext
;
private
volatile
Bootstrap
bootstrap
;
private
int
connectTimeout
=
-
1
;
private
int
readTimeout
=
-
1
;
private
volatile
Bootstrap
bootstrap
;
/**
* Create a new {@code Netty4ClientHttpRequestFactory} with a default
...
...
spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -136,6 +136,7 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory,
public
ClientHttpRequest
createRequest
(
URI
uri
,
HttpMethod
httpMethod
)
throws
IOException
{
HttpURLConnection
connection
=
openConnection
(
uri
.
toURL
(),
this
.
proxy
);
prepareConnection
(
connection
,
httpMethod
.
name
());
if
(
this
.
bufferRequestBody
)
{
return
new
SimpleBufferingClientHttpRequest
(
connection
,
this
.
outputStreaming
);
}
...
...
@@ -146,20 +147,23 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory,
/**
* {@inheritDoc}
* <p>Setting the {@link #setTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor) taskExecutor} property
* is required before calling this method.
* <p>Setting the {@link #setTaskExecutor taskExecutor} property is required before calling this method.
*/
@Override
public
AsyncClientHttpRequest
createAsyncRequest
(
URI
uri
,
HttpMethod
httpMethod
)
throws
IOException
{
Assert
.
state
(
this
.
taskExecutor
!=
null
,
"Asynchronous execution requires an AsyncTaskExecutor to be set"
);
Assert
.
state
(
this
.
taskExecutor
!=
null
,
"Asynchronous execution requires an AsyncTaskExecutor to be set"
);
HttpURLConnection
connection
=
openConnection
(
uri
.
toURL
(),
this
.
proxy
);
prepareConnection
(
connection
,
httpMethod
.
name
());
if
(
this
.
bufferRequestBody
)
{
return
new
SimpleBufferingAsyncClientHttpRequest
(
connection
,
this
.
outputStreaming
,
this
.
taskExecutor
);
return
new
SimpleBufferingAsyncClientHttpRequest
(
connection
,
this
.
outputStreaming
,
this
.
taskExecutor
);
}
else
{
return
new
SimpleStreamingAsyncClientHttpRequest
(
connection
,
this
.
chunkSize
,
this
.
outputStreaming
,
this
.
taskExecutor
);
return
new
SimpleStreamingAsyncClientHttpRequest
(
connection
,
this
.
chunkSize
,
this
.
outputStreaming
,
this
.
taskExecutor
);
}
}
...
...
@@ -192,20 +196,24 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory,
if
(
this
.
readTimeout
>=
0
)
{
connection
.
setReadTimeout
(
this
.
readTimeout
);
}
connection
.
setDoInput
(
true
);
if
(
"GET"
.
equals
(
httpMethod
))
{
connection
.
setInstanceFollowRedirects
(
true
);
}
else
{
connection
.
setInstanceFollowRedirects
(
false
);
}
if
(
"PUT"
.
equals
(
httpMethod
)
||
"POST"
.
equals
(
httpMethod
)
||
if
(
"POST"
.
equals
(
httpMethod
)
||
"PUT"
.
equals
(
httpMethod
)
||
"PATCH"
.
equals
(
httpMethod
)
||
"DELETE"
.
equals
(
httpMethod
))
{
connection
.
setDoOutput
(
true
);
}
else
{
connection
.
setDoOutput
(
false
);
}
connection
.
setRequestMethod
(
httpMethod
);
}
...
...
spring-web/src/main/java/org/springframework/http/client/support/HttpRequestWrapper.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -24,8 +24,10 @@ import org.springframework.http.HttpRequest;
import
org.springframework.util.Assert
;
/**
* Provides a convenient implementation of the {@link HttpRequest} interface that can be overridden to adapt the
* request. Methods default to calling through to the wrapped request object.
* Provides a convenient implementation of the {@link HttpRequest} interface
* that can be overridden to adapt the request.
*
* <p>These methods default to calling through to the wrapped request object.
*
* @author Arjen Poutsma
* @since 3.1
...
...
@@ -36,24 +38,24 @@ public class HttpRequestWrapper implements HttpRequest {
/**
* Creates a new {@code HttpRequest} wrapping the given request object.
*
* Create a new {@code HttpRequest} wrapping the given request object.
* @param request the request object to be wrapped
*/
public
HttpRequestWrapper
(
HttpRequest
request
)
{
Assert
.
notNull
(
request
,
"
'request'
must not be null"
);
Assert
.
notNull
(
request
,
"
HttpRequest
must not be null"
);
this
.
request
=
request
;
}
/**
* Return
s
the wrapped request.
* Return the wrapped request.
*/
public
HttpRequest
getRequest
()
{
return
request
;
return
this
.
request
;
}
/**
* Return
s
the method of the wrapped request.
* Return the method of the wrapped request.
*/
@Override
public
HttpMethod
getMethod
()
{
...
...
@@ -61,7 +63,7 @@ public class HttpRequestWrapper implements HttpRequest {
}
/**
* Return
s
the URI of the wrapped request.
* Return the URI of the wrapped request.
*/
@Override
public
URI
getURI
()
{
...
...
@@ -69,7 +71,7 @@ public class HttpRequestWrapper implements HttpRequest {
}
/**
* Return
s
the headers of the wrapped request.
* Return the headers of the wrapped request.
*/
@Override
public
HttpHeaders
getHeaders
()
{
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.java
浏览文件 @
11806b92
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -41,36 +41,39 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
private
final
boolean
isNegated
;
AbstractMediaTypeExpression
(
String
expression
)
{
if
(
expression
.
startsWith
(
"!"
))
{
isNegated
=
true
;
this
.
isNegated
=
true
;
expression
=
expression
.
substring
(
1
);
}
else
{
isNegated
=
false
;
this
.
isNegated
=
false
;
}
this
.
mediaType
=
MediaType
.
parseMediaType
(
expression
);
}
AbstractMediaTypeExpression
(
MediaType
mediaType
,
boolean
negated
)
{
this
.
mediaType
=
mediaType
;
isNegated
=
negated
;
this
.
isNegated
=
negated
;
}
@Override
public
MediaType
getMediaType
()
{
return
mediaType
;
return
this
.
mediaType
;
}
@Override
public
boolean
isNegated
()
{
return
isNegated
;
return
this
.
isNegated
;
}
public
final
boolean
match
(
HttpServletRequest
request
)
{
try
{
boolean
match
=
matchMediaType
(
request
);
return
!
isNegated
?
match
:
!
match
;
return
(!
this
.
isNegated
?
match
:
!
match
)
;
}
catch
(
HttpMediaTypeException
ex
)
{
return
false
;
...
...
@@ -79,6 +82,7 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
protected
abstract
boolean
matchMediaType
(
HttpServletRequest
request
)
throws
HttpMediaTypeException
;
@Override
public
int
compareTo
(
AbstractMediaTypeExpression
other
)
{
return
MediaType
.
SPECIFICITY_COMPARATOR
.
compare
(
this
.
getMediaType
(),
other
.
getMediaType
());
...
...
@@ -89,25 +93,25 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
!=
null
&&
getClass
()
.
equals
(
obj
.
getClass
()
))
{
if
(
obj
!=
null
&&
getClass
()
==
obj
.
getClass
(
))
{
AbstractMediaTypeExpression
other
=
(
AbstractMediaTypeExpression
)
obj
;
return
(
this
.
mediaType
.
equals
(
other
.
mediaType
)
)
&&
(
this
.
isNegated
==
other
.
isNegated
);
return
(
this
.
mediaType
.
equals
(
other
.
mediaType
)
&&
this
.
isNegated
==
other
.
isNegated
);
}
return
false
;
}
@Override
public
int
hashCode
()
{
return
mediaType
.
hashCode
();
return
this
.
mediaType
.
hashCode
();
}
@Override
public
String
toString
()
{
StringBuilder
builder
=
new
StringBuilder
();
if
(
isNegated
)
{
if
(
this
.
isNegated
)
{
builder
.
append
(
'!'
);
}
builder
.
append
(
mediaType
.
toString
());
builder
.
append
(
this
.
mediaType
.
toString
());
return
builder
.
toString
();
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java
浏览文件 @
11806b92
...
...
@@ -33,7 +33,7 @@ public abstract class AbstractRequestCondition<T extends AbstractRequestConditio
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
!=
null
&&
getClass
()
.
equals
(
obj
.
getClass
()
))
{
if
(
obj
!=
null
&&
getClass
()
==
obj
.
getClass
(
))
{
AbstractRequestCondition
<?>
other
=
(
AbstractRequestCondition
<?>)
obj
;
return
getContent
().
equals
(
other
.
getContent
());
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java
浏览文件 @
11806b92
...
...
@@ -158,7 +158,7 @@ public class PathResourceResolver extends AbstractResourceResolver {
}
private
boolean
isResourceUnderLocation
(
Resource
resource
,
Resource
location
)
throws
IOException
{
if
(
!
resource
.
getClass
().
equals
(
location
.
getClass
()
))
{
if
(
resource
.
getClass
()
!=
location
.
getClass
(
))
{
return
false
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录