-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
8, 11, 17, 18, 19
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The order in which the elements of the Set type field of Subject are obtained should be the same as the order in which they were added.
When XXXCredentials adds elements, the set type is SecureSet, and the bottom layer is LinkedList, which can ensure order.
But getXXXCredentials(Class) returns ClassSet, the bottom layer is HashSet, the order of elements in the set collection will depend on the hash value of the elements
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Subject subject=new Subject();
subject.getPrivateCredentials().add("alice");
subject.getPublicCredentials().add("alice 1");
subject.getPrivateCredentials().add("tom");
subject.getPublicCredentials().add("tom 1");
System.out.println(subject.getPrivateCredentials(String.class).iterator().next());
System.out.println(subject.getPublicCredentials(String.class).iterator().next());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
alice
alice 1
ACTUAL -
tom
tom 1
---------- BEGIN SOURCE ----------
Subject subject=new Subject();
subject.getPrivateCredentials().add("alice");
subject.getPublicCredentials().add("alice 1");
subject.getPrivateCredentials().add("tom");
subject.getPublicCredentials().add("tom 1");
System.out.println(subject.getPrivateCredentials(String.class).iterator().next());
System.out.println(subject.getPublicCredentials(String.class).iterator().next());
---------- END SOURCE ----------
The order in which the elements of the Set type field of Subject are obtained should be the same as the order in which they were added.
When XXXCredentials adds elements, the set type is SecureSet, and the bottom layer is LinkedList, which can ensure order.
But getXXXCredentials(Class) returns ClassSet, the bottom layer is HashSet, the order of elements in the set collection will depend on the hash value of the elements
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Subject subject=new Subject();
subject.getPrivateCredentials().add("alice");
subject.getPublicCredentials().add("alice 1");
subject.getPrivateCredentials().add("tom");
subject.getPublicCredentials().add("tom 1");
System.out.println(subject.getPrivateCredentials(String.class).iterator().next());
System.out.println(subject.getPublicCredentials(String.class).iterator().next());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
alice
alice 1
ACTUAL -
tom
tom 1
---------- BEGIN SOURCE ----------
Subject subject=new Subject();
subject.getPrivateCredentials().add("alice");
subject.getPublicCredentials().add("alice 1");
subject.getPrivateCredentials().add("tom");
subject.getPublicCredentials().add("tom 1");
System.out.println(subject.getPrivateCredentials(String.class).iterator().next());
System.out.println(subject.getPublicCredentials(String.class).iterator().next());
---------- END SOURCE ----------