Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
6cdc208c
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 搜索 >>
提交
6cdc208c
编写于
5月 23, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
fd1b5e80
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
20 deletion
+21
-20
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
...work/http/converter/json/Jackson2ObjectMapperBuilder.java
+6
-6
spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java
...amework/web/socket/messaging/StompSubProtocolHandler.java
+15
-14
未找到文件。
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
浏览文件 @
6cdc208c
...
...
@@ -237,7 +237,7 @@ public class Jackson2ObjectMapperBuilder {
* @since 4.1.2
*/
public
Jackson2ObjectMapperBuilder
serializerByType
(
Class
<?>
type
,
JsonSerializer
<?>
serializer
)
{
if
(
serializer
s
!=
null
)
{
if
(
serializer
!=
null
)
{
this
.
serializers
.
put
(
type
,
serializer
);
}
return
this
;
...
...
@@ -259,7 +259,7 @@ public class Jackson2ObjectMapperBuilder {
* @since 4.1.2
*/
public
Jackson2ObjectMapperBuilder
deserializerByType
(
Class
<?>
type
,
JsonDeserializer
<?>
deserializer
)
{
if
(
deserializer
s
!=
null
)
{
if
(
deserializer
!=
null
)
{
this
.
deserializers
.
put
(
type
,
deserializer
);
}
return
this
;
...
...
@@ -566,7 +566,9 @@ public class Jackson2ObjectMapperBuilder {
if
(
this
.
annotationIntrospector
!=
null
)
{
objectMapper
.
setAnnotationIntrospector
(
this
.
annotationIntrospector
);
}
if
(
this
.
propertyNamingStrategy
!=
null
)
{
objectMapper
.
setPropertyNamingStrategy
(
this
.
propertyNamingStrategy
);
}
if
(
this
.
serializationInclusion
!=
null
)
{
objectMapper
.
setSerializationInclusion
(
this
.
serializationInclusion
);
}
...
...
@@ -583,13 +585,11 @@ public class Jackson2ObjectMapperBuilder {
configureFeature
(
objectMapper
,
feature
,
this
.
features
.
get
(
feature
));
}
if
(
this
.
propertyNamingStrategy
!=
null
)
{
objectMapper
.
setPropertyNamingStrategy
(
this
.
propertyNamingStrategy
);
}
for
(
Class
<?>
target
:
this
.
mixIns
.
keySet
())
{
// Deprecated as of Jackson 2.5, but just in favor of a fluent variant.
objectMapper
.
addMixInAnnotations
(
target
,
this
.
mixIns
.
get
(
target
));
}
if
(
this
.
handlerInstantiator
!=
null
)
{
objectMapper
.
setHandlerInstantiator
(
this
.
handlerInstantiator
);
}
...
...
spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java
浏览文件 @
6cdc208c
...
...
@@ -115,9 +115,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
* Since a STOMP message can be received in multiple WebSocket messages,
* buffering may be required and therefore it is necessary to know the maximum
* allowed message size.
*
* <p>By default this property is set to 64K.
*
* @since 4.0.3
*/
public
void
setMessageSizeLimit
(
int
messageSizeLimit
)
{
...
...
@@ -126,7 +124,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
/**
* Get the configured message buffer size limit in bytes.
*
* @since 4.0.3
*/
public
int
getMessageSizeLimit
()
{
...
...
@@ -142,7 +139,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
/**
*
@r
eturn the configured UserSessionRegistry.
*
R
eturn the configured UserSessionRegistry.
*/
public
UserSessionRegistry
getUserSessionRegistry
()
{
return
this
.
userSessionRegistry
;
...
...
@@ -152,7 +149,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
* Configure a {@link MessageHeaderInitializer} to apply to the headers of all
* messages created from decoded STOMP frames and other messages sent to the
* client inbound channel.
*
* <p>By default this property is not set.
*/
public
void
setHeaderInitializer
(
MessageHeaderInitializer
headerInitializer
)
{
...
...
@@ -161,7 +157,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
/**
*
@r
eturn the configured header initializer.
*
R
eturn the configured header initializer.
*/
public
MessageHeaderInitializer
getHeaderInitializer
()
{
return
this
.
headerInitializer
;
...
...
@@ -274,7 +270,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
logger
.
error
(
"Failed to send client message to application via MessageChannel"
+
" in session "
+
session
.
getId
()
+
". Sending STOMP ERROR to client."
,
ex
);
sendErrorMessage
(
session
,
ex
);
}
}
}
...
...
@@ -300,13 +295,14 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
this
.
eventPublisher
.
publishEvent
(
event
);
}
catch
(
Throwable
ex
)
{
logger
.
error
(
"Error publishing "
+
event
+
"."
,
ex
);
logger
.
error
(
"Error publishing "
+
event
,
ex
);
}
}
protected
void
sendErrorMessage
(
WebSocketSession
session
,
Throwable
error
)
{
StompHeaderAccessor
headerAccessor
=
StompHeaderAccessor
.
create
(
StompCommand
.
ERROR
);
headerAccessor
.
setMessage
(
error
.
getMessage
());
byte
[]
bytes
=
this
.
stompEncoder
.
encode
(
headerAccessor
.
getMessageHeaders
(),
EMPTY_PAYLOAD
);
try
{
session
.
sendMessage
(
new
TextMessage
(
bytes
));
...
...
@@ -327,8 +323,10 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
logger
.
error
(
"Expected byte[] payload. Ignoring "
+
message
+
"."
);
return
;
}
StompHeaderAccessor
stompAccessor
=
getStompHeaderAccessor
(
message
);
StompCommand
command
=
stompAccessor
.
getCommand
();
if
(
StompCommand
.
MESSAGE
.
equals
(
command
))
{
if
(
stompAccessor
.
getSubscriptionId
()
==
null
)
{
logger
.
warn
(
"No STOMP \"subscription\" header in "
+
message
);
...
...
@@ -374,7 +372,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
catch
(
Throwable
ex
)
{
// Could be part of normal workflow (e.g. browser tab closed)
logger
.
debug
(
"Failed to send WebSocket message to client in session "
+
session
.
getId
()
+
"."
,
ex
);
logger
.
debug
(
"Failed to send WebSocket message to client in session "
+
session
.
getId
(),
ex
);
command
=
StompCommand
.
ERROR
;
}
finally
{
...
...
@@ -393,7 +391,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
MessageHeaderAccessor
accessor
=
MessageHeaderAccessor
.
getAccessor
(
message
,
MessageHeaderAccessor
.
class
);
if
(
accessor
==
null
)
{
// Shouldn't happen (only broker broadcasts directly to clients)
throw
new
IllegalStateException
(
"No header accessor in "
+
message
+
"."
);
throw
new
IllegalStateException
(
"No header accessor in "
+
message
);
}
StompHeaderAccessor
stompAccessor
;
if
(
accessor
instanceof
StompHeaderAccessor
)
{
...
...
@@ -415,7 +413,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
else
{
// Shouldn't happen (only broker broadcasts directly to clients)
throw
new
IllegalStateException
(
"Unexpected header accessor type: "
+
accessor
.
getClass
()
+
" in "
+
message
+
"."
);
"Unexpected header accessor type: "
+
accessor
.
getClass
()
+
" in "
+
message
);
}
return
stompAccessor
;
}
...
...
@@ -465,6 +463,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
this
.
userSessionRegistry
.
registerSessionId
(
userName
,
session
.
getId
());
}
}
long
[]
heartbeat
=
accessor
.
getHeartbeat
();
if
(
heartbeat
[
1
]
>
0
)
{
session
=
WebSocketSessionDecorator
.
unwrap
(
session
);
...
...
@@ -472,6 +471,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
((
SockJsSession
)
session
).
disableHeartbeat
();
}
}
return
accessor
;
}
...
...
@@ -499,11 +499,13 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
@Override
public
void
afterSessionEnded
(
WebSocketSession
session
,
CloseStatus
closeStatus
,
MessageChannel
outputChannel
)
{
this
.
decoders
.
remove
(
session
.
getId
());
Principal
principal
=
session
.
getPrincipal
();
if
(
principal
!=
null
&&
this
.
userSessionRegistry
!=
null
)
{
String
userName
=
getSessionRegistryUserName
(
principal
);
this
.
userSessionRegistry
.
unregisterSessionId
(
userName
,
session
.
getId
());
}
Message
<
byte
[]>
message
=
createDisconnectMessage
(
session
);
SimpAttributes
simpAttributes
=
SimpAttributes
.
fromMessage
(
message
);
try
{
...
...
@@ -535,7 +537,8 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
return
"StompSubProtocolHandler"
+
getSupportedProtocols
();
}
private
class
Stats
{
private
static
class
Stats
{
private
final
AtomicInteger
connect
=
new
AtomicInteger
();
...
...
@@ -543,7 +546,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private
final
AtomicInteger
disconnect
=
new
AtomicInteger
();
public
void
incrementConnectCount
()
{
this
.
connect
.
incrementAndGet
();
}
...
...
@@ -556,7 +558,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
this
.
disconnect
.
incrementAndGet
();
}
public
String
toString
()
{
return
"processed CONNECT("
+
this
.
connect
.
get
()
+
")-CONNECTED("
+
this
.
connected
.
get
()
+
")-DISCONNECT("
+
this
.
disconnect
.
get
()
+
")"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录