findbugs router, router/client

This commit is contained in:
zzz
2011-01-10 15:46:13 +00:00
parent f68c095222
commit 0c5d88d230
9 changed files with 34 additions and 15 deletions

View File

@ -679,7 +679,7 @@ public class Blocklist {
return;
Job job = new ShitlistJob(peer);
if (number > 0)
job.getTiming().setStartAfter(_context.clock().now() + (number * 30*1000));
job.getTiming().setStartAfter(_context.clock().now() + (30*1000l * number));
_context.jobQueue().addJob(job);
}

View File

@ -208,7 +208,7 @@ public class JobQueue {
* <code>false</code> if the job is finished or doesn't exist in the queue.
*/
public boolean isJobActive(Job job) {
if (_readyJobs.contains(job) | _timedJobs.contains(job))
if (_readyJobs.contains(job) || _timedJobs.contains(job))
return true;
for (JobQueueRunner runner: _queueRunners.values())
if (runner.getCurrentJob() == job)
@ -689,7 +689,7 @@ public class JobQueue {
TreeMap<Long, Job> ordered = new TreeMap();
for (int i = 0; i < timedJobs.size(); i++) {
Job j = timedJobs.get(i);
ordered.put(new Long(j.getTiming().getStartAfter()), j);
ordered.put(Long.valueOf(j.getTiming().getStartAfter()), j);
}
for (Iterator<Job> iter = ordered.values().iterator(); iter.hasNext(); ) {
Job j = iter.next();

View File

@ -90,13 +90,17 @@ public class MultiRouter {
private static Properties getEnv(String filename) {
Properties props = new Properties();
FileInputStream in = null;
try {
props.load(new FileInputStream(filename));
in = new FileInputStream(filename);
props.load(in);
props.setProperty("time.disabled", "true");
return props;
} catch (IOException ioe) {
ioe.printStackTrace();
return null;
} finally {
if (in != null) try { in.close(); } catch (IOException ioe) {}
}
}

View File

@ -89,15 +89,18 @@ public class OutNetMessage {
// only timestamp if we are debugging
synchronized (this) {
locked_initTimestamps();
while (_timestamps.containsKey(eventName)) {
eventName = eventName + '.';
}
_timestamps.put(eventName, new Long(now));
// ???
//while (_timestamps.containsKey(eventName)) {
// eventName = eventName + '.';
//}
_timestamps.put(eventName, Long.valueOf(now));
_timestampOrder.add(eventName);
}
}
return now - _created;
}
/** @deprecated unused */
public Map<String, Long> getTimestamps() {
if (_log.shouldLog(Log.INFO)) {
synchronized (this) {
@ -107,6 +110,8 @@ public class OutNetMessage {
}
return Collections.EMPTY_MAP;
}
/** @deprecated unused */
public Long getTimestamp(String eventName) {
if (_log.shouldLog(Log.INFO)) {
synchronized (this) {
@ -368,7 +373,7 @@ public class OutNetMessage {
@Override
public boolean equals(Object obj) {
if(obj == null) return false;
if(obj.getClass() != OutNetMessage.class) return false;
if(!(obj instanceof OutNetMessage)) return false;
return obj == this; // two OutNetMessages are different even if they contain the same message
}
}

View File

@ -98,7 +98,7 @@ class RouterThrottleImpl implements RouterThrottle {
if (_context.router().getUptime() < 20*60*1000)
return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
long lag = _context.jobQueue().getMaxLag();
//long lag = _context.jobQueue().getMaxLag();
// reject here if lag too high???
RateStat rs = _context.statManager().getRate("transport.sendProcessingTime");

View File

@ -157,9 +157,12 @@ public class StatisticsManager implements Service {
return stats;
}
/*****
private void includeRate(String rateName, Properties stats, long selectedPeriods[]) {
includeRate(rateName, stats, selectedPeriods, false);
}
*****/
/**
* @param fudgeQuantity the data being published in this stat is too sensitive to, uh
* publish, so we're kludge the quantity (allowing the fairly safe
@ -258,7 +261,6 @@ public class StatisticsManager implements Service {
// bah saturation
buf.append("0;0;0;0;");
}
long numPeriods = rate.getLifetimePeriods();
buf.append(num(fudgeQuantity)).append(';');
return buf.toString();
}

View File

@ -433,7 +433,9 @@ class ClientManager {
}
}
/** @deprecated unused */
public void renderStatusHTML(Writer out) throws IOException {
/******
StringBuilder buf = new StringBuilder(8*1024);
buf.append("<u><b>Local destinations</b></u><br>");
@ -479,6 +481,7 @@ class ClientManager {
buf.append("\n<hr>\n");
out.write(buf.toString());
out.flush();
******/
}
public void messageReceived(ClientMessage msg) {

View File

@ -207,6 +207,7 @@ public class ClientManagerFacadeImpl extends ClientManagerFacade implements Inte
}
}
/** @deprecated unused */
@Override
public void renderStatusHTML(Writer out) throws IOException {
if (_manager != null)

View File

@ -142,12 +142,12 @@ class SSLClientListenerRunner extends ClientListenerRunner {
private void exportCert(File ks) {
File sdir = new SecureDirectory(_context.getConfigDir(), "certificates");
if (sdir.exists() || sdir.mkdir()) {
InputStream fis = null;
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream fis = new FileInputStream(ks);
fis = new FileInputStream(ks);
String ksPass = _context.getProperty(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD);
keyStore.load(fis, ksPass.toCharArray());
fis.close();
Certificate cert = keyStore.getCertificate(KEY_ALIAS);
if (cert != null) {
File certFile = new File(sdir, ASCII_KEYFILE);
@ -159,6 +159,8 @@ class SSLClientListenerRunner extends ClientListenerRunner {
_log.error("Error saving ASCII SSL keys", gse);
} catch (IOException ioe) {
_log.error("Error saving ASCII SSL keys", ioe);
} finally {
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
}
} else {
_log.error("Error saving ASCII SSL keys");
@ -208,12 +210,12 @@ class SSLClientListenerRunner extends ClientListenerRunner {
" in " + (new File(_context.getConfigDir(), "router.config")).getAbsolutePath());
return false;
}
InputStream fis = null;
try {
SSLContext sslc = SSLContext.getInstance("TLS");
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream fis = new FileInputStream(ks);
fis = new FileInputStream(ks);
keyStore.load(fis, ksPass.toCharArray());
fis.close();
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, keyPass.toCharArray());
sslc.init(kmf.getKeyManagers(), null, _context.random());
@ -223,6 +225,8 @@ class SSLClientListenerRunner extends ClientListenerRunner {
_log.error("Error loading SSL keys", gse);
} catch (IOException ioe) {
_log.error("Error loading SSL keys", ioe);
} finally {
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
}
return false;
}