Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2962ea18
提交
2962ea18
authored
11月 11, 2016
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup ExecutorService after test
上级
9fb8b74e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
52 行增加
和
49 行删除
+52
-49
TestMultiThread.java
h2/src/test/org/h2/test/db/TestMultiThread.java
+52
-49
没有找到文件。
h2/src/test/org/h2/test/db/TestMultiThread.java
浏览文件 @
2962ea18
...
@@ -319,58 +319,61 @@ public class TestMultiThread extends TestBase implements Runnable {
...
@@ -319,58 +319,61 @@ public class TestMultiThread extends TestBase implements Runnable {
conn
.
close
();
conn
.
close
();
// create views that reference the common views in different threads
// create views that reference the common views in different threads
final
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
8
);
final
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
8
);
final
ArrayList
<
Future
<
Void
>>
jobs
=
new
ArrayList
<
Future
<
Void
>>();
try
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
final
ArrayList
<
Future
<
Void
>>
jobs
=
new
ArrayList
<
Future
<
Void
>>();
final
int
j
=
i
;
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
jobs
.
add
(
executor
.
submit
(
new
Callable
<
Void
>()
{
final
int
j
=
i
;
@Override
jobs
.
add
(
executor
.
submit
(
new
Callable
<
Void
>()
{
public
Void
call
()
throws
Exception
{
@Override
final
Connection
conn2
=
getConnection
(
url
);
public
Void
call
()
throws
Exception
{
Statement
stat2
=
conn2
.
createStatement
();
final
Connection
conn2
=
getConnection
(
url
);
Statement
stat2
=
conn2
.
createStatement
();
stat2
.
execute
(
"CREATE VIEW INVOICE_VIEW"
+
j
+
" as SELECT * FROM INVOICE_VIEW"
);
stat2
.
execute
(
"CREATE VIEW INVOICE_VIEW"
+
j
+
" as SELECT * FROM INVOICE_VIEW"
);
// the following query intermittently results in a
// NullPointerException
// the following query intermittently results in a
stat2
.
execute
(
"CREATE VIEW INVOICE_DETAIL_VIEW"
+
j
// NullPointerException
+
" as SELECT DTL.* FROM INVOICE_VIEW"
+
j
stat2
.
execute
(
"CREATE VIEW INVOICE_DETAIL_VIEW"
+
j
+
" INV JOIN INVOICE_DETAIL_VIEW DTL "
+
" as SELECT DTL.* FROM INVOICE_VIEW"
+
j
+
"ON INV.INVOICE_ID = DTL.INVOICE_ID"
+
" INV JOIN INVOICE_DETAIL_VIEW DTL "
+
" WHERE DESCRIPTION='TEST'"
);
+
"ON INV.INVOICE_ID = DTL.INVOICE_ID"
+
" WHERE DESCRIPTION='TEST'"
);
ResultSet
rs
=
stat2
.
executeQuery
(
"SELECT * FROM INVOICE_VIEW"
+
j
);
ResultSet
rs
=
stat2
rs
.
next
();
.
executeQuery
(
"SELECT * FROM INVOICE_VIEW"
+
j
);
rs
.
close
();
rs
.
next
();
rs
.
close
();
rs
=
stat2
.
executeQuery
(
"SELECT * FROM INVOICE_DETAIL_VIEW"
+
j
);
rs
=
stat2
.
executeQuery
(
rs
.
next
();
"SELECT * FROM INVOICE_DETAIL_VIEW"
+
j
);
rs
.
close
();
rs
.
next
();
rs
.
close
();
stat
.
close
();
conn
.
close
();
stat
.
close
();
return
null
;
conn
.
close
();
}
return
null
;
}));
}
}
}));
// check for exceptions
}
for
(
Future
<
Void
>
job
:
jobs
)
{
// check for exceptions
try
{
for
(
Future
<
Void
>
job
:
jobs
)
{
job
.
get
();
try
{
}
catch
(
ExecutionException
ex
)
{
job
.
get
();
// ignore timeout exceptions, happens periodically when the machine is really
}
catch
(
ExecutionException
ex
)
{
// busy and it's not the thing we are trying to test
// ignore timeout exceptions, happens periodically when the machine is really
if
(!(
ex
.
getCause
()
instanceof
JdbcSQLException
)
// busy and it's not the thing we are trying to test
||
((
JdbcSQLException
)
ex
.
getCause
())
if
(!(
ex
.
getCause
()
instanceof
JdbcSQLException
)
.
getErrorCode
()
!=
ErrorCode
.
LOCK_TIMEOUT_1
)
{
||
((
JdbcSQLException
)
ex
.
getCause
())
throw
ex
;
.
getErrorCode
()
!=
ErrorCode
.
LOCK_TIMEOUT_1
)
{
throw
ex
;
}
}
}
}
}
}
finally
{
executor
.
shutdown
();
executor
.
awaitTermination
(
20
,
TimeUnit
.
SECONDS
);
}
}
executor
.
shutdown
();
executor
.
awaitTermination
(
20
,
TimeUnit
.
SECONDS
);
deleteDb
(
"lockMode"
);
deleteDb
(
"lockMode"
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论