Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_nashorn
提交
ae062423
D
dragonwell8_nashorn
项目概览
openanolis
/
dragonwell8_nashorn
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_nashorn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ae062423
编写于
6月 05, 2013
作者:
J
jlaskey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8015911: $EXEC does not handle large outputs
Reviewed-by: sundar, attila Contributed-by: james.laskey@oracle.com
上级
1cd60278
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
23 deletion
+54
-23
src/jdk/nashorn/internal/runtime/ScriptingFunctions.java
src/jdk/nashorn/internal/runtime/ScriptingFunctions.java
+54
-23
未找到文件。
src/jdk/nashorn/internal/runtime/ScriptingFunctions.java
浏览文件 @
ae062423
...
...
@@ -32,9 +32,8 @@ import static jdk.nashorn.internal.lookup.Lookup.MH;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.OutputStream
Writer
;
import
java.lang.invoke.MethodHandle
;
import
java.lang.invoke.MethodHandles
;
import
java.util.Map
;
...
...
@@ -165,36 +164,61 @@ public final class ScriptingFunctions {
// Start the process.
final
Process
process
=
processBuilder
.
start
();
final
IOException
exception
[]
=
new
IOException
[
2
];
// Collect output.
final
StringBuilder
outBuffer
=
new
StringBuilder
();
Thread
outThread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
char
buffer
[]
=
new
char
[
1024
];
try
(
final
InputStreamReader
inputStream
=
new
InputStreamReader
(
process
.
getInputStream
()))
{
for
(
int
length
;
(
length
=
inputStream
.
read
(
buffer
,
0
,
buffer
.
length
))
!=
-
1
;
)
{
outBuffer
.
append
(
buffer
,
0
,
length
);
}
}
catch
(
IOException
ex
)
{
exception
[
0
]
=
ex
;
}
}
},
"$EXEC output"
);
// Collect errors.
final
StringBuilder
errBuffer
=
new
StringBuilder
();
Thread
errThread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
char
buffer
[]
=
new
char
[
1024
];
try
(
final
InputStreamReader
inputStream
=
new
InputStreamReader
(
process
.
getErrorStream
()))
{
for
(
int
length
;
(
length
=
inputStream
.
read
(
buffer
,
0
,
buffer
.
length
))
!=
-
1
;
)
{
outBuffer
.
append
(
buffer
,
0
,
length
);
}
}
catch
(
IOException
ex
)
{
exception
[
1
]
=
ex
;
}
}
},
"$EXEC error"
);
// Start gathering output.
outThread
.
start
();
errThread
.
start
();
// If input is present, pass on to process.
try
(
OutputStream
outputStream
=
process
.
getOutputStream
(
))
{
try
(
OutputStream
Writer
outputStream
=
new
OutputStreamWriter
(
process
.
getOutputStream
()
))
{
if
(
input
!=
UNDEFINED
)
{
outputStream
.
write
(
JSType
.
toString
(
input
).
getBytes
());
String
in
=
JSType
.
toString
(
input
);
outputStream
.
write
(
in
,
0
,
in
.
length
());
}
}
catch
(
IOException
ex
)
{
// Process was not expecting input. May be normal state of affairs.
}
// Wait for the process to complete.
final
int
exit
=
process
.
waitFor
();
outThread
.
join
();
errThread
.
join
();
// Collect output.
String
out
;
try
(
InputStream
inputStream
=
process
.
getInputStream
())
{
final
StringBuilder
outBuffer
=
new
StringBuilder
();
for
(
int
ch
;
(
ch
=
inputStream
.
read
())
!=
-
1
;
)
{
outBuffer
.
append
((
char
)
ch
);
}
out
=
outBuffer
.
toString
();
}
// Collect errors.
String
err
;
try
(
InputStream
errorStream
=
process
.
getErrorStream
())
{
final
StringBuilder
errBuffer
=
new
StringBuilder
();
for
(
int
ch
;
(
ch
=
errorStream
.
read
())
!=
-
1
;
)
{
errBuffer
.
append
((
char
)
ch
);
}
err
=
errBuffer
.
toString
();
}
final
String
out
=
outBuffer
.
toString
();
final
String
err
=
errBuffer
.
toString
();
// Set globals for secondary results.
final
boolean
isStrict
=
global
.
isStrictContext
();
...
...
@@ -202,6 +226,13 @@ public final class ScriptingFunctions {
global
.
set
(
ERR_NAME
,
err
,
isStrict
);
global
.
set
(
EXIT_NAME
,
exit
,
isStrict
);
// Propagate exception if present.
for
(
int
i
=
0
;
i
<
exception
.
length
;
i
++)
{
if
(
exception
[
i
]
!=
null
)
{
throw
exception
[
i
];
}
}
// Return the result from stdout.
return
out
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录