Skip to content

Commit 239fb23

Browse files
committed
ERS: the comparator SortedIndexedHashList sorts with takes Objects, as ByteArrayComparator beside it does, so it still implements Comparator once the legacy builds have stripped the type parameters.
1 parent 9b6c192 commit 239fb23

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎pkix/src/main/java/org/bouncycastle/tsp/ers/SortedIndexedHashList.java‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ public class SortedIndexedHashList
1313
{
1414
private static final Comparator<byte[]> hashComp = new ByteArrayComparator();
1515

16-
private static final Comparator<IndexedHash> digestComp = new Comparator<IndexedHash>()
17-
{
18-
public int compare(IndexedHash l, IndexedHash r)
19-
{
20-
return hashComp.compare(l.digest, r.digest);
21-
}
22-
};
16+
private static final Comparator<IndexedHash> digestComp = new DigestComparator();
2317

2418
private final List<IndexedHash> baseList = new ArrayList<IndexedHash>();
2519

@@ -75,4 +69,15 @@ public List<IndexedHash> toList()
7569

7670
return sorted;
7771
}
72+
73+
// takes Objects, as ByteArrayComparator does: the legacy builds strip the type parameters
74+
// and a compare() declared on IndexedHash then implements nothing.
75+
private static class DigestComparator
76+
implements Comparator
77+
{
78+
public int compare(Object l, Object r)
79+
{
80+
return hashComp.compare(((IndexedHash)l).digest, ((IndexedHash)r).digest);
81+
}
82+
}
7883
}

0 commit comments

Comments
 (0)