Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
dbd353bb
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,体验更适合开发者的 AI 搜索 >>
提交
dbd353bb
编写于
2月 18, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MessageHeaderAccessor defensively checks id, timestamp and contentType values
Issue: SPR-12730
上级
c7a456c0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
22 deletion
+35
-22
spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java
...in/java/org/springframework/messaging/MessageHeaders.java
+11
-10
spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java
...ingframework/messaging/support/MessageHeaderAccessor.java
+24
-12
未找到文件。
spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java
浏览文件 @
dbd353bb
/*
* 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.
...
...
@@ -70,16 +70,8 @@ import org.springframework.util.IdGenerator;
*/
public
class
MessageHeaders
implements
Map
<
String
,
Object
>,
Serializable
{
private
static
final
long
serialVersionUID
=
7035068984263400920L
;
private
static
final
Log
logger
=
LogFactory
.
getLog
(
MessageHeaders
.
class
);
public
static
final
UUID
ID_VALUE_NONE
=
new
UUID
(
0
,
0
);
private
static
volatile
IdGenerator
idGenerator
=
null
;
private
static
final
IdGenerator
defaultIdGenerator
=
new
AlternativeJdkIdGenerator
();
/**
* The key for the Message ID. This is an automatically generated UUID and
* should never be explicitly set in the header map <b>except</b> in the
...
...
@@ -90,11 +82,20 @@ public class MessageHeaders implements Map<String, Object>, Serializable {
public
static
final
String
TIMESTAMP
=
"timestamp"
;
public
static
final
String
CONTENT_TYPE
=
"contentType"
;
public
static
final
String
REPLY_CHANNEL
=
"replyChannel"
;
public
static
final
String
ERROR_CHANNEL
=
"errorChannel"
;
public
static
final
String
CONTENT_TYPE
=
"contentType"
;
private
static
final
long
serialVersionUID
=
7035068984263400920L
;
private
static
final
Log
logger
=
LogFactory
.
getLog
(
MessageHeaders
.
class
);
private
static
final
IdGenerator
defaultIdGenerator
=
new
AlternativeJdkIdGenerator
();
private
static
volatile
IdGenerator
idGenerator
=
null
;
private
final
Map
<
String
,
Object
>
headers
;
...
...
spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java
浏览文件 @
dbd353bb
/*
* 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.
...
...
@@ -418,11 +418,31 @@ public class MessageHeaderAccessor {
// Specific header accessors
public
UUID
getId
()
{
return
(
UUID
)
getHeader
(
MessageHeaders
.
ID
);
Object
value
=
getHeader
(
MessageHeaders
.
ID
);
if
(
value
==
null
)
{
return
null
;
}
return
(
value
instanceof
UUID
?
(
UUID
)
value
:
UUID
.
fromString
(
value
.
toString
()));
}
public
Long
getTimestamp
()
{
return
(
Long
)
getHeader
(
MessageHeaders
.
TIMESTAMP
);
Object
value
=
getHeader
(
MessageHeaders
.
TIMESTAMP
);
if
(
value
==
null
)
{
return
null
;
}
return
(
value
instanceof
Long
?
(
Long
)
value
:
Long
.
parseLong
(
value
.
toString
()));
}
public
void
setContentType
(
MimeType
contentType
)
{
setHeader
(
MessageHeaders
.
CONTENT_TYPE
,
contentType
);
}
public
MimeType
getContentType
()
{
Object
value
=
getHeader
(
MessageHeaders
.
CONTENT_TYPE
);
if
(
value
==
null
)
{
return
null
;
}
return
(
value
instanceof
MimeType
?
(
MimeType
)
value
:
MimeType
.
valueOf
(
value
.
toString
()));
}
public
void
setReplyChannelName
(
String
replyChannelName
)
{
...
...
@@ -449,14 +469,6 @@ public class MessageHeaderAccessor {
return
getHeader
(
MessageHeaders
.
ERROR_CHANNEL
);
}
public
void
setContentType
(
MimeType
contentType
)
{
setHeader
(
MessageHeaders
.
CONTENT_TYPE
,
contentType
);
}
public
MimeType
getContentType
()
{
return
(
MimeType
)
getHeader
(
MessageHeaders
.
CONTENT_TYPE
);
}
// Log message stuff
...
...
@@ -508,7 +520,7 @@ public class MessageHeaderAccessor {
protected
String
getDetailedPayloadLogMessage
(
Object
payload
)
{
if
(
payload
instanceof
String
)
{
return
" payload="
+
((
String
)
payload
)
;
return
" payload="
+
payload
;
}
else
if
(
payload
instanceof
byte
[])
{
byte
[]
bytes
=
(
byte
[])
payload
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录