diff --git a/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java b/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java index 1470bd50252639493fcdd92812eaff276f557364..4f7682dc91aa81aaeddd39288542ab5146ebb2f8 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/MessageOutputStream.java @@ -389,7 +389,8 @@ class MessageOutputStream extends OutputStream { // should we? To be researched further. // false -> wait for completion, not just accept. flush(false); - _log.debug("Output stream closed after writing " + _written); + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Output stream closed after writing " + _written); ByteArray ba = null; synchronized (_dataLock) { if (_buf != null) { diff --git a/core/java/src/net/i2p/util/SimpleScheduler.java b/core/java/src/net/i2p/util/SimpleScheduler.java index e1d78b6dbf45021dd4c02925318b043dca22c839..f0cade14c0c8ef7a2a75b6167f04ad5f893ad6b1 100644 --- a/core/java/src/net/i2p/util/SimpleScheduler.java +++ b/core/java/src/net/i2p/util/SimpleScheduler.java @@ -174,9 +174,13 @@ public class SimpleScheduler { long time = System.currentTimeMillis() - before; if (time > 1000 && _log.shouldLog(Log.WARN)) _log.warn(_name + " wtf, event execution took " + time + ": " + _timedEvent); - long completed = _executor.getCompletedTaskCount(); - if (_log.shouldLog(Log.INFO) && completed % 250 == 0) - _log.info(debug()); + if (_log.shouldLog(Log.INFO)) { + // this call is slow - iterates through a HashMap - + // would be better to have a local AtomicLong if we care + long completed = _executor.getCompletedTaskCount(); + if (completed % 250 == 0) + _log.info(debug()); + } } } diff --git a/core/java/src/net/i2p/util/SimpleTimer2.java b/core/java/src/net/i2p/util/SimpleTimer2.java index c36d6032452df26d403fc6569083636ac0ca84e4..ab8cf052693746a2b2836f5db8119c9560670920 100644 --- a/core/java/src/net/i2p/util/SimpleTimer2.java +++ b/core/java/src/net/i2p/util/SimpleTimer2.java @@ -368,9 +368,13 @@ public class SimpleTimer2 { long time = System.currentTimeMillis() - before; if (time > 500 && _log.shouldLog(Log.WARN)) _log.warn(_pool + " wtf, event execution took " + time + ": " + this); - long completed = _pool.getCompletedTaskCount(); - if (_log.shouldLog(Log.INFO) && completed % 250 == 0) - _log.info(_pool.debug()); + if (_log.shouldLog(Log.INFO)) { + // this call is slow - iterates through a HashMap - + // would be better to have a local AtomicLong if we care + long completed = _pool.getCompletedTaskCount(); + if (completed % 250 == 0) + _log.info(_pool.debug()); + } } /** @@ -387,6 +391,7 @@ public class SimpleTimer2 { return _name; } + /** warning - slow */ private long getCompletedTaskCount() { return _executor.getCompletedTaskCount(); } diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java index 2eeb096b6b66d7bfb4e163651e821f9137c9b2a1..dc44e1345f78992b368dbfc7f8e7d3e7ef481bb2 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java @@ -449,7 +449,8 @@ class PersistentDataStore extends TransientDataStore { // so add it here. getContext().profileManager().heardAbout(ri.getIdentity().getHash(), ri.getPublished()); } catch (IllegalArgumentException iae) { - _log.info("Refused locally loaded routerInfo - deleting", iae); + if (_log.shouldLog(Log.INFO)) + _log.info("Refused locally loaded routerInfo - deleting", iae); corrupt = true; } } @@ -524,10 +525,12 @@ class PersistentDataStore extends TransientDataStore { File f = new File(dir, riName); if (f.exists()) { boolean removed = f.delete(); - if (!removed) - _log.warn("Unable to remove router info at " + f.getAbsolutePath()); - else + if (!removed) { + if (_log.shouldLog(Log.WARN)) + _log.warn("Unable to remove router info at " + f.getAbsolutePath()); + } else if (_log.shouldLog(Log.INFO)) { _log.info("Removed router info at " + f.getAbsolutePath()); + } return; } }