Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d30b0094
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d30b0094
编写于
1月 09, 2017
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8169465: Deadlock in com.sun.jndi.ldap.pool.Connections
Reviewed-by: dfuchs, vtewari
上级
a7e89a59
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
24 deletion
+36
-24
src/share/classes/com/sun/jndi/ldap/pool/Connections.java
src/share/classes/com/sun/jndi/ldap/pool/Connections.java
+19
-15
src/share/classes/com/sun/jndi/ldap/pool/Pool.java
src/share/classes/com/sun/jndi/ldap/pool/Pool.java
+17
-9
未找到文件。
src/share/classes/com/sun/jndi/ldap/pool/Connections.java
浏览文件 @
d30b0094
...
@@ -27,7 +27,6 @@ package com.sun.jndi.ldap.pool;
...
@@ -27,7 +27,6 @@ package com.sun.jndi.ldap.pool;
import
java.util.ArrayList
;
// JDK 1.2
import
java.util.ArrayList
;
// JDK 1.2
import
java.util.List
;
import
java.util.List
;
import
java.util.Iterator
;
import
java.lang.ref.Reference
;
import
java.lang.ref.Reference
;
import
java.lang.ref.SoftReference
;
import
java.lang.ref.SoftReference
;
...
@@ -290,23 +289,28 @@ final class Connections implements PoolCallback {
...
@@ -290,23 +289,28 @@ final class Connections implements PoolCallback {
* @param threshold an entry idle since this time has expired.
* @param threshold an entry idle since this time has expired.
* @return true if no more connections in list
* @return true if no more connections in list
*/
*/
synchronized
boolean
expire
(
long
threshold
)
{
boolean
expire
(
long
threshold
)
{
Iterator
<
ConnectionDesc
>
iter
=
conns
.
iterator
();
List
<
ConnectionDesc
>
clonedConns
;
ConnectionDesc
entry
;
synchronized
(
this
)
{
while
(
iter
.
hasNext
())
{
clonedConns
=
new
ArrayList
<>(
conns
);
entry
=
iter
.
next
();
}
if
(
entry
.
expire
(
threshold
))
{
List
<
ConnectionDesc
>
expired
=
new
ArrayList
<>();
d
(
"expire(): removing "
,
entry
);
td
(
"Expired "
,
entry
);
iter
.
remove
();
// remove from pool
// Don't need to call notify() because we're
for
(
ConnectionDesc
entry
:
clonedConns
)
{
// removing only idle connections. If there were
d
(
"expire(): "
,
entry
);
// idle connections, then there should be no waiters.
if
(
entry
.
expire
(
threshold
))
{
expired
.
add
(
entry
);
td
(
"expire(): Expired "
,
entry
);
}
}
}
}
return
conns
.
isEmpty
();
// whether whole list has 'expired'
synchronized
(
this
)
{
conns
.
removeAll
(
expired
);
// Don't need to call notify() because we're
// removing only idle connections. If there were
// idle connections, then there should be no waiters.
return
conns
.
isEmpty
();
// whether whole list has 'expired'
}
}
}
/**
/**
...
...
src/share/classes/com/sun/jndi/ldap/pool/Pool.java
浏览文件 @
d30b0094
...
@@ -25,11 +25,11 @@
...
@@ -25,11 +25,11 @@
package
com.sun.jndi.ldap.pool
;
package
com.sun.jndi.ldap.pool
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.WeakHashMap
;
import
java.util.WeakHashMap
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
...
@@ -166,17 +166,25 @@ final public class Pool {
...
@@ -166,17 +166,25 @@ final public class Pool {
* and removed.
* and removed.
*/
*/
public
void
expire
(
long
threshold
)
{
public
void
expire
(
long
threshold
)
{
Collection
<
ConnectionsRef
>
copy
;
synchronized
(
map
)
{
synchronized
(
map
)
{
Iterator
<
ConnectionsRef
>
iter
=
map
.
values
().
iterator
();
copy
=
new
ArrayList
<>(
map
.
values
());
Connections
conns
;
}
while
(
iter
.
hasNext
())
{
conns
=
iter
.
next
().
getConnections
();
ArrayList
<
ConnectionsRef
>
removed
=
new
ArrayList
<>();
if
(
conns
.
expire
(
threshold
))
{
Connections
conns
;
d
(
"expire(): removing "
,
conns
);
for
(
ConnectionsRef
ref
:
copy
)
{
iter
.
remove
();
conns
=
ref
.
getConnections
();
}
if
(
conns
.
expire
(
threshold
))
{
d
(
"expire(): removing "
,
conns
);
removed
.
add
(
ref
);
}
}
}
}
synchronized
(
map
)
{
map
.
values
().
removeAll
(
removed
);
}
expungeStaleConnections
();
expungeStaleConnections
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录