From 84990d9d43abb083dc602d9f081be83fab06b23a Mon Sep 17 00:00:00 2001 From: dev <dev@welterde.de> Date: Thu, 17 Feb 2011 10:45:35 +0000 Subject: [PATCH] minor changes --- .../client/datagram/I2PDatagramDissector.java | 11 +++++------ .../i2p/client/datagram/I2PDatagramMaker.java | 8 ++++---- .../i2p/internal/QueuedI2CPMessageReader.java | 19 +++++++++++++++---- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java b/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java index 4748e74950..864fc1e56e 100644 --- a/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java +++ b/core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java @@ -30,10 +30,10 @@ public final class I2PDatagramDissector { private static Log _log = new Log(I2PDatagramDissector.class); - private static int DGRAM_BUFSIZE = 32768; + private static final int DGRAM_BUFSIZE = 32768; - private DSAEngine dsaEng = DSAEngine.getInstance(); - private SHA256Generator hashGen = SHA256Generator.getInstance(); + private final DSAEngine dsaEng = DSAEngine.getInstance(); + private final SHA256Generator hashGen = SHA256Generator.getInstance(); private Hash rxHash = null; @@ -41,7 +41,7 @@ public final class I2PDatagramDissector { private Destination rxDest; - private byte[] rxPayload = new byte[DGRAM_BUFSIZE]; + private final byte[] rxPayload = new byte[DGRAM_BUFSIZE]; private int rxPayloadLen = 0; @@ -189,8 +189,7 @@ public final class I2PDatagramDissector { if(this.valid) return; - if (rxSign == null || rxSign.getData() == null || - rxDest == null || rxDest.getSigningPublicKey() == null) + if (rxSign == null || rxSign.getData() == null || rxDest == null || rxDest.getSigningPublicKey() == null) throw new I2PInvalidDatagramException("Datagram not yet read"); // now validate diff --git a/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java b/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java index e66b7f7567..4de311c5f3 100644 --- a/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java +++ b/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java @@ -28,15 +28,15 @@ public final class I2PDatagramMaker { private static Log _log = new Log(I2PDatagramMaker.class); - private static int DGRAM_BUFSIZE = 32768; + private static final int DGRAM_BUFSIZE = 32768; - private SHA256Generator hashGen = SHA256Generator.getInstance(); - private DSAEngine dsaEng = DSAEngine.getInstance(); + private final SHA256Generator hashGen = SHA256Generator.getInstance(); + private final DSAEngine dsaEng = DSAEngine.getInstance(); private SigningPrivateKey sxPrivKey = null; private byte[] sxDestBytes = null; - private ByteArrayOutputStream sxDGram = new ByteArrayOutputStream(DGRAM_BUFSIZE); + private final ByteArrayOutputStream sxDGram = new ByteArrayOutputStream(DGRAM_BUFSIZE); /** * Construct a new I2PDatagramMaker that will be able to create I2P diff --git a/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java b/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java index 86f82241be..4b14d5ed8c 100644 --- a/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java +++ b/core/java/src/net/i2p/internal/QueuedI2CPMessageReader.java @@ -5,7 +5,7 @@ import net.i2p.data.i2cp.I2CPMessageReader; import net.i2p.util.I2PThread; /** - * Get messages off an In-JVM queue, zero-copy + * Get messages off an In-JVM queue, zero-copy. * * @author zzz * @since 0.8.3 @@ -13,6 +13,9 @@ import net.i2p.util.I2PThread; public class QueuedI2CPMessageReader extends I2CPMessageReader { private final I2CPMessageQueue in; + /** + * Creates a new instance of this QueuedMessageReader and spawns a pumper thread. + */ public QueuedI2CPMessageReader(I2CPMessageQueue in, I2CPMessageEventListener lsnr) { super(lsnr); this.in = in; @@ -25,13 +28,19 @@ public class QueuedI2CPMessageReader extends I2CPMessageReader { public QueuedI2CPMessageReaderRunner() { super(); } - + + /** + * Shuts the pumper down. + */ @Override public void cancelRunner() { super.cancelRunner(); _readerThread.interrupt(); } - + + /** + * Pumps messages from the incoming message queue to the listener. + */ @Override public void run() { while (_stayAlive) { @@ -46,7 +55,9 @@ public class QueuedI2CPMessageReader extends I2CPMessageReader { } else { _listener.messageReceived(QueuedI2CPMessageReader.this, msg); } - } catch (InterruptedException ie) {} + } catch (InterruptedException ie) { + // hint that we probably should check the continue running flag + } } // ??? unused if (_stayAlive && !_doRun) { -- GitLab