Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
02cb8665
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 搜索 >>
提交
02cb8665
编写于
9月 30, 2013
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prevent cache of sockjs known prefixes from growing
Issue: SPR-10893
上级
e60e8dc5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
6 deletion
+16
-6
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java
...work/web/socket/sockjs/support/AbstractSockJsService.java
+16
-6
未找到文件。
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java
浏览文件 @
02cb8665
...
...
@@ -26,8 +26,7 @@ import java.util.Date;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.Set
;
import
java.util.concurrent.CopyOnWriteArraySet
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.logging.Log
;
...
...
@@ -66,6 +65,8 @@ import org.springframework.web.socket.sockjs.SockJsService;
*/
public
abstract
class
AbstractSockJsService
implements
SockJsService
{
private
static
final
int
MAX_KNOWN_SOCKJS_PREFIX_COUNT
=
100
;
protected
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
private
static
final
long
ONE_YEAR
=
TimeUnit
.
DAYS
.
toSeconds
(
365
);
...
...
@@ -91,7 +92,7 @@ public abstract class AbstractSockJsService implements SockJsService {
private
final
List
<
String
>
validSockJsPrefixes
=
new
ArrayList
<
String
>();
private
final
Set
<
String
>
knownSockJsPrefixes
=
new
CopyOnWriteArraySe
t
<
String
>();
private
final
List
<
String
>
knownSockJsPrefixes
=
new
CopyOnWriteArrayLis
t
<
String
>();
public
AbstractSockJsService
(
TaskScheduler
scheduler
)
{
...
...
@@ -376,7 +377,6 @@ public abstract class AbstractSockJsService implements SockJsService {
for
(
String
prefix
:
this
.
validSockJsPrefixes
)
{
int
index
=
path
.
lastIndexOf
(
prefix
);
if
(
index
!=
-
1
)
{
this
.
knownSockJsPrefixes
.
add
(
path
.
substring
(
0
,
index
+
prefix
.
length
()));
return
path
.
substring
(
index
+
prefix
.
length
());
}
}
...
...
@@ -385,7 +385,7 @@ public abstract class AbstractSockJsService implements SockJsService {
// Try SockJS info request
if
(
path
.
endsWith
(
"/info"
))
{
this
.
knownSockJsPrefixes
.
add
(
path
.
substring
(
0
,
path
.
length
()
-
"/info"
.
length
()));
addKnownSockJsPrefix
(
path
.
substring
(
0
,
path
.
length
()
-
"/info"
.
length
()));
return
"/info"
;
}
...
...
@@ -412,13 +412,23 @@ public abstract class AbstractSockJsService implements SockJsService {
String
lastSegment
=
pathNoSlash
.
substring
(
pathNoSlash
.
lastIndexOf
(
'/'
)
+
1
);
if
(!
isValidTransportType
(
lastSegment
)
&&
!
lastSegment
.
startsWith
(
"iframe"
))
{
this
.
knownSockJsPrefixes
.
add
(
path
);
addKnownSockJsPrefix
(
path
);
return
""
;
}
return
null
;
}
private
void
addKnownSockJsPrefix
(
String
path
)
{
if
(
this
.
knownSockJsPrefixes
.
size
()
>
MAX_KNOWN_SOCKJS_PREFIX_COUNT
)
{
String
removed
=
this
.
knownSockJsPrefixes
.
remove
(
0
);
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
"MAX_KNOWN_SOCKJS_PREFIX_COUNT reached, removed prefix "
+
removed
);
}
}
this
.
knownSockJsPrefixes
.
add
(
path
);
}
/**
* Validate whether the given transport String extracted from the URL is a valid
* SockJS transport type (regardless of whether a transport handler is configured).
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录