Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0a3a2c67
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a3a2c67
编写于
2月 06, 2018
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8156824: com.sun.jndi.ldap.pool.PoolCleaner should clear its context class loader
Reviewed-by: chegar
上级
fd2d43a5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
12 deletion
+64
-12
src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
+12
-1
src/share/classes/com/sun/jndi/ldap/pool/PoolCleaner.java
src/share/classes/com/sun/jndi/ldap/pool/PoolCleaner.java
+2
-2
src/share/classes/sun/misc/InnocuousThread.java
src/share/classes/sun/misc/InnocuousThread.java
+50
-9
未找到文件。
src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
浏览文件 @
0a3a2c67
...
@@ -39,6 +39,7 @@ import java.security.PrivilegedAction;
...
@@ -39,6 +39,7 @@ import java.security.PrivilegedAction;
import
com.sun.jndi.ldap.pool.PoolCleaner
;
import
com.sun.jndi.ldap.pool.PoolCleaner
;
import
com.sun.jndi.ldap.pool.Pool
;
import
com.sun.jndi.ldap.pool.Pool
;
import
sun.misc.InnocuousThread
;
/**
/**
* Contains utilities for managing connection pools of LdapClient.
* Contains utilities for managing connection pools of LdapClient.
...
@@ -163,7 +164,17 @@ public final class LdapPoolManager {
...
@@ -163,7 +164,17 @@ public final class LdapPoolManager {
if
(
idleTimeout
>
0
)
{
if
(
idleTimeout
>
0
)
{
// Create cleaner to expire idle connections
// Create cleaner to expire idle connections
new
PoolCleaner
(
idleTimeout
,
pools
).
start
();
PrivilegedAction
<
Void
>
pa
=
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
Thread
t
=
InnocuousThread
.
newSystemThread
(
"LDAP PoolCleaner"
,
new
PoolCleaner
(
idleTimeout
,
pools
));
assert
t
.
getContextClassLoader
()
==
null
;
t
.
setDaemon
(
true
);
t
.
start
();
return
null
;
}};
AccessController
.
doPrivileged
(
pa
);
}
}
if
(
debug
)
{
if
(
debug
)
{
...
...
src/share/classes/com/sun/jndi/ldap/pool/PoolCleaner.java
浏览文件 @
0a3a2c67
...
@@ -30,7 +30,7 @@ package com.sun.jndi.ldap.pool;
...
@@ -30,7 +30,7 @@ package com.sun.jndi.ldap.pool;
*
*
* @author Rosanna Lee
* @author Rosanna Lee
*/
*/
final
public
class
PoolCleaner
extends
Thread
{
final
public
class
PoolCleaner
implements
Runnable
{
final
private
Pool
[]
pools
;
final
private
Pool
[]
pools
;
final
private
long
period
;
final
private
long
period
;
...
@@ -42,9 +42,9 @@ final public class PoolCleaner extends Thread {
...
@@ -42,9 +42,9 @@ final public class PoolCleaner extends Thread {
super
();
super
();
this
.
period
=
period
;
this
.
period
=
period
;
this
.
pools
=
pools
.
clone
();
this
.
pools
=
pools
.
clone
();
setDaemon
(
true
);
}
}
@Override
public
void
run
()
{
public
void
run
()
{
long
threshold
;
long
threshold
;
while
(
true
)
{
while
(
true
)
{
...
...
src/share/classes/sun/misc/InnocuousThread.java
浏览文件 @
0a3a2c67
...
@@ -26,7 +26,10 @@
...
@@ -26,7 +26,10 @@
package
sun.misc
;
package
sun.misc
;
import
java.security.AccessControlContext
;
import
java.security.AccessControlContext
;
import
java.security.AccessController
;
import
java.security.ProtectionDomain
;
import
java.security.ProtectionDomain
;
import
java.security.PrivilegedAction
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
/**
* A thread that has no permissions, is not a member of any user-defined
* A thread that has no permissions, is not a member of any user-defined
...
@@ -36,15 +39,44 @@ import java.security.ProtectionDomain;
...
@@ -36,15 +39,44 @@ import java.security.ProtectionDomain;
*/
*/
public
final
class
InnocuousThread
extends
Thread
{
public
final
class
InnocuousThread
extends
Thread
{
private
static
final
Unsafe
UNSAFE
;
private
static
final
Unsafe
UNSAFE
;
private
static
final
ThreadGroup
THREADGROUP
;
private
static
final
long
THREAD_LOCALS
;
private
static
final
long
INHERITABLE_THREAD_LOCALS
;
private
static
final
ThreadGroup
INNOCUOUSTHREADGROUP
;
private
static
final
AccessControlContext
ACC
;
private
static
final
AccessControlContext
ACC
;
private
static
final
long
THREADLOCALS
;
private
static
final
long
INHERITABLETHREADLOCALS
;
private
static
final
long
INHERITEDACCESSCONTROLCONTEXT
;
private
static
final
long
INHERITEDACCESSCONTROLCONTEXT
;
private
static
final
long
CONTEXTCLASSLOADER
;
private
static
final
AtomicInteger
threadNumber
=
new
AtomicInteger
(
1
);
private
static
String
newName
()
{
return
"InnocuousThread-"
+
threadNumber
.
getAndIncrement
();
}
/**
* Returns a new InnocuousThread with an auto-generated thread name.
* Its context class loader is set to null.
*/
public
static
Thread
newSystemThread
(
Runnable
target
)
{
return
newSystemThread
(
newName
(),
target
);
}
/**
* Returns a new InnocuousThread with null context class loader.
*/
public
static
Thread
newSystemThread
(
String
name
,
Runnable
target
)
{
return
new
InnocuousThread
(
INNOCUOUSTHREADGROUP
,
target
,
name
,
null
);
}
public
InnocuousThread
(
Runnable
target
)
{
public
InnocuousThread
(
Runnable
target
)
{
super
(
THREADGROUP
,
target
,
"anInnocuousThread"
);
super
(
INNOCUOUSTHREADGROUP
,
target
,
newName
());
UNSAFE
.
putOrderedObject
(
this
,
INHERITEDACCESSCONTROLCONTEXT
,
ACC
);
eraseThreadLocals
();
}
private
InnocuousThread
(
ThreadGroup
group
,
Runnable
target
,
String
name
,
ClassLoader
tccl
)
{
super
(
group
,
target
,
name
,
0L
);
UNSAFE
.
putOrderedObject
(
this
,
INHERITEDACCESSCONTROLCONTEXT
,
ACC
);
UNSAFE
.
putOrderedObject
(
this
,
INHERITEDACCESSCONTROLCONTEXT
,
ACC
);
UNSAFE
.
putOrderedObject
(
this
,
CONTEXTCLASSLOADER
,
tccl
);
eraseThreadLocals
();
eraseThreadLocals
();
}
}
...
@@ -79,8 +111,8 @@ public final class InnocuousThread extends Thread {
...
@@ -79,8 +111,8 @@ public final class InnocuousThread extends Thread {
* Drops all thread locals (and inherited thread locals).
* Drops all thread locals (and inherited thread locals).
*/
*/
public
void
eraseThreadLocals
()
{
public
void
eraseThreadLocals
()
{
UNSAFE
.
putObject
(
this
,
THREADLOCALS
,
null
);
UNSAFE
.
putObject
(
this
,
THREAD
_
LOCALS
,
null
);
UNSAFE
.
putObject
(
this
,
INHERITABLE
THREAD
LOCALS
,
null
);
UNSAFE
.
putObject
(
this
,
INHERITABLE
_THREAD_
LOCALS
,
null
);
}
}
// Use Unsafe to access Thread group and ThreadGroup parent fields
// Use Unsafe to access Thread group and ThreadGroup parent fields
...
@@ -95,12 +127,14 @@ public final class InnocuousThread extends Thread {
...
@@ -95,12 +127,14 @@ public final class InnocuousThread extends Thread {
Class
<?>
tk
=
Thread
.
class
;
Class
<?>
tk
=
Thread
.
class
;
Class
<?>
gk
=
ThreadGroup
.
class
;
Class
<?>
gk
=
ThreadGroup
.
class
;
THREADLOCALS
=
UNSAFE
.
objectFieldOffset
THREAD
_
LOCALS
=
UNSAFE
.
objectFieldOffset
(
tk
.
getDeclaredField
(
"threadLocals"
));
(
tk
.
getDeclaredField
(
"threadLocals"
));
INHERITABLE
THREAD
LOCALS
=
UNSAFE
.
objectFieldOffset
INHERITABLE
_THREAD_
LOCALS
=
UNSAFE
.
objectFieldOffset
(
tk
.
getDeclaredField
(
"inheritableThreadLocals"
));
(
tk
.
getDeclaredField
(
"inheritableThreadLocals"
));
INHERITEDACCESSCONTROLCONTEXT
=
UNSAFE
.
objectFieldOffset
INHERITEDACCESSCONTROLCONTEXT
=
UNSAFE
.
objectFieldOffset
(
tk
.
getDeclaredField
(
"inheritedAccessControlContext"
));
(
tk
.
getDeclaredField
(
"inheritedAccessControlContext"
));
CONTEXTCLASSLOADER
=
UNSAFE
.
objectFieldOffset
(
tk
.
getDeclaredField
(
"contextClassLoader"
));
long
tg
=
UNSAFE
.
objectFieldOffset
(
tk
.
getDeclaredField
(
"group"
));
long
tg
=
UNSAFE
.
objectFieldOffset
(
tk
.
getDeclaredField
(
"group"
));
long
gp
=
UNSAFE
.
objectFieldOffset
(
gk
.
getDeclaredField
(
"parent"
));
long
gp
=
UNSAFE
.
objectFieldOffset
(
gk
.
getDeclaredField
(
"parent"
));
...
@@ -113,7 +147,14 @@ public final class InnocuousThread extends Thread {
...
@@ -113,7 +147,14 @@ public final class InnocuousThread extends Thread {
break
;
break
;
group
=
parent
;
group
=
parent
;
}
}
THREADGROUP
=
new
ThreadGroup
(
group
,
"InnocuousThreadGroup"
);
final
ThreadGroup
root
=
group
;
INNOCUOUSTHREADGROUP
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
ThreadGroup
>()
{
@Override
public
ThreadGroup
run
()
{
return
new
ThreadGroup
(
root
,
"InnocuousThreadGroup"
);
}
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
Error
(
e
);
throw
new
Error
(
e
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录