propagate from branch 'i2p.i2p' (head d12a1fd746cd9314de5de5e1000c02cf4c59100d)

to branch 'i2p.i2p.str4d.cleanup' (head e20c143dd50a9c802999068a95e12198b07e4c36)
This commit is contained in:
str4d
2013-11-25 22:36:27 +00:00
64 changed files with 161 additions and 219 deletions

View File

@@ -8,7 +8,7 @@ package net.i2p.router;
*
*/
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import net.i2p.data.Hash;
@@ -49,9 +49,9 @@ public class ClientTunnelSettings {
writeToProperties(p);
buf.append("Client tunnel settings:\n");
buf.append("====================================\n");
for (Iterator iter = p.keySet().iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
String val = p.getProperty(name);
for (Map.Entry<Object, Object> entry : p.entrySet()) {
String name = (String) entry.getKey();
String val = (String) entry.getValue();
buf.append(name).append(" = [").append(val).append("]\n");
}
buf.append("====================================\n");

View File

@@ -277,7 +277,7 @@ public class JobQueue {
if (_maxWaitingJobs <= 0) return false; // dont ever drop jobs
if (!_allowParallelOperation) return false; // dont drop during startup [duh]
if (numReady > _maxWaitingJobs) {
Class cls = job.getClass();
Class<? extends Job> cls = job.getClass();
// lets not try to drop too many tunnel messages...
//if (cls == HandleTunnelMessageJob.class)
// return true;

View File

@@ -3,8 +3,6 @@ package net.i2p.router;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import net.i2p.data.DataFormatException;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
@@ -43,8 +41,7 @@ public class PersistentKeyRing extends KeyRing {
}
private void addFromProperties() {
for (Iterator iter = _ctx.getPropertyNames().iterator(); iter.hasNext(); ) {
String prop = (String) iter.next();
for (String prop : _ctx.getPropertyNames()) {
if (!prop.startsWith(PROP_PFX))
continue;
String key = _ctx.getProperty(prop);

View File

@@ -201,7 +201,7 @@ public class TunnelPoolSettings {
* @param prefix non-null
*/
public void readFromProperties(String prefix, Map<Object, Object> props) {
for (Map.Entry e : props.entrySet()) {
for (Map.Entry<Object, Object> e : props.entrySet()) {
String name = (String) e.getKey();
String value = (String) e.getValue();
if (name.startsWith(prefix)) {
@@ -250,7 +250,7 @@ public class TunnelPoolSettings {
props.setProperty(prefix + PROP_IP_RESTRICTION, ""+_IPRestriction);
if (!_isInbound)
props.setProperty(prefix + PROP_PRIORITY, Integer.toString(_priority));
for (Map.Entry e : _unknownOptions.entrySet()) {
for (Map.Entry<Object, Object> e : _unknownOptions.entrySet()) {
String name = (String) e.getKey();
String val = (String) e.getValue();
props.setProperty(prefix + name, val);
@@ -264,7 +264,7 @@ public class TunnelPoolSettings {
writeToProperties("", p);
buf.append("Tunnel pool settings:\n");
buf.append("====================================\n");
for (Map.Entry e : p.entrySet()) {
for (Map.Entry<Object, Object> e : p.entrySet()) {
String name = (String) e.getKey();
String val = (String) e.getValue();
buf.append(name).append(" = [").append(val).append("]\n");

View File

@@ -197,7 +197,7 @@ public class LoadClientAppsJob extends JobImpl {
log.info("Loading up the client application " + clientName + ": " + className + " " + Arrays.toString(args));
if (args == null)
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.invoke(cls, new Object[] { args });
}
@@ -264,15 +264,15 @@ public class LoadClientAppsJob extends JobImpl {
public void run() {
try {
Class cls = Class.forName(_className, true, _cl);
Class<?> cls = Class.forName(_className, true, _cl);
if (isRouterApp(cls)) {
Constructor con = cls.getConstructor(RouterContext.class, ClientAppManager.class, String[].class);
Constructor<?> con = cls.getConstructor(RouterContext.class, ClientAppManager.class, String[].class);
RouterAppManager mgr = _ctx.clientAppManager();
Object[] conArgs = new Object[] {_ctx, _ctx.clientAppManager(), _args};
RouterApp app = (RouterApp) con.newInstance(conArgs);
mgr.addAndStart(app, _args);
} else if (isClientApp(cls)) {
Constructor con = cls.getConstructor(I2PAppContext.class, ClientAppManager.class, String[].class);
Constructor<?> con = cls.getConstructor(I2PAppContext.class, ClientAppManager.class, String[].class);
RouterAppManager mgr = _ctx.clientAppManager();
Object[] conArgs = new Object[] {_ctx, _ctx.clientAppManager(), _args};
ClientApp app = (ClientApp) con.newInstance(conArgs);
@@ -288,17 +288,17 @@ public class LoadClientAppsJob extends JobImpl {
_log.info("Done running client application " + _appName);
}
private static boolean isRouterApp(Class cls) {
private static boolean isRouterApp(Class<?> cls) {
return isInterface(cls, RouterApp.class);
}
private static boolean isClientApp(Class cls) {
private static boolean isClientApp(Class<?> cls) {
return isInterface(cls, ClientApp.class);
}
private static boolean isInterface(Class cls, Class intfc) {
private static boolean isInterface(Class<?> cls, Class<?> intfc) {
try {
Class[] intfcs = cls.getInterfaces();
Class<?>[] intfcs = cls.getInterfaces();
for (int i = 0; i < intfcs.length; i++) {
if (intfcs[i] == intfc)
return true;

View File

@@ -280,8 +280,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
*/
private void discoverService() {
synchronized (lock) {
for (Iterator iter = _router.getDeviceList().iterator();iter.hasNext();) {
Device current = (Device)iter.next();
for (Device current : _router.getDeviceList()) {
if (!current.getDeviceType().equals(WAN_DEVICE))
continue;

View File

@@ -69,7 +69,7 @@ class NTCPSendFinisher {
public CustomThreadPoolExecutor(int num) {
// use unbounded queue, so maximumPoolSize and keepAliveTime have no effect
super(num, num, 1000, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue(), new CustomThreadFactory());
new LinkedBlockingQueue<Runnable>(), new CustomThreadFactory());
}
}

View File

@@ -24,7 +24,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
super(context);
}
public List<Hash> selectPeers(TunnelPoolSettings settings) {
public List<Hash> selectPeers(TunnelPoolSettings settings) {
Log l = ctx.logManager().getLog(getClass());
int length = getLength(settings);
if (length < 0) {
@@ -34,7 +34,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
}
if (false && shouldSelectExplicit(settings)) {
List rv = selectExplicit(settings, length);
List<Hash> rv = selectExplicit(settings, length);
if (l.shouldLog(Log.DEBUG))
l.debug("Explicit peers selected: " + rv);
return rv;

View File

@@ -6,7 +6,7 @@ import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.TreeSet;
import net.i2p.data.Hash;
@@ -123,7 +123,8 @@ public class TunnelPool {
return; // don't override client specified settings
} else {
if (_settings.isExploratory()) {
Map props = _context.router().getConfigMap();
Properties props = new Properties();
props.putAll(_context.router().getConfigMap());
if (_settings.isInbound())
_settings.readFromProperties(TunnelPoolSettings.PREFIX_INBOUND_EXPLORATORY, props);
else