forked from I2P_Developers/i2p.i2p
lint router
This commit is contained in:
@ -339,7 +339,7 @@ public class RouterInfo extends DatabaseEntry {
|
|||||||
// WARNING this sort algorithm cannot be changed, as it must be consistent
|
// WARNING this sort algorithm cannot be changed, as it must be consistent
|
||||||
// network-wide. The signature is not checked at readin time, but only
|
// network-wide. The signature is not checked at readin time, but only
|
||||||
// later, and the hashes are stored in a Set, not a List.
|
// 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) {
|
for (Hash peerHash : peers) {
|
||||||
peerHash.writeBytes(out);
|
peerHash.writeBytes(out);
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,11 @@ class SortHelper {
|
|||||||
* WARNING - this sort order must be consistent network-wide, so while the order is arbitrary,
|
* WARNING - this sort order must be consistent network-wide, so while the order is arbitrary,
|
||||||
* it cannot be changed.
|
* it cannot be changed.
|
||||||
* Why? Just because it has to be consistent so signing will work.
|
* 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.
|
* DEPRECATED - Only used by RouterInfo.
|
||||||
*
|
*
|
||||||
* @return a new list
|
* @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();
|
if (dataStructures == null) return Collections.emptyList();
|
||||||
|
|
||||||
// This used to use Hash.toString(), which is insane, since a change to toString()
|
// 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()) {
|
//for (DataStructure struct : tm.values()) {
|
||||||
// rv.add(struct);
|
// rv.add(struct);
|
||||||
//}
|
//}
|
||||||
ArrayList<DataStructure> rv = new ArrayList<DataStructure>(dataStructures);
|
ArrayList<T> rv = new ArrayList<T>(dataStructures);
|
||||||
sortStructureList(rv);
|
sortStructureList(rv);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public abstract class CommSystemFacade implements Service {
|
|||||||
public boolean haveInboundCapacity(int pct) { return true; }
|
public boolean haveInboundCapacity(int pct) { return true; }
|
||||||
public boolean haveOutboundCapacity(int pct) { return true; }
|
public boolean haveOutboundCapacity(int pct) { return true; }
|
||||||
public boolean haveHighOutboundCapacity() { 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.
|
* Median clock skew of connected peers in seconds, or null if we cannot answer.
|
||||||
|
@ -611,6 +611,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
* This is synchronized with saveConfig().
|
* This is synchronized with saveConfig().
|
||||||
* Not for external use.
|
* Not for external use.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public void readConfig() {
|
public void readConfig() {
|
||||||
synchronized(_configFileLock) {
|
synchronized(_configFileLock) {
|
||||||
String f = getConfigFilename();
|
String f = getConfigFilename();
|
||||||
@ -1391,6 +1392,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
* @return success
|
* @return success
|
||||||
* @since 0.8.13
|
* @since 0.8.13
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public boolean saveConfig(Map toAdd, Collection<String> toRemove) {
|
public boolean saveConfig(Map toAdd, Collection<String> toRemove) {
|
||||||
synchronized(_configFileLock) {
|
synchronized(_configFileLock) {
|
||||||
if (toAdd != null)
|
if (toAdd != null)
|
||||||
|
@ -207,7 +207,7 @@ public class LoadClientAppsJob extends JobImpl {
|
|||||||
if (args == null)
|
if (args == null)
|
||||||
args = new String[0];
|
args = new String[0];
|
||||||
Class<?> cls = Class.forName(className, true, cl);
|
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 });
|
method.invoke(cls, new Object[] { args });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ public class LoadClientAppsJob extends JobImpl {
|
|||||||
ClientApp app = (ClientApp) con.newInstance(conArgs);
|
ClientApp app = (ClientApp) con.newInstance(conArgs);
|
||||||
mgr.addAndStart(app, _args);
|
mgr.addAndStart(app, _args);
|
||||||
} else {
|
} else {
|
||||||
Method method = cls.getMethod("main", new Class[] { String[].class });
|
Method method = cls.getMethod("main", String[].class);
|
||||||
method.invoke(cls, new Object[] { _args });
|
method.invoke(cls, new Object[] { _args });
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -96,6 +96,7 @@ public class OutboundMessageRegistry {
|
|||||||
* @return non-null List of OutNetMessage describing messages that were waiting for
|
* @return non-null List of OutNetMessage describing messages that were waiting for
|
||||||
* the payload
|
* the payload
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public List<OutNetMessage> getOriginalMessages(I2NPMessage message) {
|
public List<OutNetMessage> getOriginalMessages(I2NPMessage message) {
|
||||||
List<MessageSelector> matchedSelectors = null;
|
List<MessageSelector> matchedSelectors = null;
|
||||||
List<MessageSelector> removedSelectors = null;
|
List<MessageSelector> removedSelectors = null;
|
||||||
@ -193,6 +194,7 @@ public class OutboundMessageRegistry {
|
|||||||
/**
|
/**
|
||||||
* @param allowEmpty is msg.getMessage() allowed to be null?
|
* @param allowEmpty is msg.getMessage() allowed to be null?
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void registerPending(OutNetMessage msg, boolean allowEmpty) {
|
private void registerPending(OutNetMessage msg, boolean allowEmpty) {
|
||||||
if ( (!allowEmpty) && (msg.getMessage() == null) )
|
if ( (!allowEmpty) && (msg.getMessage() == null) )
|
||||||
throw new IllegalArgumentException("OutNetMessage doesn't contain an I2NPMessage? Impossible?");
|
throw new IllegalArgumentException("OutNetMessage doesn't contain an I2NPMessage? Impossible?");
|
||||||
@ -229,6 +231,7 @@ public class OutboundMessageRegistry {
|
|||||||
/**
|
/**
|
||||||
* @param msg may be be null
|
* @param msg may be be null
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void unregisterPending(OutNetMessage msg) {
|
public void unregisterPending(OutNetMessage msg) {
|
||||||
if (msg == null) return;
|
if (msg == null) return;
|
||||||
MessageSelector sel = msg.getReplySelector();
|
MessageSelector sel = msg.getReplySelector();
|
||||||
@ -262,6 +265,7 @@ public class OutboundMessageRegistry {
|
|||||||
_nextExpire = -1;
|
_nextExpire = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
List<MessageSelector> removing = new ArrayList<MessageSelector>(8);
|
List<MessageSelector> removing = new ArrayList<MessageSelector>(8);
|
||||||
|
@ -57,6 +57,7 @@ class TimedWeightedPriorityMessageQueue implements MessageQueue, OutboundMessage
|
|||||||
* specifically, this means how many messages in this queue
|
* specifically, this means how many messages in this queue
|
||||||
* should be pulled off in a row before moving on to the next.
|
* 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) {
|
public TimedWeightedPriorityMessageQueue(RouterContext ctx, int[] priorityLimits, int[] weighting, FailedListener lsnr) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
_log = ctx.logManager().getLog(TimedWeightedPriorityMessageQueue.class);
|
_log = ctx.logManager().getLog(TimedWeightedPriorityMessageQueue.class);
|
||||||
|
@ -58,6 +58,7 @@ class PumpedTunnelGateway extends TunnelGateway {
|
|||||||
* @param receiver this receives the encrypted message and forwards it off
|
* @param receiver this receives the encrypted message and forwards it off
|
||||||
* to the first hop
|
* to the first hop
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public PumpedTunnelGateway(RouterContext context, QueuePreprocessor preprocessor,
|
public PumpedTunnelGateway(RouterContext context, QueuePreprocessor preprocessor,
|
||||||
Sender sender, Receiver receiver, TunnelGatewayPumper pumper) {
|
Sender sender, Receiver receiver, TunnelGatewayPumper pumper) {
|
||||||
super(context, preprocessor, sender, receiver);
|
super(context, preprocessor, sender, receiver);
|
||||||
|
Reference in New Issue
Block a user