Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c5c0273a
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看板
提交
c5c0273a
编写于
7月 30, 2013
作者:
P
psandoz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8021863: Stream.concat incorrectly calculates unsized state
Reviewed-by: chegar
上级
6b6e7b8b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
6 deletion
+97
-6
src/share/classes/java/util/stream/Streams.java
src/share/classes/java/util/stream/Streams.java
+3
-5
test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatOpTest.java
...test/org/openjdk/tests/java/util/stream/ConcatOpTest.java
+94
-1
未找到文件。
src/share/classes/java/util/stream/Streams.java
浏览文件 @
c5c0273a
...
...
@@ -681,11 +681,9 @@ final class Streams {
this
.
aSpliterator
=
aSpliterator
;
this
.
bSpliterator
=
bSpliterator
;
beforeSplit
=
true
;
// The spliterator is unsized before splitting if a and b are
// sized and the sum of the estimates overflows
unsized
=
aSpliterator
.
hasCharacteristics
(
SIZED
)
&&
aSpliterator
.
hasCharacteristics
(
SIZED
)
&&
aSpliterator
.
estimateSize
()
+
bSpliterator
.
estimateSize
()
<
0
;
// The spliterator is known to be unsized before splitting if the
// sum of the estimates overflows.
unsized
=
aSpliterator
.
estimateSize
()
+
bSpliterator
.
estimateSize
()
<
0
;
}
@Override
...
...
test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatOpTest.java
浏览文件 @
c5c0273a
...
...
@@ -22,6 +22,8 @@
*/
package
org.openjdk.tests.java.util.stream
;
import
java.util.Spliterator
;
import
java.util.stream.BaseStream
;
import
java.util.stream.OpTestCase
;
import
java.util.stream.StreamTestDataProvider
;
...
...
@@ -34,16 +36,107 @@ import java.util.stream.DoubleStream;
import
java.util.stream.TestData
;
import
static
java
.
util
.
stream
.
LambdaTestHelpers
.*;
import
static
org
.
testng
.
Assert
.
assertEquals
;
/**
* @test
* @bug 8021863
*/
public
class
ConcatOpTest
extends
OpTestCase
{
// Sanity to make sure all type of stream source works
@Test
(
dataProvider
=
"StreamTestData<Integer>"
,
dataProviderClass
=
StreamTestDataProvider
.
class
)
public
void
testOps
Sequential
(
String
name
,
TestData
.
OfRef
<
Integer
>
data
)
{
public
void
testOps
(
String
name
,
TestData
.
OfRef
<
Integer
>
data
)
{
exerciseOpsInt
(
data
,
s
->
Stream
.
concat
(
s
,
data
.
stream
()),
s
->
IntStream
.
concat
(
s
,
data
.
stream
().
mapToInt
(
Integer:
:
intValue
)),
s
->
LongStream
.
concat
(
s
,
data
.
stream
().
mapToLong
(
Integer:
:
longValue
)),
s
->
DoubleStream
.
concat
(
s
,
data
.
stream
().
mapToDouble
(
Integer:
:
doubleValue
)));
}
public
void
testSize
()
{
assertSized
(
Stream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
/
2
).
boxed
(),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
/
2
).
boxed
()));
assertUnsized
(
Stream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
boxed
(),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
boxed
()));
assertUnsized
(
Stream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
boxed
(),
Stream
.
iterate
(
0
,
i
->
i
+
1
)));
assertUnsized
(
Stream
.
concat
(
Stream
.
iterate
(
0
,
i
->
i
+
1
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
boxed
()));
}
public
void
testLongSize
()
{
assertSized
(
LongStream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
/
2
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
/
2
)));
assertUnsized
(
LongStream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
)));
assertUnsized
(
LongStream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
),
LongStream
.
iterate
(
0
,
i
->
i
+
1
)));
assertUnsized
(
LongStream
.
concat
(
LongStream
.
iterate
(
0
,
i
->
i
+
1
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
)));
}
public
void
testIntSize
()
{
assertSized
(
IntStream
.
concat
(
IntStream
.
range
(
0
,
Integer
.
MAX_VALUE
),
IntStream
.
range
(
0
,
Integer
.
MAX_VALUE
)));
assertUnsized
(
IntStream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToInt
(
i
->
(
int
)
i
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToInt
(
i
->
(
int
)
i
)));
assertUnsized
(
IntStream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToInt
(
i
->
(
int
)
i
),
IntStream
.
iterate
(
0
,
i
->
i
+
1
)));
assertUnsized
(
IntStream
.
concat
(
IntStream
.
iterate
(
0
,
i
->
i
+
1
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToInt
(
i
->
(
int
)
i
)));
}
public
void
testDoubleSize
()
{
assertSized
(
DoubleStream
.
concat
(
IntStream
.
range
(
0
,
Integer
.
MAX_VALUE
).
mapToDouble
(
i
->
i
),
IntStream
.
range
(
0
,
Integer
.
MAX_VALUE
).
mapToDouble
(
i
->
i
)));
assertUnsized
(
DoubleStream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToDouble
(
i
->
i
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToDouble
(
i
->
i
)));
assertUnsized
(
DoubleStream
.
concat
(
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToDouble
(
i
->
i
),
DoubleStream
.
iterate
(
0
,
i
->
i
+
1
)));
assertUnsized
(
DoubleStream
.
concat
(
DoubleStream
.
iterate
(
0
,
i
->
i
+
1
),
LongStream
.
range
(
0
,
Long
.
MAX_VALUE
).
mapToDouble
(
i
->
i
)));
}
void
assertUnsized
(
BaseStream
<?,
?>
s
)
{
Spliterator
<?>
sp
=
s
.
spliterator
();
assertFalse
(
sp
.
hasCharacteristics
(
Spliterator
.
SIZED
|
Spliterator
.
SUBSIZED
));
assertEquals
(
sp
.
estimateSize
(),
Long
.
MAX_VALUE
);
}
void
assertSized
(
BaseStream
<?,
?>
s
)
{
Spliterator
<?>
sp
=
s
.
spliterator
();
assertTrue
(
sp
.
hasCharacteristics
(
Spliterator
.
SIZED
|
Spliterator
.
SUBSIZED
));
assertTrue
(
sp
.
estimateSize
()
<
Long
.
MAX_VALUE
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录