Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d61a0a4b
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看板
提交
d61a0a4b
编写于
4月 14, 2013
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8011799: CompletableFuture/Basic.java fails intermittently
Reviewed-by: martin, alanb
上级
72e038be
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
28 addition
and
28 deletion
+28
-28
test/java/util/concurrent/CompletableFuture/Basic.java
test/java/util/concurrent/CompletableFuture/Basic.java
+28
-28
未找到文件。
test/java/util/concurrent/CompletableFuture/Basic.java
浏览文件 @
d61a0a4b
...
...
@@ -486,40 +486,40 @@ public class Basic {
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEither
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEither
(
cf2
,
(
x
)
->
{
check
(
x
==
2
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
1
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
1
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
fail
();
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedExceptionally
(
cf3
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
...
...
@@ -531,45 +531,45 @@ public class Basic {
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
acceptEither
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
acceptEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
2
);
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
1
);
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
fail
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedExceptionally
(
cf3
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
...
...
@@ -581,50 +581,50 @@ public class Basic {
CompletableFuture
<
Void
>
cf1
=
runAsync
(()
->
{
});
CompletableFuture
<
Void
>
cf2
=
runAsync
(()
->
{
});
cf3
=
cf1
.
runAfterEither
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
});
cf3
=
cf1
.
runAfterEitherAsync
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
});
cf3
=
cf2
.
runAfterEitherAsync
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
runAsync
(()
->
{
});
cf3
=
cf2
.
runAfterEither
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf1
.
runAfterEitherAsync
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf2
.
runAfterEitherAsync
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedExceptionally
(
cf3
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
before
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
...
...
@@ -670,16 +670,16 @@ public class Basic {
//----------------------------------------------------------------
// anyOf tests
//----------------------------------------------------------------
//
try {
//
CompletableFuture<Object> cf3;
//
for (int k=0; k < 10; k++){
//
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
//
CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
//
cf3 = CompletableFuture.anyOf(cf1, cf2);
// check(cf1.isDone() || cf2.isDone()
);
// checkCompletedNormally(cf3, new Object[] {1, 2}
);
//
}
//
} catch (Throwable t) { unexpected(t); }
try
{
CompletableFuture
<
Object
>
cf3
;
for
(
int
k
=
0
;
k
<
10
;
k
++){
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
cf3
=
CompletableFuture
.
anyOf
(
cf1
,
cf2
);
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
}
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
()
);
}
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
// allOf tests
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录