Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a2f1fa8e
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看板
提交
a2f1fa8e
编写于
9月 19, 2012
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7195917: XMLDecoder parsing at close-time should be improved
Reviewed-by: art, ahgross
上级
a39d5f2b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
23 deletion
+48
-23
src/share/classes/com/sun/beans/decoder/DocumentHandler.java
src/share/classes/com/sun/beans/decoder/DocumentHandler.java
+34
-21
src/share/classes/java/beans/XMLDecoder.java
src/share/classes/java/beans/XMLDecoder.java
+14
-2
未找到文件。
src/share/classes/com/sun/beans/decoder/DocumentHandler.java
浏览文件 @
a2f1fa8e
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008,
2012,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -37,6 +37,9 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.security.AccessControlContext
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
javax.xml.parsers.ParserConfigurationException
;
import
javax.xml.parsers.SAXParserFactory
;
...
...
@@ -46,6 +49,8 @@ import org.xml.sax.InputSource;
import
org.xml.sax.SAXException
;
import
org.xml.sax.helpers.DefaultHandler
;
import
sun.misc.SharedSecrets
;
/**
* The main class to parse JavaBeans XML archive.
*
...
...
@@ -56,11 +61,10 @@ import org.xml.sax.helpers.DefaultHandler;
* @see ElementHandler
*/
public
final
class
DocumentHandler
extends
DefaultHandler
{
private
final
Map
<
String
,
Class
<?
extends
ElementHandler
>>
handlers
=
new
HashMap
<
String
,
Class
<?
extends
ElementHandler
>>();
private
final
Map
<
String
,
Object
>
environment
=
new
HashMap
<
String
,
Object
>();
private
final
List
<
Object
>
objects
=
new
ArrayList
<
Object
>();
private
final
AccessControlContext
acc
=
AccessController
.
getContext
();
private
final
Map
<
String
,
Class
<?
extends
ElementHandler
>>
handlers
=
new
HashMap
<>();
private
final
Map
<
String
,
Object
>
environment
=
new
HashMap
<>();
private
final
List
<
Object
>
objects
=
new
ArrayList
<>();
private
Reference
<
ClassLoader
>
loader
;
private
ExceptionListener
listener
;
...
...
@@ -351,23 +355,32 @@ public final class DocumentHandler extends DefaultHandler {
*
* @param input the input source to parse
*/
public
void
parse
(
InputSource
input
)
{
try
{
SAXParserFactory
.
newInstance
().
newSAXParser
().
parse
(
input
,
this
);
public
void
parse
(
final
InputSource
input
)
{
if
((
this
.
acc
==
null
)
&&
(
null
!=
System
.
getSecurityManager
()))
{
throw
new
SecurityException
(
"AccessControlContext is not set"
);
}
catch
(
ParserConfigurationException
exception
)
{
handleException
(
exception
);
}
catch
(
SAXException
wrapper
)
{
Exception
exception
=
wrapper
.
getException
();
if
(
exception
==
null
)
{
exception
=
wrapper
;
AccessControlContext
stack
=
AccessController
.
getContext
();
SharedSecrets
.
getJavaSecurityAccess
().
doIntersectionPrivilege
(
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
try
{
SAXParserFactory
.
newInstance
().
newSAXParser
().
parse
(
input
,
DocumentHandler
.
this
);
}
catch
(
ParserConfigurationException
exception
)
{
handleException
(
exception
);
}
catch
(
SAXException
wrapper
)
{
Exception
exception
=
wrapper
.
getException
();
if
(
exception
==
null
)
{
exception
=
wrapper
;
}
handleException
(
exception
);
}
catch
(
IOException
exception
)
{
handleException
(
exception
);
}
return
null
;
}
handleException
(
exception
);
}
catch
(
IOException
exception
)
{
handleException
(
exception
);
}
},
stack
,
this
.
acc
);
}
/**
...
...
src/share/classes/java/beans/XMLDecoder.java
浏览文件 @
a2f1fa8e
/*
* Copyright (c) 2000, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -29,6 +29,9 @@ import com.sun.beans.decoder.DocumentHandler;
import
java.io.Closeable
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.security.AccessControlContext
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
org.xml.sax.InputSource
;
import
org.xml.sax.helpers.DefaultHandler
;
...
...
@@ -61,6 +64,7 @@ import org.xml.sax.helpers.DefaultHandler;
* @author Philip Milne
*/
public
class
XMLDecoder
implements
AutoCloseable
{
private
final
AccessControlContext
acc
=
AccessController
.
getContext
();
private
final
DocumentHandler
handler
=
new
DocumentHandler
();
private
final
InputSource
input
;
private
Object
owner
;
...
...
@@ -189,7 +193,15 @@ public class XMLDecoder implements AutoCloseable {
return
false
;
}
if
(
this
.
array
==
null
)
{
this
.
handler
.
parse
(
this
.
input
);
if
((
this
.
acc
==
null
)
&&
(
null
!=
System
.
getSecurityManager
()))
{
throw
new
SecurityException
(
"AccessControlContext is not set"
);
}
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
XMLDecoder
.
this
.
handler
.
parse
(
XMLDecoder
.
this
.
input
);
return
null
;
}
},
this
.
acc
);
this
.
array
=
this
.
handler
.
getObjects
();
}
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录