Details
-
Bug
-
Resolution: Fixed
-
P2
-
None
-
b102
-
Verified
Description
Consider the following code:
import java.util.StringJoiner;
public class MergeSelf {
public static void main(String[] args) {
final StringJoiner joiner1 = new StringJoiner(",", "[", "]").add("a").add("b");
System.out.println("joiner1.merge(joiner1) = " + joiner1.merge(joiner1));
System.out.println("joiner1.merge(joiner1) = " + joiner1.merge(joiner1));
final StringJoiner joiner2 = new StringJoiner(",").add("c").add("d");
System.out.println("joiner2.merge(joiner2) = " + joiner2.merge(joiner2));
}
}
The output will be:
joiner1.merge(joiner1) = [a,b,a,b,]
joiner1.merge(joiner1) = [a,b,a,b,,a,b,a,b,,]
joiner2.merge(joiner2) = c,d,c,d,
The following JCK tests will fail due to this issue:
api/java_util/StringJoiner/index.html#Merge[selfSimple1]
api/java_util/StringJoiner/index.html#Merge[selfSimple1Delimiter]
api/java_util/StringJoiner/index.html#Merge[selfSimple2]
api/java_util/StringJoiner/index.html#Merge[selfSimple2Delimiter]
api/java_util/StringJoiner/index.html#Merge[selfSimpleTwice1]
api/java_util/StringJoiner/index.html#Merge[selfSimpleTwice1Delimtier]
import java.util.StringJoiner;
public class MergeSelf {
public static void main(String[] args) {
final StringJoiner joiner1 = new StringJoiner(",", "[", "]").add("a").add("b");
System.out.println("joiner1.merge(joiner1) = " + joiner1.merge(joiner1));
System.out.println("joiner1.merge(joiner1) = " + joiner1.merge(joiner1));
final StringJoiner joiner2 = new StringJoiner(",").add("c").add("d");
System.out.println("joiner2.merge(joiner2) = " + joiner2.merge(joiner2));
}
}
The output will be:
joiner1.merge(joiner1) = [a,b,a,b,]
joiner1.merge(joiner1) = [a,b,a,b,,a,b,a,b,,]
joiner2.merge(joiner2) = c,d,c,d,
The following JCK tests will fail due to this issue:
api/java_util/StringJoiner/index.html#Merge[selfSimple1]
api/java_util/StringJoiner/index.html#Merge[selfSimple1Delimiter]
api/java_util/StringJoiner/index.html#Merge[selfSimple2]
api/java_util/StringJoiner/index.html#Merge[selfSimple2Delimiter]
api/java_util/StringJoiner/index.html#Merge[selfSimpleTwice1]
api/java_util/StringJoiner/index.html#Merge[selfSimpleTwice1Delimtier]