Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.-Smile-.
spring-framework
提交
e8417ea6
S
spring-framework
项目概览
.-Smile-.
/
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,体验更适合开发者的 AI 搜索 >>
提交
e8417ea6
编写于
11月 24, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SimpAnnotationMethodMessageHandler skips template variable check in case of no pattern
Issue: SPR-13704
上级
9d9433a6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
20 deletion
+24
-20
spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java
...nnotation/support/SimpAnnotationMethodMessageHandler.java
+17
-15
spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java
...ingframework/messaging/support/MessageHeaderAccessor.java
+7
-5
未找到文件。
spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java
浏览文件 @
e8417ea6
...
...
@@ -86,8 +86,8 @@ import org.springframework.validation.Validator;
public
class
SimpAnnotationMethodMessageHandler
extends
AbstractMethodMessageHandler
<
SimpMessageMappingInfo
>
implements
EmbeddedValueResolverAware
,
SmartLifecycle
{
private
static
final
boolean
completableFuturePresent
=
ClassUtils
.
isPresent
(
"java.util.concurrent.CompletableFuture"
,
SimpAnnotationMethodMessageHandler
.
class
.
getClassLoader
());
private
static
final
boolean
completableFuturePresent
=
ClassUtils
.
isPresent
(
"java.util.concurrent.CompletableFuture"
,
SimpAnnotationMethodMessageHandler
.
class
.
getClassLoader
());
private
final
SubscribableChannel
clientInboundChannel
;
...
...
@@ -304,9 +304,8 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
protected
List
<
HandlerMethodArgumentResolver
>
initArgumentResolvers
()
{
ConfigurableBeanFactory
beanFactory
=
(
ClassUtils
.
isAssignableValue
(
ConfigurableApplicationContext
.
class
,
getApplicationContext
()))
?
((
ConfigurableApplicationContext
)
getApplicationContext
()).
getBeanFactory
()
:
null
;
ConfigurableBeanFactory
beanFactory
=
(
getApplicationContext
()
instanceof
ConfigurableApplicationContext
?
((
ConfigurableApplicationContext
)
getApplicationContext
()).
getBeanFactory
()
:
null
);
List
<
HandlerMethodArgumentResolver
>
resolvers
=
new
ArrayList
<
HandlerMethodArgumentResolver
>();
...
...
@@ -327,7 +326,6 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
@Override
protected
List
<?
extends
HandlerMethodReturnValueHandler
>
initReturnValueHandlers
()
{
List
<
HandlerMethodReturnValueHandler
>
handlers
=
new
ArrayList
<
HandlerMethodReturnValueHandler
>();
// Single-purpose return value types
...
...
@@ -337,11 +335,13 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
}
// Annotation-based return value types
SendToMethodReturnValueHandler
sth
=
new
SendToMethodReturnValueHandler
(
this
.
brokerTemplate
,
true
);
SendToMethodReturnValueHandler
sth
=
new
SendToMethodReturnValueHandler
(
this
.
brokerTemplate
,
true
);
sth
.
setHeaderInitializer
(
this
.
headerInitializer
);
handlers
.
add
(
sth
);
SubscriptionMethodReturnValueHandler
sh
=
new
SubscriptionMethodReturnValueHandler
(
this
.
clientMessagingTemplate
);
SubscriptionMethodReturnValueHandler
sh
=
new
SubscriptionMethodReturnValueHandler
(
this
.
clientMessagingTemplate
);
sh
.
setHeaderInitializer
(
this
.
headerInitializer
);
handlers
.
add
(
sh
);
...
...
@@ -468,13 +468,15 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
protected
void
handleMatch
(
SimpMessageMappingInfo
mapping
,
HandlerMethod
handlerMethod
,
String
lookupDestination
,
Message
<?>
message
)
{
String
matchedPattern
=
mapping
.
getDestinationConditions
().
getPatterns
().
iterator
().
next
();
Map
<
String
,
String
>
vars
=
getPathMatcher
().
extractUriTemplateVariables
(
matchedPattern
,
lookupDestination
);
if
(!
CollectionUtils
.
isEmpty
(
vars
))
{
MessageHeaderAccessor
accessor
=
MessageHeaderAccessor
.
getAccessor
(
message
,
MessageHeaderAccessor
.
class
);
Assert
.
state
(
accessor
!=
null
&&
accessor
.
isMutable
());
accessor
.
setHeader
(
DestinationVariableMethodArgumentResolver
.
DESTINATION_TEMPLATE_VARIABLES_HEADER
,
vars
);
Set
<
String
>
patterns
=
mapping
.
getDestinationConditions
().
getPatterns
();
if
(!
CollectionUtils
.
isEmpty
(
patterns
))
{
String
pattern
=
patterns
.
iterator
().
next
();
Map
<
String
,
String
>
vars
=
getPathMatcher
().
extractUriTemplateVariables
(
pattern
,
lookupDestination
);
if
(!
CollectionUtils
.
isEmpty
(
vars
))
{
MessageHeaderAccessor
mha
=
MessageHeaderAccessor
.
getAccessor
(
message
,
MessageHeaderAccessor
.
class
);
Assert
.
state
(
mha
!=
null
&&
mha
.
isMutable
());
mha
.
setHeader
(
DestinationVariableMethodArgumentResolver
.
DESTINATION_TEMPLATE_VARIABLES_HEADER
,
vars
);
}
}
try
{
...
...
spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java
浏览文件 @
e8417ea6
...
...
@@ -319,7 +319,8 @@ public class MessageHeaderAccessor {
protected
void
verifyType
(
String
headerName
,
Object
headerValue
)
{
if
(
headerName
!=
null
&&
headerValue
!=
null
)
{
if
(
MessageHeaders
.
ERROR_CHANNEL
.
equals
(
headerName
)
||
MessageHeaders
.
REPLY_CHANNEL
.
endsWith
(
headerName
))
{
if
(
MessageHeaders
.
ERROR_CHANNEL
.
equals
(
headerName
)
||
MessageHeaders
.
REPLY_CHANNEL
.
endsWith
(
headerName
))
{
if
(!(
headerValue
instanceof
MessageChannel
||
headerValue
instanceof
String
))
{
throw
new
IllegalArgumentException
(
"'"
+
headerName
+
"' header value must be a MessageChannel or String"
);
...
...
@@ -572,11 +573,13 @@ public class MessageHeaderAccessor {
* A variation of {@link #getAccessor(org.springframework.messaging.Message, Class)}
* with a {@code MessageHeaders} instance instead of a {@code Message}.
* <p>This is for cases when a full message may not have been created yet.
* @return an accessor instance of the specified type
m
or {@code null} if none
* @return an accessor instance of the specified type
,
or {@code null} if none
* @since 4.1
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
extends
MessageHeaderAccessor
>
T
getAccessor
(
MessageHeaders
messageHeaders
,
Class
<
T
>
requiredType
)
{
public
static
<
T
extends
MessageHeaderAccessor
>
T
getAccessor
(
MessageHeaders
messageHeaders
,
Class
<
T
>
requiredType
)
{
if
(
messageHeaders
instanceof
MutableMessageHeaders
)
{
MutableMessageHeaders
mutableHeaders
=
(
MutableMessageHeaders
)
messageHeaders
;
MessageHeaderAccessor
headerAccessor
=
mutableHeaders
.
getMessageHeaderAccessor
();
...
...
@@ -593,7 +596,7 @@ public class MessageHeaderAccessor {
* wrapping the message with a {@code MessageHeaderAccessor} instance.
* <p>This is for cases where a header needs to be updated in generic code
* while preserving the accessor type for downstream processing.
* @return an accessor of the required type
, never {@code null}.
* @return an accessor of the required type
(never {@code null})
* @since 4.1
*/
public
static
MessageHeaderAccessor
getMutableAccessor
(
Message
<?>
message
)
{
...
...
@@ -646,7 +649,6 @@ public class MessageHeaderAccessor {
if
(
getId
()
==
null
)
{
IdGenerator
idGenerator
=
(
MessageHeaderAccessor
.
this
.
idGenerator
!=
null
?
MessageHeaderAccessor
.
this
.
idGenerator
:
MessageHeaders
.
getIdGenerator
());
UUID
id
=
idGenerator
.
generateId
();
if
(
id
!=
null
&&
id
!=
MessageHeaders
.
ID_VALUE_NONE
)
{
getRawHeaders
().
put
(
ID
,
id
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录