From d10dc1e8d3a382e32ff2e1e16ac468a74f81fff6 Mon Sep 17 00:00:00 2001 From: shendaras <shendaras> Date: Sat, 31 Jul 2004 01:04:34 +0000 Subject: [PATCH] Doing something different this time -- but only to core I marked all the empty statements with //nop I removed unneccessary elses (ie, the if returns or throws) I took out some casts (integral promotions/some didn't need to be there) -- Love, shendaras (2 in one day, w00t) --- core/java/src/net/i2p/client/ATalk.java | 6 +- .../src/net/i2p/client/ConnectionRunner.java | 2 +- .../src/net/i2p/client/I2PSessionImpl.java | 12 +-- .../src/net/i2p/client/I2PSessionImpl2.java | 10 +- .../java/src/net/i2p/client/MessageState.java | 12 +-- core/java/src/net/i2p/client/TestClient.java | 8 +- core/java/src/net/i2p/client/TestServer.java | 2 +- .../client/datagram/I2PDatagramDissector.java | 3 +- .../client/naming/HostsTxtNamingService.java | 2 +- .../net/i2p/client/naming/NamingService.java | 3 +- .../src/net/i2p/crypto/AESInputStream.java | 41 ++++--- .../i2p/crypto/CryptixRijndael_Algorithm.java | 13 ++- .../net/i2p/crypto/DHSessionKeyBuilder.java | 8 +- core/java/src/net/i2p/crypto/DSAEngine.java | 2 +- .../net/i2p/crypto/DummyElGamalEngine.java | 9 +- .../src/net/i2p/crypto/ElGamalAESEngine.java | 28 ++--- .../src/net/i2p/crypto/ElGamalEngine.java | 17 +-- .../net/i2p/crypto/HMACSHA256Generator.java | 4 +- .../java/src/net/i2p/crypto/KeyGenerator.java | 2 +- .../crypto/PersistentSessionKeyManager.java | 2 +- .../src/net/i2p/crypto/SHA256Generator.java | 6 +- .../src/net/i2p/crypto/SessionKeyManager.java | 17 +-- .../crypto/TransientSessionKeyManager.java | 28 +++-- core/java/src/net/i2p/crypto/YKGenerator.java | 8 +- core/java/src/net/i2p/data/Base64.java | 2 +- core/java/src/net/i2p/data/ByteArray.java | 14 +-- core/java/src/net/i2p/data/Certificate.java | 4 +- core/java/src/net/i2p/data/DataHelper.java | 37 +++---- .../src/net/i2p/data/DataStructureImpl.java | 4 +- core/java/src/net/i2p/data/Hash.java | 2 +- core/java/src/net/i2p/data/LeaseSet.java | 6 +- core/java/src/net/i2p/data/RouterInfo.java | 11 +- .../src/net/i2p/data/RoutingKeyGenerator.java | 2 +- .../src/net/i2p/data/UnsignedInteger.java | 9 +- .../i2p/data/i2cp/CreateLeaseSetMessage.java | 4 +- .../i2p/data/i2cp/CreateSessionMessage.java | 4 +- .../i2p/data/i2cp/DestroySessionMessage.java | 4 +- .../net/i2p/data/i2cp/DisconnectMessage.java | 4 +- .../src/net/i2p/data/i2cp/GetDateMessage.java | 4 +- .../net/i2p/data/i2cp/I2CPMessageImpl.java | 2 +- .../net/i2p/data/i2cp/I2CPMessageReader.java | 2 +- .../i2p/data/i2cp/MessagePayloadMessage.java | 4 +- .../i2p/data/i2cp/MessageStatusMessage.java | 4 +- .../data/i2cp/ReceiveMessageBeginMessage.java | 4 +- .../data/i2cp/ReceiveMessageEndMessage.java | 4 +- .../net/i2p/data/i2cp/ReportAbuseMessage.java | 4 +- .../i2p/data/i2cp/RequestLeaseSetMessage.java | 4 +- .../net/i2p/data/i2cp/SendMessageMessage.java | 4 +- .../src/net/i2p/data/i2cp/SessionConfig.java | 4 +- .../i2p/data/i2cp/SessionStatusMessage.java | 4 +- .../src/net/i2p/data/i2cp/SetDateMessage.java | 4 +- core/java/src/net/i2p/stat/Frequency.java | 28 +++-- core/java/src/net/i2p/stat/Rate.java | 102 +++++++++--------- core/java/src/net/i2p/stat/RateStat.java | 10 +- .../src/net/i2p/util/EventDispatcherImpl.java | 2 +- core/java/src/net/i2p/util/HTTPSendData.java | 2 +- core/java/src/net/i2p/util/HexDump.java | 2 +- core/java/src/net/i2p/util/I2PThread.java | 2 +- core/java/src/net/i2p/util/Log.java | 11 +- core/java/src/net/i2p/util/LogManager.java | 17 +-- .../src/net/i2p/util/LogRecordFormatter.java | 14 +-- core/java/src/net/i2p/util/LogWriter.java | 31 +++--- .../src/net/i2p/util/NativeBigInteger.java | 19 ++-- .../src/net/i2p/util/OrderedProperties.java | 21 ++-- 64 files changed, 327 insertions(+), 334 deletions(-) diff --git a/core/java/src/net/i2p/client/ATalk.java b/core/java/src/net/i2p/client/ATalk.java index 303f94e7aa..a517e995c1 100644 --- a/core/java/src/net/i2p/client/ATalk.java +++ b/core/java/src/net/i2p/client/ATalk.java @@ -187,7 +187,7 @@ public class ATalk implements I2PSessionListener, Runnable { } try { Thread.sleep(5000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop! } } } @@ -302,7 +302,7 @@ public class ATalk implements I2PSessionListener, Runnable { _log.debug("Keys generation failed"); try { Thread.sleep(5000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } else if (args.length == 3) { _log.debug("Starting chat"); @@ -320,7 +320,7 @@ public class ATalk implements I2PSessionListener, Runnable { System.out.println(MANUAL); try { Thread.sleep(5000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } System.exit(-1); } diff --git a/core/java/src/net/i2p/client/ConnectionRunner.java b/core/java/src/net/i2p/client/ConnectionRunner.java index 815c9eab99..a3548f0c88 100644 --- a/core/java/src/net/i2p/client/ConnectionRunner.java +++ b/core/java/src/net/i2p/client/ConnectionRunner.java @@ -223,7 +223,7 @@ class ConnectionRunner implements I2CPMessageReader.I2CPMessageEventListener { } - protected void sessionCreated() { + protected void sessionCreated() { // nop } protected SessionConfig getConfig() { diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java index 84248a6d22..6b6052b54a 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl.java @@ -252,7 +252,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa synchronized (_dateReceivedLock) { _dateReceivedLock.wait(1000); } - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After received a SetDate response"); @@ -266,7 +266,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa synchronized (_leaseSetWait) { try { _leaseSetWait.wait(1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } @@ -375,7 +375,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa if (_pendingIds.size() <= 0) { try { AvailabilityNotifier.this.wait(); - } catch (InterruptedException ie) {} + } catch (InterruptedException ie) { // nop + } } if (_pendingIds.size() > 0) { msgId = (Integer)_pendingIds.remove(0); @@ -480,7 +481,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Message written out and flushed w/ " + (inSync-beforeSync) + "ms to sync and " - + (afterSync-inSync) + "ms to send");; + + (afterSync-inSync) + "ms to send"); } /** @@ -551,9 +552,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa if (reconnect()) { if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "I2CP reconnection successful"); return; - } else { - if (_log.shouldLog(Log.ERROR)) _log.error(getPrefix() + "I2CP reconnection failed"); } + if (_log.shouldLog(Log.ERROR)) _log.error(getPrefix() + "I2CP reconnection failed"); } if (_log.shouldLog(Log.ERROR)) diff --git a/core/java/src/net/i2p/client/I2PSessionImpl2.java b/core/java/src/net/i2p/client/I2PSessionImpl2.java index 2e797d2e97..18f6119727 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl2.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl2.java @@ -76,9 +76,8 @@ class I2PSessionImpl2 extends I2PSessionImpl { // as well as the nonblocking sends with application managed keys. Later. if (isGuaranteed() || true) { return sendGuaranteed(dest, payload, keyUsed, tagsSent); - } else { - return sendBestEffort(dest, payload, keyUsed, tagsSent); } + return sendBestEffort(dest, payload, keyUsed, tagsSent); } /** @@ -94,9 +93,8 @@ class I2PSessionImpl2 extends I2PSessionImpl { } catch (IOException ioe) { throw new I2PSessionException("Error decompressing message", ioe); } - } else { - return compressed; } + return compressed; } private boolean sendBestEffort(Destination dest, byte payload[], SessionKey keyUsed, Set tagsSent) @@ -116,7 +114,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { if (false) // rekey newKey = _context.keyGenerator().generateSessionKey(); - long nonce = (long)_context.random().nextInt(Integer.MAX_VALUE); + long nonce = _context.random().nextInt(Integer.MAX_VALUE); MessageState state = new MessageState(nonce, getPrefix()); state.setKey(key); state.setTags(sentTags); @@ -196,7 +194,7 @@ class I2PSessionImpl2 extends I2PSessionImpl { if (false) // rekey newKey = _context.keyGenerator().generateSessionKey(); - long nonce = (long)_context.random().nextInt(Integer.MAX_VALUE); + long nonce = _context.random().nextInt(Integer.MAX_VALUE); MessageState state = new MessageState(nonce, getPrefix()); state.setKey(key); state.setTags(sentTags); diff --git a/core/java/src/net/i2p/client/MessageState.java b/core/java/src/net/i2p/client/MessageState.java index 9f1194b540..8b1792ac30 100644 --- a/core/java/src/net/i2p/client/MessageState.java +++ b/core/java/src/net/i2p/client/MessageState.java @@ -127,7 +127,7 @@ class MessageState { synchronized (_lock) { try { _lock.wait(timeToWait); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } @@ -163,13 +163,11 @@ class MessageState { case MessageStatusMessage.STATUS_SEND_ACCEPTED: if (wantedStatus == MessageStatusMessage.STATUS_SEND_ACCEPTED) { return true; // if we're only looking for accepted, take it directly (don't let any GUARANTEED_* override it) - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug(_prefix + "Got accepted, but we're waiting for more from " - + toString()); - continue; - // ignore accepted, as we want something better } + // ignore accepted, as we want something better + if (_log.shouldLog(Log.DEBUG)) + _log.debug(_prefix + "Got accepted, but we're waiting for more from " + toString()); + continue; case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_SUCCESS: if (_log.shouldLog(Log.DEBUG)) _log.debug(_prefix + "Received best effort success after " + getElapsed() diff --git a/core/java/src/net/i2p/client/TestClient.java b/core/java/src/net/i2p/client/TestClient.java index 61a67f3b9f..47a00fc3ce 100644 --- a/core/java/src/net/i2p/client/TestClient.java +++ b/core/java/src/net/i2p/client/TestClient.java @@ -64,7 +64,7 @@ public class TestClient implements I2PSessionListener { while ((_dest1 == null) || (_dest2 == null)) try { Thread.sleep(500); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } if (isDest1) { @@ -79,12 +79,12 @@ public class TestClient implements I2PSessionListener { try { _log.debug("waiting for a message..."); Thread.sleep(1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } try { Thread.sleep(5000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } System.exit(0); } @@ -98,7 +98,7 @@ public class TestClient implements I2PSessionListener { doTest(); try { Thread.sleep(30 * 1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } diff --git a/core/java/src/net/i2p/client/TestServer.java b/core/java/src/net/i2p/client/TestServer.java index b238efa38b..ee7b78bf3c 100644 --- a/core/java/src/net/i2p/client/TestServer.java +++ b/core/java/src/net/i2p/client/TestServer.java @@ -74,7 +74,7 @@ public class TestServer implements Runnable { * Fire up the router */ public static void main(String args[]) { - if (args.length == 1) { + if (args.length == 1) { // nop } else if (args.length == 2) { try { LISTEN_PORT = Integer.parseInt(args[1]); diff --git a/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java b/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java index 7d3c7d460e..2a314b959b 100644 --- a/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java +++ b/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java @@ -46,7 +46,8 @@ public final class I2PDatagramDissector { /** * Crate a new I2P repliable datagram dissector. */ - public I2PDatagramDissector() {} + public I2PDatagramDissector() { // nop + } /** * Load an I2P repliable datagram into the dissector. diff --git a/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java b/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java index f8cf4fdeae..c2f00f4123 100644 --- a/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java +++ b/core/java/src/net/i2p/client/naming/HostsTxtNamingService.java @@ -61,7 +61,7 @@ public class HostsTxtNamingService extends NamingService { } finally { if (fis != null) try { fis.close(); - } catch (IOException ioe) { + } catch (IOException ioe) { // nop } } String res = hosts.getProperty(hostname); diff --git a/core/java/src/net/i2p/client/naming/NamingService.java b/core/java/src/net/i2p/client/naming/NamingService.java index f3ebfa79a6..9420b401b4 100644 --- a/core/java/src/net/i2p/client/naming/NamingService.java +++ b/core/java/src/net/i2p/client/naming/NamingService.java @@ -35,7 +35,8 @@ public abstract class NamingService { protected NamingService(I2PAppContext context) { _context = context; } - private NamingService() {} + private NamingService() { // nop + } /** * Look up a host name. diff --git a/core/java/src/net/i2p/crypto/AESInputStream.java b/core/java/src/net/i2p/crypto/AESInputStream.java index 5f10aec594..073f4a7ea5 100644 --- a/core/java/src/net/i2p/crypto/AESInputStream.java +++ b/core/java/src/net/i2p/crypto/AESInputStream.java @@ -73,16 +73,15 @@ public class AESInputStream extends FilterInputStream { Integer nval = getNext(); if (nval != null) { return nval.intValue(); - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("No byte available. eof? " + _eofFound); - if (_eofFound) - return -1; - else { - throw new IOException("Not EOF, but none available? " + _readyBuf.size() + "/" + _encryptedBuf.size() - + "/" + _cumulativeRead + "... impossible"); - } } + if (_log.shouldLog(Log.DEBUG)) + _log.debug("No byte available. eof? " + _eofFound); + + if (_eofFound) + return -1; + + throw new IOException("Not EOF, but none available? " + _readyBuf.size() + "/" + _encryptedBuf.size() + + "/" + _cumulativeRead + "... impossible"); } public int read(byte dest[]) throws IOException { @@ -90,13 +89,11 @@ public class AESInputStream extends FilterInputStream { int val = read(); if (val == -1) { // no more to read... can they expect more? - if (_eofFound && (i == 0)) - return -1; - else - return i; - } else { - dest[i] = (byte) val; + if (_eofFound && (i == 0)) return -1; + + return i; } + dest[i] = (byte) val; } if (_log.shouldLog(Log.DEBUG)) _log.debug("Read the full buffer of size " + dest.length); @@ -141,7 +138,7 @@ public class AESInputStream extends FilterInputStream { + encrypted + " still encrypted]"); } - public void mark(int readLimit) { + public void mark(int readLimit) { // nop } public void reset() throws IOException { @@ -159,9 +156,9 @@ public class AESInputStream extends FilterInputStream { private Integer getNext() { if (_readyBuf.size() > 0) { return (Integer) _readyBuf.remove(0); - } else { - return null; } + + return null; } /** @@ -240,7 +237,7 @@ public class AESInputStream extends FilterInputStream { byte data[] = DataHelper.xor(decrypted, _lastBlock); int cleaned[] = stripPadding(data); for (int j = 0; j < cleaned.length; j++) { - if (((int) cleaned[j]) <= 0) { + if (cleaned[j] <= 0) { cleaned[j] += 256; //_log.error("(modified: " + cleaned[j] + ")"); } @@ -258,7 +255,7 @@ public class AESInputStream extends FilterInputStream { + " bytes back onto the buffer, lets delay 1s our action so we don't fast busy until the net transfers data"); try { Thread.sleep(1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } else { //_log.debug("No remaining encrypted bytes beyond the block size"); @@ -280,7 +277,7 @@ public class AESInputStream extends FilterInputStream { * */ private int[] stripPadding(byte data[]) throws IOException { - int numPadBytes = (int) data[data.length - 1]; + int numPadBytes = data[data.length - 1]; if ((numPadBytes >= data.length) || (numPadBytes <= 0)) { if (_log.shouldLog(Log.DEBUG)) _log.debug("stripPadding from block " + DataHelper.toHexString(data) + " (" + data.length + "bytes): " @@ -363,7 +360,7 @@ public class AESInputStream extends FilterInputStream { try { Thread.sleep(30 * 1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } diff --git a/core/java/src/net/i2p/crypto/CryptixRijndael_Algorithm.java b/core/java/src/net/i2p/crypto/CryptixRijndael_Algorithm.java index 8a872e3f82..bac0706dbb 100644 --- a/core/java/src/net/i2p/crypto/CryptixRijndael_Algorithm.java +++ b/core/java/src/net/i2p/crypto/CryptixRijndael_Algorithm.java @@ -166,14 +166,13 @@ public final class CryptixRijndael_Algorithm // implicit no-argument constructor t++; if (t == 4) throw new RuntimeException("G matrix is not invertible"); - else { - for (j = 0; j < 8; j++) { - tmp = AA[i][j]; - AA[i][j] = AA[t][j]; - AA[t][j] = (byte) tmp; - } - pivot = AA[i][i]; + + for (j = 0; j < 8; j++) { + tmp = AA[i][j]; + AA[i][j] = AA[t][j]; + AA[t][j] = tmp; } + pivot = AA[i][i]; } for (j = 0; j < 8; j++) if (AA[i][j] != 0) AA[i][j] = (byte) _alog[(255 + _log[AA[i][j] & 0xFF] - _log[pivot & 0xFF]) % 255]; diff --git a/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java b/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java index 9fa0292904..bb930ac3ed 100644 --- a/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java +++ b/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java @@ -266,7 +266,7 @@ public class DHSessionKeyBuilder { RandomSource.getInstance().nextBoolean(); // warm it up try { Thread.sleep(20 * 1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } I2PAppContext ctx = new I2PAppContext(); _log.debug("\n\n\n\nBegin test\n"); @@ -303,7 +303,7 @@ public class DHSessionKeyBuilder { _log.debug("Negotiation time for 5 runs: " + negTime + " @ " + negTime / 5l + "ms each"); try { Thread.sleep(2000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } @@ -329,7 +329,7 @@ public class DHSessionKeyBuilder { // for some relief... try { Thread.sleep(CALC_DELAY); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } @@ -343,7 +343,7 @@ public class DHSessionKeyBuilder { } try { Thread.sleep(30 * 1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } diff --git a/core/java/src/net/i2p/crypto/DSAEngine.java b/core/java/src/net/i2p/crypto/DSAEngine.java index 0bf261834e..7c8758185f 100644 --- a/core/java/src/net/i2p/crypto/DSAEngine.java +++ b/core/java/src/net/i2p/crypto/DSAEngine.java @@ -157,7 +157,7 @@ public class DSAEngine { k += 512; } int padbytes = k / 8; - int wordlength = (int) (source.length / 4 + padbytes / 4 + 3); + int wordlength = source.length / 4 + padbytes / 4 + 3; int[] M0 = new int[wordlength]; int wordcount = 0; int x = 0; diff --git a/core/java/src/net/i2p/crypto/DummyElGamalEngine.java b/core/java/src/net/i2p/crypto/DummyElGamalEngine.java index 5aad5261c3..2b2f5a9ece 100644 --- a/core/java/src/net/i2p/crypto/DummyElGamalEngine.java +++ b/core/java/src/net/i2p/crypto/DummyElGamalEngine.java @@ -97,11 +97,10 @@ public class DummyElGamalEngine extends ElGamalEngine { if (_log.shouldLog(Log.DEBUG)) _log.debug("Hash matches: " + DataHelper.toString(hash.getData(), hash.getData().length)); return rv; - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Doesn't match hash [calc=" + calcHash + " sent hash=" + hash + "]\ndata = " + new String(rv), - new Exception("Doesn't match")); - return null; } + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Doesn't match hash [calc=" + calcHash + " sent hash=" + hash + "]\ndata = " + new String(rv), + new Exception("Doesn't match")); + return null; } } \ No newline at end of file diff --git a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java index d15e82840f..bf9ae0e4c0 100644 --- a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java +++ b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java @@ -37,7 +37,9 @@ public class ElGamalAESEngine { private final static int MIN_ENCRYPTED_SIZE = 80; // smallest possible resulting size private I2PAppContext _context; - private ElGamalAESEngine() {} + private ElGamalAESEngine() { // nop + } + public ElGamalAESEngine(I2PAppContext ctx) { _context = ctx; @@ -217,13 +219,12 @@ public class ElGamalAESEngine { if (_log.shouldLog(Log.DEBUG)) _log.debug("Decrypt with a non session tag, but tags read: " + foundTags.size()); return decryptNewSession(data, targetPrivateKey, foundTags, usedKey, foundKey); - } else { - // existing session decrypted successfully! - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Decrypt with an EXISTING session tag successfull, # tags read: " + foundTags.size(), - new Exception("Decrypted by")); - return decrypted; } + // existing session decrypted successfully! + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Decrypt with an EXISTING session tag successfull, # tags read: " + foundTags.size(), + new Exception("Decrypted by")); + return decrypted; } /** @@ -292,9 +293,9 @@ public class ElGamalAESEngine { foundTags.addAll(tags); if (newKey != null) foundKey.setData(newKey.getData()); return unencrData; - } else { - throw new Exception("Hash does not match"); } + + throw new Exception("Hash does not match"); } catch (Exception e) { if (_log.shouldLog(Log.WARN)) _log.warn("Unable to decrypt AES block", e); return null; @@ -321,12 +322,11 @@ public class ElGamalAESEngine { _log.info("Current tag is null, encrypting as new session", new Exception("encrypt new")); _context.statManager().updateFrequency("crypto.elGamalAES.encryptNewSession"); return encryptNewSession(data, target, key, tagsForDelivery, newKey, paddedSize); - } else { - if (_log.shouldLog(Log.INFO)) - _log.info("Current tag is NOT null, encrypting as existing session", new Exception("encrypt existing")); - _context.statManager().updateFrequency("crypto.elGamalAES.encryptExistingSession"); - return encryptExistingSession(data, target, key, tagsForDelivery, currentTag, newKey, paddedSize); } + if (_log.shouldLog(Log.INFO)) + _log.info("Current tag is NOT null, encrypting as existing session", new Exception("encrypt existing")); + _context.statManager().updateFrequency("crypto.elGamalAES.encryptExistingSession"); + return encryptExistingSession(data, target, key, tagsForDelivery, currentTag, newKey, paddedSize); } /** diff --git a/core/java/src/net/i2p/crypto/ElGamalEngine.java b/core/java/src/net/i2p/crypto/ElGamalEngine.java index 2847caa9a8..b6f0cf9715 100644 --- a/core/java/src/net/i2p/crypto/ElGamalEngine.java +++ b/core/java/src/net/i2p/crypto/ElGamalEngine.java @@ -75,7 +75,9 @@ public class ElGamalEngine { _context = context; _log = context.logManager().getLog(ElGamalEngine.class); } - private ElGamalEngine() {} + + private ElGamalEngine() { // nop + } private final static BigInteger _two = new NativeBigInteger(1, new byte[] { 0x02}); @@ -215,12 +217,11 @@ public class ElGamalEngine { if (ok) { //_log.debug("Hash matches: " + DataHelper.toString(hash.getData(), hash.getData().length)); return rv; - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Doesn't match hash [calc=" + calcHash + " sent hash=" + hash + "]\ndata = " - + Base64.encode(rv), new Exception("Doesn't match")); - return null; } + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Doesn't match hash [calc=" + calcHash + " sent hash=" + hash + "]\ndata = " + + Base64.encode(rv), new Exception("Doesn't match")); + return null; } public static void main(String args[]) { @@ -230,12 +231,12 @@ public class ElGamalEngine { int numRuns = 100; if (args.length > 0) try { numRuns = Integer.parseInt(args[0]); - } catch (NumberFormatException nfe) { + } catch (NumberFormatException nfe) { // nop } try { Thread.sleep(30 * 1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } RandomSource.getInstance().nextBoolean(); diff --git a/core/java/src/net/i2p/crypto/HMACSHA256Generator.java b/core/java/src/net/i2p/crypto/HMACSHA256Generator.java index d90fa17d7a..920cce5dd3 100644 --- a/core/java/src/net/i2p/crypto/HMACSHA256Generator.java +++ b/core/java/src/net/i2p/crypto/HMACSHA256Generator.java @@ -11,7 +11,9 @@ import net.i2p.data.SessionKey; * */ public class HMACSHA256Generator { - public HMACSHA256Generator(I2PAppContext context) {}; + public HMACSHA256Generator(I2PAppContext context) { // nop + } + public static HMACSHA256Generator getInstance() { return I2PAppContext.getGlobalContext().hmac(); } diff --git a/core/java/src/net/i2p/crypto/KeyGenerator.java b/core/java/src/net/i2p/crypto/KeyGenerator.java index 2330fbe2d6..1960745461 100644 --- a/core/java/src/net/i2p/crypto/KeyGenerator.java +++ b/core/java/src/net/i2p/crypto/KeyGenerator.java @@ -166,7 +166,7 @@ public class KeyGenerator { try { Thread.sleep(5000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/crypto/PersistentSessionKeyManager.java b/core/java/src/net/i2p/crypto/PersistentSessionKeyManager.java index f323b9b74c..957fd186e3 100644 --- a/core/java/src/net/i2p/crypto/PersistentSessionKeyManager.java +++ b/core/java/src/net/i2p/crypto/PersistentSessionKeyManager.java @@ -182,7 +182,7 @@ public class PersistentSessionKeyManager extends TransientSessionKeyManager { } try { Thread.sleep(3000); - } catch (Throwable t) { + } catch (Throwable t) { // nop } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/crypto/SHA256Generator.java b/core/java/src/net/i2p/crypto/SHA256Generator.java index 87ef918a86..a4e7413034 100644 --- a/core/java/src/net/i2p/crypto/SHA256Generator.java +++ b/core/java/src/net/i2p/crypto/SHA256Generator.java @@ -39,7 +39,9 @@ import net.i2p.data.Hash; * @author thecrypto,jrandom */ public class SHA256Generator { - public SHA256Generator(I2PAppContext context) {}; + public SHA256Generator(I2PAppContext context) { // nop + } + public static SHA256Generator getInstance() { return I2PAppContext.getGlobalContext().sha(); } @@ -66,7 +68,7 @@ public class SHA256Generator { k += 512; } int padbytes = k / 8; - int wordlength = (int) (source.length / 4 + padbytes / 4 + 3); + int wordlength = source.length / 4 + padbytes / 4 + 3; int[] M0 = new int[wordlength]; int wordcount = 0; int x = 0; diff --git a/core/java/src/net/i2p/crypto/SessionKeyManager.java b/core/java/src/net/i2p/crypto/SessionKeyManager.java index 07ab061cbd..5b609347bb 100644 --- a/core/java/src/net/i2p/crypto/SessionKeyManager.java +++ b/core/java/src/net/i2p/crypto/SessionKeyManager.java @@ -25,9 +25,12 @@ import net.i2p.data.SessionTag; */ public class SessionKeyManager { /** session key managers must be created through an app context */ - protected SessionKeyManager(I2PAppContext context) {} + protected SessionKeyManager(I2PAppContext context) { // nop + } + /** see above */ - private SessionKeyManager() {} + private SessionKeyManager() { // nop + } /** * Retrieve the session key currently associated with encryption to the target, @@ -43,7 +46,7 @@ public class SessionKeyManager { * when to expire that key begin with this call. * */ - public void createSession(PublicKey target, SessionKey key) { + public void createSession(PublicKey target, SessionKey key) { // nop } /** @@ -90,7 +93,7 @@ public class SessionKeyManager { * method after receiving an ack to a message delivering them) * */ - public void tagsDelivered(PublicKey target, SessionKey key, Set sessionTags) { + public void tagsDelivered(PublicKey target, SessionKey key, Set sessionTags) { // nop } /** @@ -99,14 +102,14 @@ public class SessionKeyManager { * from corrupted tag sets and crashes * */ - public void failTags(PublicKey target) { + public void failTags(PublicKey target) { // nop } /** * Accept the given tags and associate them with the given key for decryption * */ - public void tagsReceived(SessionKey key, Set sessionTags) { + public void tagsReceived(SessionKey key, Set sessionTags) { // nop } /** @@ -125,6 +128,6 @@ public class SessionKeyManager { * whatever precautions are necessary (saving state, etc) * */ - public void shutdown() { + public void shutdown() { // nop } } \ No newline at end of file diff --git a/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java b/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java index d408d351ba..13bc32d338 100644 --- a/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java +++ b/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java @@ -123,9 +123,8 @@ class TransientSessionKeyManager extends SessionKeyManager { + new Date(sess.getEstablishedDate()) + " with target " + target); return null; - } else { - return sess.getCurrentKey(); } + return sess.getCurrentKey(); } /** @@ -158,11 +157,10 @@ class TransientSessionKeyManager extends SessionKeyManager { if (_log.shouldLog(Log.DEBUG)) _log.debug("Tag consumed: " + nxt); return nxt; - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Key does not match existing key, no tag"); - return null; } + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Key does not match existing key, no tag"); + return null; } /** @@ -175,9 +173,8 @@ class TransientSessionKeyManager extends SessionKeyManager { if (sess == null) { return 0; } if (sess.getCurrentKey().equals(key)) { return sess.availableTags(); - } else { - return 0; } + return 0; } /** @@ -189,9 +186,8 @@ class TransientSessionKeyManager extends SessionKeyManager { if (sess == null) { return 0; } if (sess.getCurrentKey().equals(key)) { return (sess.getLastExpirationDate() + SESSION_TAG_DURATION_MS) - Clock.getInstance().now(); - } else { - return 0; } + return 0; } /** @@ -263,9 +259,9 @@ class TransientSessionKeyManager extends SessionKeyManager { if (_log.shouldLog(Log.DEBUG)) _log.debug("Cannot consume tag " + tag + " as it is not known"); return null; - } else { - tagSet.consume(tag); } + tagSet.consume(tag); + SessionKey key = tagSet.getAssociatedKey(); if (_log.shouldLog(Log.DEBUG)) _log.debug("Consuming tag " + tag + " for sessionKey " + key); @@ -555,11 +551,11 @@ class TransientSessionKeyManager extends SessionKeyManager { public SessionTag consumeNext() { if (_sessionTags.size() <= 0) { return null; - } else { - SessionTag first = (SessionTag) _sessionTags.iterator().next(); - _sessionTags.remove(first); - return first; } + + SessionTag first = (SessionTag) _sessionTags.iterator().next(); + _sessionTags.remove(first); + return first; } public int hashCode() { diff --git a/core/java/src/net/i2p/crypto/YKGenerator.java b/core/java/src/net/i2p/crypto/YKGenerator.java index 682e0cc78d..cc9f42fb78 100644 --- a/core/java/src/net/i2p/crypto/YKGenerator.java +++ b/core/java/src/net/i2p/crypto/YKGenerator.java @@ -157,7 +157,7 @@ class YKGenerator { RandomSource.getInstance().nextBoolean(); // warm it up try { Thread.sleep(20 * 1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } _log.debug("\n\n\n\nBegin test\n"); long negTime = 0; @@ -169,7 +169,7 @@ class YKGenerator { _log.debug("YK fetch time for 5 runs: " + negTime + " @ " + negTime / 5l + "ms each"); try { Thread.sleep(30 * 1000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } @@ -197,7 +197,7 @@ class YKGenerator { // for some relief... try { Thread.sleep(CALC_DELAY); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } @@ -211,7 +211,7 @@ class YKGenerator { } try { Thread.sleep(CHECK_DELAY); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } diff --git a/core/java/src/net/i2p/data/Base64.java b/core/java/src/net/i2p/data/Base64.java index 78218cd188..d7049dff49 100644 --- a/core/java/src/net/i2p/data/Base64.java +++ b/core/java/src/net/i2p/data/Base64.java @@ -114,7 +114,7 @@ public class Base64 { private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding /** Defeats instantiation. */ - private Base64() { + private Base64() { // nop } public static void main(String[] args) { diff --git a/core/java/src/net/i2p/data/ByteArray.java b/core/java/src/net/i2p/data/ByteArray.java index 243cc73abb..11c30a8862 100644 --- a/core/java/src/net/i2p/data/ByteArray.java +++ b/core/java/src/net/i2p/data/ByteArray.java @@ -40,13 +40,13 @@ public class ByteArray implements Serializable { if (o == null) return false; if (o instanceof ByteArray) { return compare(getData(), ((ByteArray) o).getData()); - } else { - try { - byte val[] = (byte[]) o; - return compare(getData(), val); - } catch (Throwable t) { - return false; - } + } + + try { + byte val[] = (byte[]) o; + return compare(getData(), val); + } catch (Throwable t) { + return false; } } diff --git a/core/java/src/net/i2p/data/Certificate.java b/core/java/src/net/i2p/data/Certificate.java index 7d82464644..e2a4fd6058 100644 --- a/core/java/src/net/i2p/data/Certificate.java +++ b/core/java/src/net/i2p/data/Certificate.java @@ -78,9 +78,9 @@ public class Certificate extends DataStructureImpl { if (_type < 0) throw new DataFormatException("Invalid certificate type: " + _type); if ((_type != 0) && (_payload == null)) throw new DataFormatException("Payload is required for non null type"); - DataHelper.writeLong(out, 1, (long) _type); + DataHelper.writeLong(out, 1, _type); if (_payload != null) { - DataHelper.writeLong(out, 2, (long) _payload.length); + DataHelper.writeLong(out, 2, _payload.length); out.write(_payload); } else { DataHelper.writeLong(out, 2, 0L); diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 551c66feb0..9cd632eaf4 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -148,10 +148,9 @@ public class DataHelper { } public static String toString(byte buf[]) { - if (buf == null) - return ""; - else - return toString(buf, buf.length); + if (buf == null) return ""; + + return toString(buf, buf.length); } private static final byte[] EMPTY_BUFFER = "".getBytes(); @@ -164,7 +163,7 @@ public class DataHelper { out.append("00"); } for (int i = 0; i < buf.length && i < len; i++) { - StringBuffer temp = new StringBuffer(Integer.toHexString((int) buf[i])); + StringBuffer temp = new StringBuffer(Integer.toHexString(buf[i])); while (temp.length() < 2) { temp.insert(0, '0'); } @@ -241,10 +240,9 @@ public class DataHelper { */ public static Date readDate(InputStream in) throws DataFormatException, IOException { long date = readLong(in, 8); - if (date == 0L) - return null; - else - return new Date(date); + if (date == 0L) return null; + + return new Date(date); } /** Write out a date to the stream as specified by the I2P data structure spec. @@ -448,10 +446,9 @@ public class DataHelper { * */ public static int hashCode(Object obj) { - if (obj == null) - return 0; - else - return obj.hashCode(); + if (obj == null) return 0; + + return obj.hashCode(); } /** @@ -459,10 +456,9 @@ public class DataHelper { * */ public static int hashCode(Date obj) { - if (obj == null) - return 0; - else - return (int) obj.getTime(); + if (obj == null) return 0; + + return (int) obj.getTime(); } /** @@ -495,10 +491,9 @@ public class DataHelper { while (cur < target.length) { int numRead = in.read(target, cur, target.length - cur); if (numRead == -1) { - if (cur == 0) - return -1; // throw new EOFException("EOF Encountered during reading"); - else - return cur; + if (cur == 0) return -1; // throw new EOFException("EOF Encountered during reading"); + + return cur; } cur += numRead; } diff --git a/core/java/src/net/i2p/data/DataStructureImpl.java b/core/java/src/net/i2p/data/DataStructureImpl.java index 8307bd139e..fe7fe9b732 100644 --- a/core/java/src/net/i2p/data/DataStructureImpl.java +++ b/core/java/src/net/i2p/data/DataStructureImpl.java @@ -29,8 +29,8 @@ public abstract class DataStructureImpl implements DataStructure { byte data[] = toByteArray(); if (data == null) return null; - else - return Base64.encode(data); + + return Base64.encode(data); } public void fromBase64(String data) throws DataFormatException { diff --git a/core/java/src/net/i2p/data/Hash.java b/core/java/src/net/i2p/data/Hash.java index 92779dc73f..2eeb9f0eb5 100644 --- a/core/java/src/net/i2p/data/Hash.java +++ b/core/java/src/net/i2p/data/Hash.java @@ -99,7 +99,7 @@ public class Hash extends DataStructureImpl { _xorCache.remove(iter.next()); } distance = DataHelper.xor(key.getData(), getData()); - _xorCache.put(key, (Object)distance); + _xorCache.put(key, (Object) distance); cached = _xorCache.size(); } if (_log.shouldLog(Log.DEBUG)) { diff --git a/core/java/src/net/i2p/data/LeaseSet.java b/core/java/src/net/i2p/data/LeaseSet.java index cea706043d..6892e4826b 100644 --- a/core/java/src/net/i2p/data/LeaseSet.java +++ b/core/java/src/net/i2p/data/LeaseSet.java @@ -121,8 +121,8 @@ public class LeaseSet extends DataStructureImpl { Hash rk = RoutingKeyGenerator.getInstance().getRoutingKey(destKey); if (rk.equals(getRoutingKey())) return true; - else - return false; + + return false; } /** @@ -136,7 +136,7 @@ public class LeaseSet extends DataStructureImpl { public long getEarliestLeaseDate() { long when = -1; for (int i = 0; i < getLeaseCount(); i++) { - Lease lse = (Lease) getLease(i); + Lease lse = getLease(i); if ((lse != null) && (lse.getEndDate() != null)) { if ((when <= 0) || (lse.getEndDate().getTime() < when)) when = lse.getEndDate().getTime(); } diff --git a/core/java/src/net/i2p/data/RouterInfo.java b/core/java/src/net/i2p/data/RouterInfo.java index 2f36d79b5b..2f40587e95 100644 --- a/core/java/src/net/i2p/data/RouterInfo.java +++ b/core/java/src/net/i2p/data/RouterInfo.java @@ -302,8 +302,8 @@ public class RouterInfo extends DataStructureImpl { Hash rk = RoutingKeyGenerator.getInstance().getRoutingKey(identKey); if (rk.equals(getRoutingKey())) return true; - else - return false; + + return false; } /** @@ -316,11 +316,10 @@ public class RouterInfo extends DataStructureImpl { */ public boolean isCurrent(long maxAgeMs) { long earliestExpire = Clock.getInstance().now() - maxAgeMs; - if (getPublished() < earliestExpire) { + if (getPublished() < earliestExpire) return false; - } else { - return true; - } + + return true; } /** diff --git a/core/java/src/net/i2p/data/RoutingKeyGenerator.java b/core/java/src/net/i2p/data/RoutingKeyGenerator.java index c20b5779a3..76cdacfb06 100644 --- a/core/java/src/net/i2p/data/RoutingKeyGenerator.java +++ b/core/java/src/net/i2p/data/RoutingKeyGenerator.java @@ -124,7 +124,7 @@ public class RoutingKeyGenerator { } try { Thread.sleep(2000); - } catch (Throwable t) { + } catch (Throwable t) { // nop } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/data/UnsignedInteger.java b/core/java/src/net/i2p/data/UnsignedInteger.java index c15a81416e..4131a407ad 100644 --- a/core/java/src/net/i2p/data/UnsignedInteger.java +++ b/core/java/src/net/i2p/data/UnsignedInteger.java @@ -76,7 +76,7 @@ public class UnsignedInteger { } else if (data.length == 0) { return 0; } long rv = 0; for (int i = 0; i < data.length; i++) { - long cur = (long)(data[i]&0xFF); + long cur = data[i] & 0xFF; if (cur < 0) cur = cur+256; cur = (cur << (8*(data.length-i-1))); rv += cur; @@ -90,7 +90,7 @@ public class UnsignedInteger { + " != \n " + Long.toBinaryString(rv) + " /\t" + Long.toHexString(rv) + " /\t" + rv); for (int i = 0; i < data.length; i++) { - long cur = (long)(data[i]&0xFF); + long cur = data[i] & 0xFF; if (cur < 0) cur = cur+256; long shiftBy = (8*(data.length-i-1)); long old = cur; @@ -210,9 +210,8 @@ public class UnsignedInteger { if ((obj != null) && (obj instanceof UnsignedInteger)) { return DataHelper.eq(_data, ((UnsignedInteger) obj)._data) && DataHelper.eq(_value, ((UnsignedInteger) obj)._value); - } else { - return false; } + return false; } public int hashCode() { @@ -242,7 +241,7 @@ public class UnsignedInteger { } catch (Throwable t) { t.printStackTrace(); } try { Thread.sleep(1000); - } catch (Throwable t) { + } catch (Throwable t) { // nop } } diff --git a/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java b/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java index 9135f4ac01..596796311e 100644 --- a/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java +++ b/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java @@ -114,9 +114,9 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl { && DataHelper.eq(getSigningPrivateKey(), msg.getSigningPrivateKey()) && DataHelper.eq(getPrivateKey(), msg.getPrivateKey()) && DataHelper.eq(getLeaseSet(), msg.getLeaseSet()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java b/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java index fbe18f91c3..9a67a6184f 100644 --- a/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java +++ b/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java @@ -74,9 +74,9 @@ public class CreateSessionMessage extends I2CPMessageImpl { if ((object != null) && (object instanceof CreateSessionMessage)) { CreateSessionMessage msg = (CreateSessionMessage) object; return DataHelper.eq(getSessionConfig(), msg.getSessionConfig()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java b/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java index 3aeb984f9f..ca7c7580f8 100644 --- a/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java +++ b/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java @@ -70,9 +70,9 @@ public class DestroySessionMessage extends I2CPMessageImpl { if ((object != null) && (object instanceof DestroySessionMessage)) { DestroySessionMessage msg = (DestroySessionMessage) object; return DataHelper.eq(getSessionId(), msg.getSessionId()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java b/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java index c4c294d604..21477ad7f1 100644 --- a/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java +++ b/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java @@ -66,9 +66,9 @@ public class DisconnectMessage extends I2CPMessageImpl { if ((object != null) && (object instanceof DisconnectMessage)) { DisconnectMessage msg = (DisconnectMessage) object; return DataHelper.eq(getReason(), msg.getReason()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/GetDateMessage.java b/core/java/src/net/i2p/data/i2cp/GetDateMessage.java index 329de60ae4..9b0da7a0d5 100644 --- a/core/java/src/net/i2p/data/i2cp/GetDateMessage.java +++ b/core/java/src/net/i2p/data/i2cp/GetDateMessage.java @@ -42,9 +42,9 @@ public class GetDateMessage extends I2CPMessageImpl { public boolean equals(Object object) { if ((object != null) && (object instanceof GetDateMessage)) { return true; - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java b/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java index ca068c4cc7..ae3478902d 100644 --- a/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java +++ b/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java @@ -27,7 +27,7 @@ import net.i2p.util.Log; public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPMessage { private final static Log _log = new Log(I2CPMessageImpl.class); - public I2CPMessageImpl() { + public I2CPMessageImpl() { // nop } /** diff --git a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java index ccae59e12f..b4fa132dd4 100644 --- a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java +++ b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java @@ -168,7 +168,7 @@ public class I2CPMessageReader { // pause .5 secs when we're paused try { Thread.sleep(500); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } diff --git a/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java b/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java index 7f425b6d7f..230de8836b 100644 --- a/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java +++ b/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java @@ -103,9 +103,9 @@ public class MessagePayloadMessage extends I2CPMessageImpl { return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getMessageId(), msg.getMessageId()) && DataHelper.eq(getPayload(), msg.getPayload()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java b/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java index 1f85f13e66..e11a8cacaf 100644 --- a/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java +++ b/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java @@ -146,9 +146,9 @@ public class MessageStatusMessage extends I2CPMessageImpl { return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getMessageId(), msg.getMessageId()) && (getNonce() == msg.getNonce()) && DataHelper.eq(getSize(), msg.getSize()) && DataHelper.eq(getStatus(), msg.getStatus()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java b/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java index 30834aa0d6..eb56896d7b 100644 --- a/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java @@ -83,9 +83,9 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl { ReceiveMessageBeginMessage msg = (ReceiveMessageBeginMessage) object; return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getMessageId(), msg.getMessageId()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java b/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java index ee3f55f508..5257c5fe9e 100644 --- a/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java @@ -83,9 +83,9 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl { ReceiveMessageEndMessage msg = (ReceiveMessageEndMessage) object; return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getMessageId(), msg.getMessageId()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java b/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java index 072ab34fef..c6a1b1c9b5 100644 --- a/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java @@ -113,9 +113,9 @@ public class ReportAbuseMessage extends I2CPMessageImpl { ReportAbuseMessage msg = (ReportAbuseMessage) object; return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getSeverity(), msg.getSeverity()) && DataHelper.eq(getReason(), msg.getReason()) && DataHelper.eq(getMessageId(), msg.getMessageId()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java b/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java index 986da520de..cdbc3148e3 100644 --- a/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java +++ b/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java @@ -131,9 +131,9 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl { return false; } return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getEndDate(), msg.getEndDate()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java b/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java index 809b133475..d25fa30960 100644 --- a/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java +++ b/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java @@ -111,9 +111,9 @@ public class SendMessageMessage extends I2CPMessageImpl { return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getDestination(), msg.getDestination()) && (getNonce() == msg.getNonce()) && DataHelper.eq(getPayload(), msg.getPayload()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/SessionConfig.java b/core/java/src/net/i2p/data/i2cp/SessionConfig.java index 83b2b1c8af..3763bfc5ef 100644 --- a/core/java/src/net/i2p/data/i2cp/SessionConfig.java +++ b/core/java/src/net/i2p/data/i2cp/SessionConfig.java @@ -204,9 +204,9 @@ public class SessionConfig extends DataStructureImpl { && DataHelper.eq(getDestination(), cfg.getDestination()) && DataHelper.eq(getCreationDate(), cfg.getCreationDate()) && DataHelper.eq(getOptions(), cfg.getOptions()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java b/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java index e694a8ad75..67dd367207 100644 --- a/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java +++ b/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java @@ -86,9 +86,9 @@ public class SessionStatusMessage extends I2CPMessageImpl { if ((object != null) && (object instanceof SessionStatusMessage)) { SessionStatusMessage msg = (SessionStatusMessage) object; return DataHelper.eq(getSessionId(), msg.getSessionId()) && DataHelper.eq(getStatus(), msg.getStatus()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/data/i2cp/SetDateMessage.java b/core/java/src/net/i2p/data/i2cp/SetDateMessage.java index b91c2e92a8..49247b0278 100644 --- a/core/java/src/net/i2p/data/i2cp/SetDateMessage.java +++ b/core/java/src/net/i2p/data/i2cp/SetDateMessage.java @@ -69,9 +69,9 @@ public class SetDateMessage extends I2CPMessageImpl { if ((object != null) && (object instanceof SetDateMessage)) { SetDateMessage msg = (SetDateMessage) object; return DataHelper.eq(getDate(), msg.getDate()); - } else { - return false; } + + return false; } public String toString() { diff --git a/core/java/src/net/i2p/stat/Frequency.java b/core/java/src/net/i2p/stat/Frequency.java index 82ffb64e4d..ef42108f20 100644 --- a/core/java/src/net/i2p/stat/Frequency.java +++ b/core/java/src/net/i2p/stat/Frequency.java @@ -55,20 +55,18 @@ public class Frequency { /** calculate how many events would occur in a period given the current average */ public double getAverageEventsPerPeriod() { synchronized (_lock) { - if (_avgInterval > 0) - return _period / _avgInterval; - else - return 0; + if (_avgInterval > 0) return _period / _avgInterval; + + return 0; } } /** calculate how many events would occur in a period given the maximum average */ public double getMaxAverageEventsPerPeriod() { synchronized (_lock) { - if (_minAverageInterval > 0) - return _period / _minAverageInterval; - else - return 0; + if (_minAverageInterval > 0) return _period / _minAverageInterval; + + return 0; } } @@ -76,10 +74,9 @@ public class Frequency { public double getStrictAverageInterval() { synchronized (_lock) { long duration = now() - _start; - if ((duration <= 0) || (_count <= 0)) - return 0; - else - return duration / _count; + if ((duration <= 0) || (_count <= 0)) return 0; + + return duration / _count; } } @@ -87,10 +84,9 @@ public class Frequency { public double getStrictAverageEventsPerPeriod() { double avgInterval = getStrictAverageInterval(); synchronized (_lock) { - if (avgInterval > 0) - return _period / avgInterval; - else - return 0; + if (avgInterval > 0) return _period / avgInterval; + + return 0; } } diff --git a/core/java/src/net/i2p/stat/Rate.java b/core/java/src/net/i2p/stat/Rate.java index c1fd5602d8..9a6e07f60f 100644 --- a/core/java/src/net/i2p/stat/Rate.java +++ b/core/java/src/net/i2p/stat/Rate.java @@ -182,27 +182,26 @@ public class Rate { if (measuredPeriod < _period) { // no need to coallesce return; - } else { - // ok ok, lets coallesce - - // how much were we off by? (so that we can sample down the measured values) - double periodFactor = measuredPeriod / _period; - _lastTotalValue = (_currentTotalValue == 0 ? 0.0d : _currentTotalValue / periodFactor); - _lastEventCount = (_currentEventCount == 0 ? 0l : (long) (_currentEventCount / periodFactor)); - _lastTotalEventTime = (_currentTotalEventTime == 0 ? 0l - : (long) (_currentTotalEventTime / periodFactor)); - _lastCoallesceDate = now; - - if (_lastTotalValue > _extremeTotalValue) { - _extremeTotalValue = _lastTotalValue; - _extremeEventCount = _lastEventCount; - _extremeTotalEventTime = _lastTotalEventTime; - } - - _currentTotalValue = 0.0d; - _currentEventCount = 0; - _currentTotalEventTime = 0; } + + // ok ok, lets coallesce + + // how much were we off by? (so that we can sample down the measured values) + double periodFactor = measuredPeriod / _period; + _lastTotalValue = (_currentTotalValue == 0 ? 0.0D : _currentTotalValue / periodFactor); + _lastEventCount = (_currentEventCount == 0 ? 0L : (long) (_currentEventCount / periodFactor)); + _lastTotalEventTime = (_currentTotalEventTime == 0 ? 0L : (long) (_currentTotalEventTime / periodFactor)); + _lastCoallesceDate = now; + + if (_lastTotalValue > _extremeTotalValue) { + _extremeTotalValue = _lastTotalValue; + _extremeEventCount = _lastEventCount; + _extremeTotalEventTime = _lastTotalEventTime; + } + + _currentTotalValue = 0.0D; + _currentEventCount = 0; + _currentTotalEventTime = 0; } } @@ -210,24 +209,24 @@ public class Rate { public double getAverageValue() { if ((_lastTotalValue != 0) && (_lastEventCount > 0)) return _lastTotalValue / _lastEventCount; - else - return 0.0d; + + return 0.0D; } /** what was the average value across the events in the most active period? */ public double getExtremeAverageValue() { if ((_extremeTotalValue != 0) && (_extremeEventCount > 0)) return _extremeTotalValue / _extremeEventCount; - else - return 0.0d; + + return 0.0D; } /** what was the average value across the events since the stat was created? */ public double getLifetimeAverageValue() { if ((_lifetimeTotalValue != 0) && (_lifetimeEventCount > 0)) return _lifetimeTotalValue / _lifetimeEventCount; - else - return 0.0d; + + return 0.0D; } /** @@ -239,12 +238,12 @@ public class Rate { public double getLastEventSaturation() { if ((_lastEventCount > 0) && (_lastTotalEventTime > 0)) { double eventTime = (double) _lastTotalEventTime / (double) _lastEventCount; - double maxEvents = (double) _period / eventTime; + double maxEvents = _period / eventTime; double saturation = _lastEventCount / maxEvents; return saturation; - } else { - return 0.0d; } + + return 0.0D; } /** @@ -256,11 +255,10 @@ public class Rate { public double getExtremeEventSaturation() { if ((_extremeEventCount > 0) && (_extremeTotalEventTime > 0)) { double eventTime = (double) _extremeTotalEventTime / (double) _extremeEventCount; - double maxEvents = (double) _period / eventTime; + double maxEvents = _period / eventTime; return _extremeEventCount / maxEvents; - } else { - return 0.0d; } + return 0.0D; } /** @@ -272,13 +270,12 @@ public class Rate { public double getLifetimeEventSaturation() { if ((_lastEventCount > 0) && (_lifetimeTotalEventTime > 0)) { double eventTime = (double) _lifetimeTotalEventTime / (double) _lifetimeEventCount; - double maxEvents = (double) _period / eventTime; + double maxEvents = _period / eventTime; double numPeriods = getLifetimePeriods(); double avgEventsPerPeriod = _lifetimeEventCount / numPeriods; return avgEventsPerPeriod / maxEvents; - } else { - return 0.0d; } + return 0.0D; } /** how many periods have we already completed? */ @@ -297,13 +294,11 @@ public class Rate { public double getLastSaturationLimit() { if ((_lastTotalValue != 0) && (_lastEventCount > 0) && (_lastTotalEventTime > 0)) { double saturation = getLastEventSaturation(); - if (saturation != 0.0d) - return _lastTotalValue / saturation; - else - return 0.0d; - } else { - return 0.0d; + if (saturation != 0.0D) return _lastTotalValue / saturation; + + return 0.0D; } + return 0.0D; } /** @@ -315,13 +310,12 @@ public class Rate { public double getExtremeSaturationLimit() { if ((_extremeTotalValue != 0) && (_extremeEventCount > 0) && (_extremeTotalEventTime > 0)) { double saturation = getExtremeEventSaturation(); - if (saturation != 0.0d) - return _extremeTotalValue / saturation; - else - return 0.0d; - } else { - return 0.0d; - } + if (saturation != 0.0d) return _extremeTotalValue / saturation; + + return 0.0D; + } + + return 0.0D; } /** @@ -331,8 +325,8 @@ public class Rate { public double getPercentageOfExtremeValue() { if ((_lastTotalValue != 0) && (_extremeTotalValue != 0)) return _lastTotalValue / _extremeTotalValue; - else - return 0.0d; + + return 0.0D; } /** @@ -343,9 +337,9 @@ public class Rate { if ((_lastTotalValue != 0) && (_lifetimeTotalValue != 0)) { double lifetimePeriodValue = _period * (_lifetimeTotalValue / (now() - _creationDate)); return _lastTotalValue / lifetimePeriodValue; - } else { - return 0.0d; } + + return 0.0D; } public void store(String prefix, StringBuffer buf) throws IOException { @@ -468,7 +462,7 @@ public class Rate { for (int i = 0; i < 50; i++) { try { Thread.sleep(20); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } rate.addData(i * 100, 20); } @@ -492,7 +486,7 @@ public class Rate { } try { Thread.sleep(5000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/stat/RateStat.java b/core/java/src/net/i2p/stat/RateStat.java index 0de1a0c758..b2e558f391 100644 --- a/core/java/src/net/i2p/stat/RateStat.java +++ b/core/java/src/net/i2p/stat/RateStat.java @@ -97,9 +97,9 @@ public class RateStat { for (int i = 0; i < _rates.length; i++) if (!_rates[i].equals(rs.getRate(_rates[i].getPeriod()))) return false; return true; - } else { - return false; - } + } + + return false; } public void store(OutputStream out, String prefix) throws IOException { @@ -158,7 +158,7 @@ public class RateStat { for (int i = 0; i < 50; i++) { try { Thread.sleep(20); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } rs.addData(i * 100, 20); } @@ -185,7 +185,7 @@ public class RateStat { } try { Thread.sleep(5000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/util/EventDispatcherImpl.java b/core/java/src/net/i2p/util/EventDispatcherImpl.java index a30e26904f..b82682b885 100644 --- a/core/java/src/net/i2p/util/EventDispatcherImpl.java +++ b/core/java/src/net/i2p/util/EventDispatcherImpl.java @@ -132,7 +132,7 @@ public class EventDispatcherImpl implements EventDispatcher { } try { _events.wait(1 * 1000); - } catch (InterruptedException e) { + } catch (InterruptedException e) { // nop } } } while (true); diff --git a/core/java/src/net/i2p/util/HTTPSendData.java b/core/java/src/net/i2p/util/HTTPSendData.java index e0f22b589d..18d072db81 100644 --- a/core/java/src/net/i2p/util/HTTPSendData.java +++ b/core/java/src/net/i2p/util/HTTPSendData.java @@ -84,7 +84,7 @@ public class HTTPSendData { _log.debug("Sent? " + sent); try { Thread.sleep(2000); - } catch (InterruptedException ie) { + } catch (InterruptedException ie) { // nop } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/util/HexDump.java b/core/java/src/net/i2p/util/HexDump.java index 10ce2cc33d..0d56d2f981 100644 --- a/core/java/src/net/i2p/util/HexDump.java +++ b/core/java/src/net/i2p/util/HexDump.java @@ -106,7 +106,7 @@ public class HexDump { if (i >= nextbytes) { out.write(" ".getBytes()); } else { - val = ((int) data[dumpoff + i]) & 0xff; + val = data[dumpoff + i] & 0xff; out.write(HEXCHARS[val >>> 4]); out.write(HEXCHARS[val & 0xf]); out.write(" ".getBytes()); diff --git a/core/java/src/net/i2p/util/I2PThread.java b/core/java/src/net/i2p/util/I2PThread.java index bdd1197351..88d89da74a 100644 --- a/core/java/src/net/i2p/util/I2PThread.java +++ b/core/java/src/net/i2p/util/I2PThread.java @@ -86,7 +86,7 @@ public class I2PThread extends Thread { t.start(); try { Thread.sleep(10000); - } catch (Throwable tt) { + } catch (Throwable tt) { // nop } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/util/Log.java b/core/java/src/net/i2p/util/Log.java index 55fa08cc98..ff14968cbb 100644 --- a/core/java/src/net/i2p/util/Log.java +++ b/core/java/src/net/i2p/util/Log.java @@ -161,10 +161,9 @@ public class Log { } public String getName() { - if (_class != null) - return _class.getName(); - else - return _name; + if (_class != null) return _class.getName(); + + return _name; } public Object getScope() { return _scope; } @@ -189,9 +188,9 @@ public class Log { LogScope s = (LogScope)obj; return DataHelper.eq(s._scopeName, _scopeName) && DataHelper.eq(s._scopeClass, _scopeClass); - } else { - return false; } + + return false; } } } \ No newline at end of file diff --git a/core/java/src/net/i2p/util/LogManager.java b/core/java/src/net/i2p/util/LogManager.java index d1d0d79ef8..92f73fee35 100644 --- a/core/java/src/net/i2p/util/LogManager.java +++ b/core/java/src/net/i2p/util/LogManager.java @@ -108,7 +108,9 @@ public class LogManager { } //System.out.println("Created logManager " + this + " with context: " + context); } - private LogManager() {} + + private LogManager() { // nop + } public Log getLog(Class cls) { return getLog(cls, null); } public Log getLog(String name) { return getLog(null, name); } @@ -213,10 +215,11 @@ public class LogManager { + (_context.clock().now() - _configLastRead) + "ms ago, config file modified " + (_context.clock().now() - cfgFile.lastModified()) + "ms ago"); return; - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Loading config from " + _location); } + + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Loading config from " + _location); + Properties p = new Properties(); FileInputStream fis = null; try { @@ -228,7 +231,7 @@ public class LogManager { } finally { if (fis != null) try { fis.close(); - } catch (IOException ioe) { + } catch (IOException ioe) { // nop } } parseConfig(p); @@ -320,7 +323,7 @@ public class LogManager { char mod = size.toUpperCase().charAt(size.length() - 1); if (!Character.isDigit(mod)) v = size.substring(0, size.length() - 1); int val = Integer.parseInt(v); - switch ((int) mod) { + switch (mod) { case 'K': val *= 1024; break; @@ -443,7 +446,7 @@ public class LogManager { l1.error("test exception", new Exception("test")); try { Thread.sleep(2 * 1000); - } catch (Throwable t) { + } catch (Throwable t) { // nop } System.exit(0); } diff --git a/core/java/src/net/i2p/util/LogRecordFormatter.java b/core/java/src/net/i2p/util/LogRecordFormatter.java index 58c0fcc29b..033ca57693 100644 --- a/core/java/src/net/i2p/util/LogRecordFormatter.java +++ b/core/java/src/net/i2p/util/LogRecordFormatter.java @@ -33,20 +33,20 @@ class LogRecordFormatter { StringBuffer buf = new StringBuffer(size); char format[] = manager.getFormat(); for (int i = 0; i < format.length; ++i) { - switch ((int) format[i]) { - case (int) LogManager.DATE: + switch (format[i]) { + case LogManager.DATE: buf.append(getWhen(manager, rec)); break; - case (int) LogManager.CLASS: + case LogManager.CLASS: buf.append(getWhere(rec)); break; - case (int) LogManager.THREAD: + case LogManager.THREAD: buf.append(getThread(rec)); break; - case (int) LogManager.PRIORITY: + case LogManager.PRIORITY: buf.append(getPriority(rec)); break; - case (int) LogManager.MESSAGE: + case LogManager.MESSAGE: buf.append(getWhat(rec)); break; default: @@ -62,7 +62,7 @@ class LogRecordFormatter { try { pw.flush(); baos.flush(); - } catch (IOException ioe) { + } catch (IOException ioe) { // nop } byte tb[] = baos.toByteArray(); buf.append(new String(tb)); diff --git a/core/java/src/net/i2p/util/LogWriter.java b/core/java/src/net/i2p/util/LogWriter.java index ba04097f81..421f13dc1f 100644 --- a/core/java/src/net/i2p/util/LogWriter.java +++ b/core/java/src/net/i2p/util/LogWriter.java @@ -33,7 +33,9 @@ class LogWriter implements Runnable { private boolean _write; - private LogWriter() {} + private LogWriter() { // nop + } + public LogWriter(LogManager manager) { _manager = manager; } @@ -69,7 +71,10 @@ class LogWriter implements Runnable { } catch (Throwable t) { t.printStackTrace(); } finally { - try { Thread.sleep(100); } catch (InterruptedException ie) {} + try { + Thread.sleep(100); + } catch (InterruptedException ie) { // nop + } } } @@ -148,19 +153,21 @@ class LogWriter implements Runnable { */ private File getNextFile(String pattern) { File f = null; + if (pattern.indexOf('#') < 0) { return new File(pattern); - } else { - int max = _manager.getRotationLimit(); - if (_rotationNum == -1) { - return getFirstFile(pattern, max); - } else { - // we're in rotation, just go to the next - _rotationNum++; - if (_rotationNum > max) _rotationNum = 0; - return new File(replace(pattern, _rotationNum)); - } } + + int max = _manager.getRotationLimit(); + if (_rotationNum == -1) { + return getFirstFile(pattern, max); + } + + // we're in rotation, just go to the next + _rotationNum++; + if (_rotationNum > max) _rotationNum = 0; + + return new File(replace(pattern, _rotationNum)); } /** diff --git a/core/java/src/net/i2p/util/NativeBigInteger.java b/core/java/src/net/i2p/util/NativeBigInteger.java index c7bc379c40..da9c288bab 100644 --- a/core/java/src/net/i2p/util/NativeBigInteger.java +++ b/core/java/src/net/i2p/util/NativeBigInteger.java @@ -137,8 +137,8 @@ public class NativeBigInteger extends BigInteger { public BigInteger modPow(BigInteger exponent, BigInteger m) { if (_nativeOk) return new NativeBigInteger(nativeModPow(toByteArray(), exponent.toByteArray(), m.toByteArray())); - else - return super.modPow(exponent, m); + + return super.modPow(exponent, m); } /** @@ -197,10 +197,10 @@ public class NativeBigInteger extends BigInteger { System.err.println("ERROR: java modPow value: " + jval.toString()); System.err.println("ERROR: run time: " + totalTime + "ms (" + (totalTime / (runsProcessed + 1)) + "ms each)"); break; - } else { - System.out.println("DEBUG: current run time: " + (afterModPow - beforeModPow) + "ms (total: " - + totalTime + "ms, " + (totalTime / (runsProcessed + 1)) + "ms each)"); } + + System.out.println("DEBUG: current run time: " + (afterModPow - beforeModPow) + "ms (total: " + + totalTime + "ms, " + (totalTime / (runsProcessed + 1)) + "ms each)"); } System.out.println("INFO: run time: " + totalTime + "ms (" + (totalTime / (runsProcessed + 1)) + "ms each)"); if (numRuns == runsProcessed) @@ -212,7 +212,7 @@ public class NativeBigInteger extends BigInteger { System.out.println("native run time: \t" + totalTime + "ms (" + (totalTime / (runsProcessed + 1)) + "ms each)"); System.out.println("java run time: \t" + javaTime + "ms (" + (javaTime / (runsProcessed + 1)) + "ms each)"); - System.out.println("native = " + ((totalTime * 100.0d) / (double) javaTime) + "% of pure java time"); + System.out.println("native = " + ((totalTime * 100.0D) / javaTime) + "% of pure java time"); } else { System.out.println("java run time: \t" + javaTime + "ms (" + (javaTime / (runsProcessed + 1)) + "ms each)"); System.out.println("However, we couldn't load the native library, so this doesn't test much"); @@ -349,7 +349,12 @@ public class NativeBigInteger extends BigInteger { ioe.printStackTrace(); } } finally { - if (in != null) try { in.close(); } catch (IOException ioe) {} + if (in != null) { + try { + in.close(); + } catch (IOException ioe) { // nop + } + } } } diff --git a/core/java/src/net/i2p/util/OrderedProperties.java b/core/java/src/net/i2p/util/OrderedProperties.java index 5d2d1aaa1f..d65a423960 100644 --- a/core/java/src/net/i2p/util/OrderedProperties.java +++ b/core/java/src/net/i2p/util/OrderedProperties.java @@ -69,9 +69,9 @@ public class OrderedProperties extends Properties { synchronized (_lock) { return _data.equals(obj); } - } else { - return false; - } + } + + return false; } public int hashCode() { @@ -96,10 +96,9 @@ public class OrderedProperties extends Properties { if (key == null) return null; synchronized (_lock) { Object rv = _data.get(key); - if ((rv != null) && (rv instanceof String)) - return (String) rv; - else - return null; + if ((rv != null) && (rv instanceof String)) return (String) rv; + + return null; } } @@ -191,17 +190,17 @@ public class OrderedProperties extends Properties { return Collections.enumeration(keySet()); } - public void list(PrintStream out) { + public void list(PrintStream out) { // nop } - public void list(PrintWriter out) { + public void list(PrintWriter out) { // nop } - public void load(InputStream in) { + public void load(InputStream in) { // nop } //public void save(OutputStream out, String header) {} - public void store(OutputStream out, String header) { + public void store(OutputStream out, String header) { // nop } private Set buildEntrySet(Set data) { -- GitLab