Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
五度鱼学Java
jenkins
提交
6ff1c684
J
jenkins
项目概览
五度鱼学Java
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6ff1c684
编写于
11月 20, 2022
作者:
J
Jesse Glick
提交者:
Kris Stern
12月 13, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-70103] `WeakHashMap` broken for looking up Jetty `Session` in WebSocket response (#7412)
(cherry picked from commit
aedacbab
)
上级
521f3d83
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
20 deletion
+16
-20
core/src/main/java/jenkins/websocket/WebSockets.java
core/src/main/java/jenkins/websocket/WebSockets.java
+9
-1
websocket/jetty10/src/main/java/jenkins/websocket/Jetty10Provider.java
...ty10/src/main/java/jenkins/websocket/Jetty10Provider.java
+2
-9
websocket/jetty9/src/main/java/jenkins/websocket/Jetty9Provider.java
...etty9/src/main/java/jenkins/websocket/Jetty9Provider.java
+2
-9
websocket/spi/src/main/java/jenkins/websocket/Provider.java
websocket/spi/src/main/java/jenkins/websocket/Provider.java
+3
-1
未找到文件。
core/src/main/java/jenkins/websocket/WebSockets.java
浏览文件 @
6ff1c684
...
...
@@ -68,12 +68,20 @@ public class WebSockets {
return
(
req
,
rsp
,
node
)
->
{
try
{
session
.
handler
=
provider
.
handle
(
req
,
rsp
,
new
Provider
.
Listener
()
{
private
Object
providerSession
;
@Override
public
void
onWebSocketConnect
()
{
public
void
onWebSocketConnect
(
Object
providerSession
)
{
this
.
providerSession
=
providerSession
;
session
.
startPings
();
session
.
opened
();
}
@Override
public
Object
getProviderSession
()
{
return
providerSession
;
}
@Override
public
void
onWebSocketClose
(
int
statusCode
,
String
reason
)
{
session
.
stopPings
();
...
...
websocket/jetty10/src/main/java/jenkins/websocket/Jetty10Provider.java
浏览文件 @
6ff1c684
...
...
@@ -26,9 +26,6 @@ package jenkins.websocket;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.WeakHashMap
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.Future
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -49,9 +46,6 @@ public class Jetty10Provider implements Provider {
private
static
final
String
ATTR_LISTENER
=
Jetty10Provider
.
class
.
getName
()
+
".listener"
;
// TODO does not seem possible to use HttpServletRequest.get/setAttribute for this
private
static
final
Map
<
Listener
,
Session
>
sessions
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<>());
public
Jetty10Provider
()
{
JettyWebSocketServerContainer
.
class
.
hashCode
();
}
...
...
@@ -101,7 +95,7 @@ public class Jetty10Provider implements Provider {
}
private
Session
session
()
{
Session
session
=
sessions
.
get
(
listener
);
Session
session
=
(
Session
)
listener
.
getProviderSession
(
);
if
(
session
==
null
)
{
throw
new
IllegalStateException
(
"missing session"
);
}
...
...
@@ -151,8 +145,7 @@ public class Jetty10Provider implements Provider {
@Override
public
void
onWebSocketConnect
(
Session
session
)
{
sessions
.
put
(
listener
,
session
);
listener
.
onWebSocketConnect
();
listener
.
onWebSocketConnect
(
session
);
}
@Override
...
...
websocket/jetty9/src/main/java/jenkins/websocket/Jetty9Provider.java
浏览文件 @
6ff1c684
...
...
@@ -26,9 +26,6 @@ package jenkins.websocket;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.WeakHashMap
;
import
java.util.concurrent.Future
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -48,9 +45,6 @@ public class Jetty9Provider implements Provider {
private
static
final
String
ATTR_LISTENER
=
Jetty9Provider
.
class
.
getName
()
+
".listener"
;
// TODO does not seem possible to use HttpServletRequest.get/setAttribute for this
private
static
final
Map
<
Listener
,
Session
>
sessions
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<>());
private
WebSocketServletFactory
factory
;
public
Jetty9Provider
()
{
...
...
@@ -104,7 +98,7 @@ public class Jetty9Provider implements Provider {
}
private
Session
session
()
{
Session
session
=
sessions
.
get
(
listener
);
Session
session
=
(
Session
)
listener
.
getProviderSession
(
);
if
(
session
==
null
)
{
throw
new
IllegalStateException
(
"missing session"
);
}
...
...
@@ -136,8 +130,7 @@ public class Jetty9Provider implements Provider {
@Override
public
void
onWebSocketConnect
(
Session
session
)
{
sessions
.
put
(
listener
,
session
);
listener
.
onWebSocketConnect
();
listener
.
onWebSocketConnect
(
session
);
}
@Override
...
...
websocket/spi/src/main/java/jenkins/websocket/Provider.java
浏览文件 @
6ff1c684
...
...
@@ -47,7 +47,9 @@ interface Provider {
interface
Listener
{
void
onWebSocketConnect
();
void
onWebSocketConnect
(
Object
providerSession
);
Object
getProviderSession
();
void
onWebSocketClose
(
int
statusCode
,
String
reason
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录