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;
}

View File

@ -48,7 +48,7 @@ public abstract class CommSystemFacade implements Service {
public boolean haveInboundCapacity(int pct) { return true; }
public boolean haveOutboundCapacity(int pct) { return true; }
public boolean haveHighOutboundCapacity() { return true; }
public List getMostRecentErrorMessages() { return Collections.emptyList(); }
public List<String> getMostRecentErrorMessages() { return Collections.emptyList(); }
/**
* Median clock skew of connected peers in seconds, or null if we cannot answer.

View File

@ -611,6 +611,7 @@ public class Router implements RouterClock.ClockShiftListener {
* This is synchronized with saveConfig().
* Not for external use.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void readConfig() {
synchronized(_configFileLock) {
String f = getConfigFilename();
@ -1391,6 +1392,7 @@ public class Router implements RouterClock.ClockShiftListener {
* @return success
* @since 0.8.13
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public boolean saveConfig(Map toAdd, Collection<String> toRemove) {
synchronized(_configFileLock) {
if (toAdd != null)

View File

@ -207,7 +207,7 @@ public class LoadClientAppsJob extends JobImpl {
if (args == null)
args = new String[0];
Class<?> cls = Class.forName(className, true, cl);
Method method = cls.getMethod("main", new Class[] { String[].class });
Method method = cls.getMethod("main", String[].class);
method.invoke(cls, new Object[] { args });
}
@ -287,7 +287,7 @@ public class LoadClientAppsJob extends JobImpl {
ClientApp app = (ClientApp) con.newInstance(conArgs);
mgr.addAndStart(app, _args);
} else {
Method method = cls.getMethod("main", new Class[] { String[].class });
Method method = cls.getMethod("main", String[].class);
method.invoke(cls, new Object[] { _args });
}
} catch (Throwable t) {

View File

@ -96,6 +96,7 @@ public class OutboundMessageRegistry {
* @return non-null List of OutNetMessage describing messages that were waiting for
* the payload
*/
@SuppressWarnings("unchecked")
public List<OutNetMessage> getOriginalMessages(I2NPMessage message) {
List<MessageSelector> matchedSelectors = null;
List<MessageSelector> removedSelectors = null;
@ -193,6 +194,7 @@ public class OutboundMessageRegistry {
/**
* @param allowEmpty is msg.getMessage() allowed to be null?
*/
@SuppressWarnings("unchecked")
private void registerPending(OutNetMessage msg, boolean allowEmpty) {
if ( (!allowEmpty) && (msg.getMessage() == null) )
throw new IllegalArgumentException("OutNetMessage doesn't contain an I2NPMessage? Impossible?");
@ -229,6 +231,7 @@ public class OutboundMessageRegistry {
/**
* @param msg may be be null
*/
@SuppressWarnings("unchecked")
public void unregisterPending(OutNetMessage msg) {
if (msg == null) return;
MessageSelector sel = msg.getReplySelector();
@ -262,6 +265,7 @@ public class OutboundMessageRegistry {
_nextExpire = -1;
}
@SuppressWarnings("unchecked")
public void timeReached() {
long now = _context.clock().now();
List<MessageSelector> removing = new ArrayList<MessageSelector>(8);

View File

@ -57,6 +57,7 @@ class TimedWeightedPriorityMessageQueue implements MessageQueue, OutboundMessage
* specifically, this means how many messages in this queue
* should be pulled off in a row before moving on to the next.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public TimedWeightedPriorityMessageQueue(RouterContext ctx, int[] priorityLimits, int[] weighting, FailedListener lsnr) {
_context = ctx;
_log = ctx.logManager().getLog(TimedWeightedPriorityMessageQueue.class);

View File

@ -58,6 +58,7 @@ class PumpedTunnelGateway extends TunnelGateway {
* @param receiver this receives the encrypted message and forwards it off
* to the first hop
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public PumpedTunnelGateway(RouterContext context, QueuePreprocessor preprocessor,
Sender sender, Receiver receiver, TunnelGatewayPumper pumper) {
super(context, preprocessor, sender, receiver);