findbugs correctness fixes, all over the place

This commit is contained in:
zzz
2013-11-07 19:20:25 +00:00
parent 5cbecb3599
commit ae76a6ee1a
8 changed files with 21 additions and 15 deletions

View File

@@ -197,6 +197,9 @@ public class TunnelPoolSettings {
public Properties getUnknownOptions() { return _unknownOptions; }
/**
* @param prefix non-null
*/
public void readFromProperties(String prefix, Map<Object, Object> props) {
for (Map.Entry e : props.entrySet()) {
String name = (String) e.getKey();
@@ -225,11 +228,14 @@ public class TunnelPoolSettings {
int max = _isExploratory ? EXPLORATORY_PRIORITY : MAX_PRIORITY;
_priority = Math.min(max, Math.max(MIN_PRIORITY, getInt(value, def)));
} else
_unknownOptions.setProperty(name.substring((prefix != null ? prefix.length() : 0)), value);
_unknownOptions.setProperty(name.substring(prefix.length()), value);
}
}
}
}
/**
* @param prefix non-null
*/
public void writeToProperties(String prefix, Properties props) {
if (props == null) return;
props.setProperty(prefix + PROP_ALLOW_ZERO_HOP, ""+_allowZeroHop);

View File

@@ -320,10 +320,12 @@ class BuildExecutor implements Runnable {
// we don't have either inbound or outbound tunnels, so don't bother trying to build
// non-zero-hop tunnels
// try to kickstart it to build a fallback, otherwise we may get stuck here for a long time (minutes)
if (mgr.getFreeTunnelCount() <= 0)
mgr.selectInboundTunnel();
if (mgr.getOutboundTunnelCount() <= 0)
mgr.selectOutboundTunnel();
if (mgr != null) {
if (mgr.getFreeTunnelCount() <= 0)
mgr.selectInboundTunnel();
if (mgr.getOutboundTunnelCount() <= 0)
mgr.selectOutboundTunnel();
}
synchronized (_currentlyBuilding) {
if (!_repoll) {
if (_log.shouldLog(Log.DEBUG))

View File

@@ -261,7 +261,7 @@ public class TunnelPool {
}
}
if (rv != null) {
_context.statManager().addRateData("tunnel.matchLease", closestTo.equals(rv) ? 1 : 0);
_context.statManager().addRateData("tunnel.matchLease", closestTo.equals(rv.getFarEnd()) ? 1 : 0);
} else {
if (_log.shouldLog(Log.WARN))
_log.warn(toString() + ": No tunnels to select from");