lint router

This commit is contained in:
zzz
2015-10-17 14:38:02 +00:00
parent 4e6ddfcea3
commit 9bddba56a0
8 changed files with 14 additions and 7 deletions

View File

@@ -339,7 +339,7 @@ public class RouterInfo extends DatabaseEntry {
// WARNING this sort algorithm cannot be changed, as it must be consistent
// network-wide. The signature is not checked at readin time, but only
// later, and the hashes are stored in a Set, not a List.
peers = (Collection<Hash>) SortHelper.sortStructures(peers);
peers = SortHelper.sortStructures(peers);
for (Hash peerHash : peers) {
peerHash.writeBytes(out);
}

View File

@@ -31,12 +31,11 @@ class SortHelper {
* WARNING - this sort order must be consistent network-wide, so while the order is arbitrary,
* it cannot be changed.
* Why? Just because it has to be consistent so signing will work.
* How to spec as returning the same type as the param?
* DEPRECATED - Only used by RouterInfo.
*
* @return a new list
*/
public static List<? extends DataStructure> sortStructures(Collection<? extends DataStructure> dataStructures) {
public static <T extends DataStructure> List<T> sortStructures(Collection<T> dataStructures) {
if (dataStructures == null) return Collections.emptyList();
// This used to use Hash.toString(), which is insane, since a change to toString()
@@ -52,7 +51,7 @@ class SortHelper {
//for (DataStructure struct : tm.values()) {
// rv.add(struct);
//}
ArrayList<DataStructure> rv = new ArrayList<DataStructure>(dataStructures);
ArrayList<T> rv = new ArrayList<T>(dataStructures);
sortStructureList(rv);
return rv;
}