From d2b32bc75447bf72df804af66c73b9a4242c97f3 Mon Sep 17 00:00:00 2001 From: slumlord Date: Mon, 6 Aug 2018 10:08:44 +0000 Subject: [PATCH 01/12] PeerState patched for CachedIteratorAbstractCollection; With branch 'i2p.i2p.slumlord' this time --- .../src/net/i2p/router/transport/udp/PeerState.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/udp/PeerState.java b/router/java/src/net/i2p/router/transport/udp/PeerState.java index 9d8e136a1..d4ecee104 100644 --- a/router/java/src/net/i2p/router/transport/udp/PeerState.java +++ b/router/java/src/net/i2p/router/transport/udp/PeerState.java @@ -11,14 +11,12 @@ import java.util.Map; import java.util.Set; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.atomic.AtomicInteger; import net.i2p.data.Hash; import net.i2p.data.SessionKey; import net.i2p.router.OutNetMessage; import net.i2p.router.RouterContext; -import net.i2p.router.util.CachedIteratorArrayList; -import net.i2p.router.util.CoDelPriorityBlockingQueue; +import net.i2p.router.util.CachedIteratorAbstractCollection; import net.i2p.router.util.PriBlockingQueue; import net.i2p.util.Log; import net.i2p.util.ConcurrentHashSet; @@ -210,7 +208,7 @@ public class PeerState { * Mostly messages that have been transmitted and are awaiting acknowledgement, * although there could be some that have not been sent yet. */ - private final List _outboundMessages; + private final CachedIteratorAbstractCollection _outboundMessages; /** * Priority queue of messages that have not yet been sent. @@ -370,7 +368,7 @@ public class PeerState { _rtt = INIT_RTT; _rttDeviation = _rtt; _inboundMessages = new HashMap(8); - _outboundMessages = new CachedIteratorArrayList(32); + _outboundMessages = new CachedIteratorAbstractCollection(); //_outboundQueue = new CoDelPriorityBlockingQueue(ctx, "UDP-PeerState", 32); _outboundQueue = new PriBlockingQueue(ctx, "UDP-PeerState", 32); // all createRateStat() moved to EstablishmentManager @@ -1568,7 +1566,7 @@ public class PeerState { if (_dead) { dropOutbound(); return 0; - } + } int rv = 0; List succeeded = null; @@ -1586,6 +1584,7 @@ public class PeerState { iter.remove(); if (_retransmitter == state) _retransmitter = null; + _log.debug("CachedIteratorAbstractCollection: sendFailed update" + state); _context.statManager().addRateData("udp.sendFailed", state.getPushCount()); if (failed == null) failed = new ArrayList(4); failed.add(state); @@ -1593,6 +1592,7 @@ public class PeerState { iter.remove(); if (state == _retransmitter) _retransmitter = null; + _log.debug("CachedIteratorAbstractCollection: sendAggressiveFailed update" + state); _context.statManager().addRateData("udp.sendAggressiveFailed", state.getPushCount()); if (failed == null) failed = new ArrayList(4); failed.add(state); From 7084c86e76d4f22b93f0652f836f3e83becb51b4 Mon Sep 17 00:00:00 2001 From: slumlord Date: Mon, 6 Aug 2018 15:08:41 +0000 Subject: [PATCH 02/12] Update CachedIteratorCollection javadocs --- .idea/compiler.xml | 53 +++++++++++++------ .idea/modules.xml | 53 +++++++++++++++++++ .../router/util/CachedIteratorCollection.java | 34 ++++++------ 3 files changed, 108 insertions(+), 32 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 96cc43efa..46d39593e 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,22 +1,41 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 3e5d2de7a..12768205c 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,25 +2,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/router/java/src/net/i2p/router/util/CachedIteratorCollection.java b/router/java/src/net/i2p/router/util/CachedIteratorCollection.java index 84570882d..6038dd67d 100644 --- a/router/java/src/net/i2p/router/util/CachedIteratorCollection.java +++ b/router/java/src/net/i2p/router/util/CachedIteratorCollection.java @@ -1,8 +1,4 @@ -// Extend `java.util.AbstractCollection` to create a collection that can be iterated over without creation of a new -// object - -// https://docs.oracle.com/javase/7/docs/api/java/util/AbstractCollection.html - +// The Node class below is derived from Java's LinkedList.java /* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,7 +23,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -// The Node class below is from Java's LinkedList.java package net.i2p.router.util; @@ -38,6 +33,14 @@ import java.util.NoSuchElementException; import net.i2p.I2PAppContext; import net.i2p.util.Log; +/** + * Extend java.util.AbstractCollection to create a collection that can be + * iterated over without creation of a new object + * + * @since 0.9.36 + * + */ + public class CachedIteratorCollection extends AbstractCollection { // FOR DEBUGGING & LOGGING PURPOSES @@ -60,18 +63,18 @@ public class CachedIteratorCollection extends AbstractCollection { Node next; Node prev; - Node(Node prev, E element, Node next) { + Node(Node prev, E element) { this.item = element; this.prev = prev; - this.next = next; + this.next = null; } } // First Node in the AbstractCollectionTest object - private transient Node first; + private transient Node first = null; // Last Node in the AbstractCollectionTest object - private transient Node last; + private transient Node last = null; /** * Default constructor @@ -85,14 +88,13 @@ public class CachedIteratorCollection extends AbstractCollection { */ @Override public boolean add(E element) { + final Node newNode = new Node<>(null, element); if (this.size == 0) { - final Node newNode = new Node<>(null, element, null); this.first = newNode; this.last = newNode; } else { - final Node newLast = new Node<>(this.last, element, null); - this.last.next = newLast; - this.last = newLast; + this.last.next = newNode; + this.last = newNode; } this.size++; log.debug("CachedIteratorAbstractCollection: Element added"); @@ -205,5 +207,7 @@ public class CachedIteratorCollection extends AbstractCollection { /** * Return size of current LinkedListTest object */ - public int size() { return this.size; } + public int size() { + return this.size; + } } From 57fee62557c0d4c863a1c009c019ca2654d4a702 Mon Sep 17 00:00:00 2001 From: slumlord Date: Mon, 6 Aug 2018 15:13:41 +0000 Subject: [PATCH 03/12] Fix PeerState --- .../src/net/i2p/router/transport/udp/PeerState.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/udp/PeerState.java b/router/java/src/net/i2p/router/transport/udp/PeerState.java index d4ecee104..8a5dd9224 100644 --- a/router/java/src/net/i2p/router/transport/udp/PeerState.java +++ b/router/java/src/net/i2p/router/transport/udp/PeerState.java @@ -16,7 +16,7 @@ import net.i2p.data.Hash; import net.i2p.data.SessionKey; import net.i2p.router.OutNetMessage; import net.i2p.router.RouterContext; -import net.i2p.router.util.CachedIteratorAbstractCollection; +import net.i2p.router.util.CachedIteratorCollection; import net.i2p.router.util.PriBlockingQueue; import net.i2p.util.Log; import net.i2p.util.ConcurrentHashSet; @@ -208,7 +208,7 @@ public class PeerState { * Mostly messages that have been transmitted and are awaiting acknowledgement, * although there could be some that have not been sent yet. */ - private final CachedIteratorAbstractCollection _outboundMessages; + private final CachedIteratorCollection _outboundMessages; /** * Priority queue of messages that have not yet been sent. @@ -368,7 +368,7 @@ public class PeerState { _rtt = INIT_RTT; _rttDeviation = _rtt; _inboundMessages = new HashMap(8); - _outboundMessages = new CachedIteratorAbstractCollection(); + _outboundMessages = new CachedIteratorCollection(); //_outboundQueue = new CoDelPriorityBlockingQueue(ctx, "UDP-PeerState", 32); _outboundQueue = new PriBlockingQueue(ctx, "UDP-PeerState", 32); // all createRateStat() moved to EstablishmentManager @@ -1584,7 +1584,7 @@ public class PeerState { iter.remove(); if (_retransmitter == state) _retransmitter = null; - _log.debug("CachedIteratorAbstractCollection: sendFailed update" + state); + _log.debug("CachedIteratorCollection: sendFailed update" + state); _context.statManager().addRateData("udp.sendFailed", state.getPushCount()); if (failed == null) failed = new ArrayList(4); failed.add(state); @@ -1592,7 +1592,7 @@ public class PeerState { iter.remove(); if (state == _retransmitter) _retransmitter = null; - _log.debug("CachedIteratorAbstractCollection: sendAggressiveFailed update" + state); + _log.debug("CachedIteratorCollection: sendAggressiveFailed update" + state); _context.statManager().addRateData("udp.sendAggressiveFailed", state.getPushCount()); if (failed == null) failed = new ArrayList(4); failed.add(state); From 5a6ee17f3c655ff87e80904d01f960f3141c4aa9 Mon Sep 17 00:00:00 2001 From: slumlord Date: Tue, 7 Aug 2018 08:28:16 +0000 Subject: [PATCH 04/12] CachedIteratorCollection - Fix bug in add() function Add comments for remove() function --- .../router/util/CachedIteratorCollection.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/router/java/src/net/i2p/router/util/CachedIteratorCollection.java b/router/java/src/net/i2p/router/util/CachedIteratorCollection.java index 6038dd67d..163edabe8 100644 --- a/router/java/src/net/i2p/router/util/CachedIteratorCollection.java +++ b/router/java/src/net/i2p/router/util/CachedIteratorCollection.java @@ -88,7 +88,7 @@ public class CachedIteratorCollection extends AbstractCollection { */ @Override public boolean add(E element) { - final Node newNode = new Node<>(null, element); + final Node newNode = new Node<>(last, element); if (this.size == 0) { this.first = newNode; this.last = newNode; @@ -152,28 +152,41 @@ public class CachedIteratorCollection extends AbstractCollection { @Override public void remove() { if (nextCalled) { + // Are we at the end of the collection? If so itrIndexNode will + // be null if (itrIndexNode != null) { - if (itrIndexNode.prev.prev != null) { + // The Node we are trying to remove is itrIndexNode.prev + // Is there a Node before itrIndexNode.prev? + //if (itrIndexNode.prev != null && itrIndexNode.prev.prev != null) { + if (itrIndexNode != first.next) { + // Set current itrIndexNode's prev to Node N-2 itrIndexNode.prev = itrIndexNode.prev.prev; + // Then set Node N-2's next to current itrIndexNode, + // this drops all references to the Node being removed itrIndexNode.prev.next = itrIndexNode; } else { + // There is no N-2 Node, we are removing the first Node + // in the collection itrIndexNode.prev = null; first = itrIndexNode; } } else { + // itrIndexNode is null, we are at the end of the collection + // Are there any items before the Node that is being removed? if (last.prev != null) { last.prev.next = null; last = last.prev; } else { + // There are no more items, clear() the collection nextCalled = false; clear(); - log.debug("CachedIteratorAbstractCollection: Element Removed"); + //log.debug("CachedIteratorAbstractCollection: Element Removed"); return; } } size--; nextCalled = false; - log.debug("CachedIteratorAbstractCollection: Element Removed"); + //log.debug("CachedIteratorAbstractCollection: Element Removed"); } else { throw new IllegalStateException(); } From 733d3496a993d1d852734b8f135bd30331575f65 Mon Sep 17 00:00:00 2001 From: slumlord Date: Tue, 7 Aug 2018 10:15:27 +0000 Subject: [PATCH 05/12] Append "-sl" to version string --- router/java/src/net/i2p/router/RouterVersion.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 9319fc01c..abd359fe7 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -21,7 +21,7 @@ public class RouterVersion { public final static long BUILD = 22; /** for example "-test" */ - public final static String EXTRA = ""; + public final static String EXTRA = "-sl"; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public static void main(String args[]) { System.out.println("I2P Router version: " + FULL_VERSION); From f9d5d48a4d70dc4ac7bdcb51c3fd400f2e833497 Mon Sep 17 00:00:00 2001 From: slumlord Date: Tue, 7 Aug 2018 12:04:31 +0000 Subject: [PATCH 06/12] Clean up code --- .../net/i2p/router/util/CachedIteratorCollection.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/router/java/src/net/i2p/router/util/CachedIteratorCollection.java b/router/java/src/net/i2p/router/util/CachedIteratorCollection.java index 163edabe8..1f46d0ab5 100644 --- a/router/java/src/net/i2p/router/util/CachedIteratorCollection.java +++ b/router/java/src/net/i2p/router/util/CachedIteratorCollection.java @@ -44,7 +44,7 @@ import net.i2p.util.Log; public class CachedIteratorCollection extends AbstractCollection { // FOR DEBUGGING & LOGGING PURPOSES - Log log = I2PAppContext.getGlobalContext().logManager().getLog(CachedIteratorCollection.class); + //Log log = I2PAppContext.getGlobalContext().logManager().getLog(CachedIteratorCollection.class); // Cached Iterator object private final CachedIterator iterator = new CachedIterator(); @@ -91,13 +91,12 @@ public class CachedIteratorCollection extends AbstractCollection { final Node newNode = new Node<>(last, element); if (this.size == 0) { this.first = newNode; - this.last = newNode; } else { this.last.next = newNode; - this.last = newNode; } + this.last = newNode; this.size++; - log.debug("CachedIteratorAbstractCollection: Element added"); + //log.debug("CachedIteratorAbstractCollection: Element added"); return true; } @@ -111,7 +110,7 @@ public class CachedIteratorCollection extends AbstractCollection { this.last = null; this.size = 0; iterator.reset(); - log.debug("CachedIteratorAbstractCollection: Cleared"); + //log.debug("CachedIteratorAbstractCollection: Cleared"); } /** @@ -157,7 +156,6 @@ public class CachedIteratorCollection extends AbstractCollection { if (itrIndexNode != null) { // The Node we are trying to remove is itrIndexNode.prev // Is there a Node before itrIndexNode.prev? - //if (itrIndexNode.prev != null && itrIndexNode.prev.prev != null) { if (itrIndexNode != first.next) { // Set current itrIndexNode's prev to Node N-2 itrIndexNode.prev = itrIndexNode.prev.prev; From a40ff5f52829399fd6bcffe873bd3693ba94e43e Mon Sep 17 00:00:00 2001 From: slumlord Date: Mon, 13 Aug 2018 08:33:45 +0000 Subject: [PATCH 07/12] Add CachedIteratorCollectionTest - junit tests for CachedIteratorCollection --- .../util/CachedIteratorCollectionTest.java | 799 ++++++++++++++++++ 1 file changed, 799 insertions(+) create mode 100644 router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java diff --git a/router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java b/router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java new file mode 100644 index 000000000..6b8d4689b --- /dev/null +++ b/router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java @@ -0,0 +1,799 @@ +package net.i2p.router.util; + +import static org.junit.Assert.*; +import org.junit.Test; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.ArrayList; +import java.util.NoSuchElementException; + +/* when using with JUnit5+Idea +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.DisplayName; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.fail; +*/ + + + +/** + * A set of tests to ensure that the CachedIteratorCollection class is + * functioning as intended + */ + +public class CachedIteratorCollectionTest { + + /* Add n-number of objects to the given CachedIteratorCollection object + * + */ + private void AddNObjects(CachedIteratorCollection a, int n) { + if (n > 0) { + for (int j = 0; j < n; j++) { + String s = "test" + j; + a.add(s); + } + } else { + throw new UnsupportedOperationException("Please use a positive integer"); + } + } + + private void AddNObjectsLL(LinkedList a, int n) { + if (n > 0) { + for (int j = 0; j < n; j++) { + String s = "test" + j; + a.add(s); + } + } else { + throw new UnsupportedOperationException("Please use a positive integer"); + } + } + + //@DisplayName("Add 1 Element Test") + @Test + public void Add1Test() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 1); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + while(testCollection1Itr.hasNext()) { + testString += testCollection1Itr.next(); + } + + assertEquals("test0", testString); + assertEquals(1, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 1); + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + while(testCollection2Itr.hasNext()) { + testString += testCollection2Itr.next(); + } + + assertEquals("test0", testString); + assertEquals(1, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } + + //@DisplayName("Add 10 Elements Test") + @Test + public void Add10Test() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + while(testCollection1Itr.hasNext()) { + testString += testCollection1Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList OBject + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + while(testCollection2Itr.hasNext()) { + testString += testCollection2Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } + + //@DisplayName("AddAll() Test") + @Test + public void AddAll() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + ArrayList stringArrayList = new ArrayList<>(); + + for (int i = 0; i < 10; i++) { + String s = "test" + i; + stringArrayList.add(s); + } + + testCollection1.addAll(stringArrayList); + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + String testString = ""; + + while(testCollection1Itr.hasNext()) { + testString += testCollection1Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + stringArrayList = new ArrayList<>(); + + for (int i = 0; i < 10; i++) { + String s = "test" + i; + stringArrayList.add(s); + } + + testCollection2.addAll(stringArrayList); + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + testString = ""; + + while(testCollection2Itr.hasNext()) { + testString += testCollection2Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } + + //@DisplayName("Single Element Remove Test - Size 1 Collection") + @Test + public void SingleRemove() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 1); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + while(testCollection1Itr.hasNext()) { + testString += testCollection1Itr.next(); + testCollection1Itr.remove(); + } + + assertEquals("test0", testString); + assertEquals(0, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertTrue(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 1); + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + while(testCollection2Itr.hasNext()) { + testString += testCollection2Itr.next(); + testCollection2Itr.remove(); + } + + assertEquals("test0", testString); + assertEquals(0, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertTrue(testCollection2.isEmpty()); + } + + //@DisplayName("Single Element Remove From Start Test - Size 10 Collection") + @Test + public void RemoveFromStart() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + String s = ""; + while (testCollection1Itr.hasNext()) { + s = testCollection1Itr.next(); + if (s.equals("test0")) { + testCollection1Itr.remove(); + } else { + testString += s; + } + } + + assertEquals("test1test2test3test4test5test6test7test8test9", testString); + assertEquals(9, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + s = ""; + while (testCollection2Itr.hasNext()) { + s = testCollection2Itr.next(); + if (s.equals("test0")) { + testCollection2Itr.remove(); + } else { + testString += s; + } + } + + assertEquals("test1test2test3test4test5test6test7test8test9", testString); + assertEquals(9, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } + + //@DisplayName("Single Element Remove From Middle Test") + @Test + public void RemoveFromMiddle() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + String s = ""; + while (testCollection1Itr.hasNext()) { + s = testCollection1Itr.next(); + if (s.equals("test5")) { + testCollection1Itr.remove(); + } else { + testString += s; + } + } + + assertEquals("test0test1test2test3test4test6test7test8test9", testString); + assertEquals(9, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + s = ""; + while (testCollection2Itr.hasNext()) { + s = testCollection2Itr.next(); + if (s.equals("test5")) { + testCollection2Itr.remove(); + } else { + testString += s; + } + } + + assertEquals("test0test1test2test3test4test6test7test8test9", testString); + assertEquals(9, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } + + //@DisplayName("Multiple Elements Remove From Middle Test") + @Test + public void RemoveMultipleFromMiddle() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + String s = ""; + while (testCollection1Itr.hasNext()) { + s = testCollection1Itr.next(); + if (s.equals("test5") || s.equals("test6")) { + testCollection1Itr.remove(); + } else { + testString += s; + } + } + + assertEquals("test0test1test2test3test4test7test8test9", testString); + assertEquals(8, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + s = ""; + while (testCollection2Itr.hasNext()) { + s = testCollection2Itr.next(); + if (s.equals("test5") || s.equals("test6")) { + testCollection2Itr.remove(); + } else { + testString += s; + } + } + + assertEquals(8, testCollection2.size()); + assertEquals("test0test1test2test3test4test7test8test9", testString); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } + + //@DisplayName("Single Element Remove From End Test") + @Test + public void RemoveFromEnd() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + String s = ""; + while (testCollection1Itr.hasNext()) { + s = testCollection1Itr.next(); + if (s.equals("test9")) { + testCollection1Itr.remove(); + } else { + testString += s; + } + } + + assertEquals("test0test1test2test3test4test5test6test7test8", testString); + assertEquals(9, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + s = ""; + while (testCollection2Itr.hasNext()) { + s = testCollection2Itr.next(); + if (s.equals("test9")) { + testCollection2Itr.remove(); + } else { + testString += s; + } + } + + assertEquals(9, testCollection2.size()); + assertEquals("test0test1test2test3test4test5test6test7test8", testString); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } + + //@DisplayName("Remove All - Size 10 Collection") + @Test + public void RemoveAll() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + assertEquals(10, testCollection1.size()); + assertTrue(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Remove all test + while (testCollection1Itr.hasNext()) { + testCollection1Itr.next(); + testCollection1Itr.remove(); + } + + assertEquals(0, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertTrue(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + assertEquals(10, testCollection2.size()); + assertTrue(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + + // Remove all test + while (testCollection2Itr.hasNext()) { + testCollection2Itr.next(); + testCollection2Itr.remove(); + } + + assertEquals(0, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertTrue(testCollection2.isEmpty()); + } + + //@DisplayName("Test Iterator Equality/Inequality") + @Test + public void Equality() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + Iterator testCollection1Itr1 = testCollection1.iterator(); + Iterator testCollection1Itr2 = testCollection1.iterator(); + Iterator testCollection1Itr3 = testCollection1.iterator(); + Iterator testCollection1Itr4 = testCollection1.iterator(); + + assertSame(testCollection1Itr1,testCollection1Itr2); + assertSame(testCollection1Itr2,testCollection1Itr3); + assertSame(testCollection1Itr3,testCollection1Itr4); + + // LinkedList object's iterator should return different objects + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + Iterator testCollection2Itr1 = testCollection2.iterator(); + Iterator testCollection2Itr2 = testCollection2.iterator(); + Iterator testCollection2Itr3 = testCollection2.iterator(); + Iterator testCollection2Itr4 = testCollection2.iterator(); + + assertNotSame(testCollection2Itr1,testCollection2Itr2); + assertNotSame(testCollection2Itr2,testCollection2Itr3); + assertNotSame(testCollection2Itr3,testCollection2Itr4); + } + + //@DisplayName("Restart Iterator Test") + @Test + public void Restart() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + String s = ""; + while(testCollection1Itr.hasNext()) { + testString += testCollection1Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Restart Iterator + testCollection1Itr = testCollection1.iterator(); + + assertTrue("test0".equals(testCollection1Itr.next())); + assertEquals(10, testCollection1.size()); + assertTrue(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + while(testCollection2Itr.hasNext()) { + testString += testCollection2Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + + // Restart Iterator + testCollection2Itr = testCollection2.iterator(); + + assertEquals(10, testCollection2.size()); + assertTrue("test0".equals(testCollection2Itr.next())); + assertTrue(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + + } + + //@DisplayName("Clear Test") + @Test + public void Clear() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + + String testString = ""; + + // Iterator test + Iterator testCollection1Itr = testCollection1.iterator(); + + assertEquals(10, testCollection1.size()); + assertTrue(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Clear + testCollection1.clear(); + + assertEquals(0, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertTrue(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + + testString = ""; + + // Iterator test + Iterator testCollection2Itr = testCollection2.iterator(); + + assertEquals(10, testCollection2.size()); + assertFalse(testCollection2.isEmpty()); + assertTrue(testCollection2Itr.hasNext()); + + // Clear + testCollection2.clear(); + + assertEquals(0, testCollection2.size()); + assertTrue(testCollection2.isEmpty()); + assertFalse(testCollection2Itr.hasNext()); + } + + //@DisplayName("Remove Twice Before next() Test") + @Test + public void RemoveTwice() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + + Iterator testCollection1Itr = testCollection1.iterator(); + testCollection1Itr.next(); + testCollection1Itr.remove(); + testCollection1Itr.next(); + testCollection1Itr.remove(); + + /* Junit5 + java8+ + assertThrows(IllegalStateException.class, () -> { + // Remove called once more here before a next() + testCollection1Itr.remove(); + }); + */ + + try { + testCollection1Itr.remove(); + fail("Exception should be caught; This should not print."); + } catch (IllegalStateException e) { + System.out.println("RemoveTwice()+CachedIteratorCollection: IllegalStateException caught successfully." + e); + } + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + + Iterator testCollection2Itr = testCollection2.iterator(); + testCollection2Itr.next(); + testCollection2Itr.remove(); + testCollection2Itr.next(); + testCollection2Itr.remove(); + + /* Junit5 + java8+ + assertThrows(IllegalStateException.class, () -> { + // Remove called once more here before a next() + testCollection2Itr.remove(); + }); + */ + + try { + testCollection2Itr.remove(); + fail("Exception should be caught; This should not print."); + } catch (IllegalStateException e) { + System.out.println("RemoveTwice()+LinkedList: IllegalStateException caught successfully." + e); + } + } + + //@DisplayName("next() When No Elements Left Test") + @Test + public void NextWhenNone() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + + Iterator testCollection1Itr = testCollection1.iterator(); + + while(testCollection1Itr.hasNext()) { + testCollection1Itr.next(); + } + + assertEquals(10, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + /* JUnit5 java8+ + // next() should throw an exception as there are no more nodes + assertThrows(NoSuchElementException.class, () -> { testCollection1Itr.next(); }); + */ + + try { + testCollection1Itr.next(); + fail("Exception should be caught; This should not print."); + } catch (NoSuchElementException e) { + System.out.println("NextWhenNone()+CachedIteratorCollection: NoSuchElementException caught successfully." + e); + } + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + + Iterator testCollection2Itr = testCollection2.iterator(); + + while(testCollection2Itr.hasNext()) { + testCollection2Itr.next(); + } + + assertEquals(10, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + /* JUnit5 java8+ + // next() should throw an exception as there are no more nodes + assertThrows(NoSuchElementException.class, () -> { testCollection2Itr.next(); }); + */ + + try { + testCollection2Itr.next(); + fail("Exception should be caught; This should not print."); + } catch (NoSuchElementException e) { + System.out.println("NextWhenNone()+LinkedList: NoSuchElementException caught successfully." + e); + } + } + + //@DisplayName("Add, Remove All and Add Again Test") + @Test + public void ReAdd() { + CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); + + AddNObjects(testCollection1, 10); + + Iterator testCollection1Itr = testCollection1.iterator(); + + String testString = ""; + + while (testCollection1Itr.hasNext()) { + testString += testCollection1Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection1.size()); + + // Reset and remove all + testCollection1Itr = testCollection1.iterator(); + + while(testCollection1Itr.hasNext()) { + testCollection1Itr.next(); + testCollection1Itr.remove(); + } + + assertEquals(0, testCollection1.size()); + assertFalse(testCollection1Itr.hasNext()); + assertTrue(testCollection1.isEmpty()); + + // Re-add + AddNObjects(testCollection1, 10); + testCollection1Itr = testCollection1.iterator(); + + assertEquals(10, testCollection1.size()); + assertTrue("test0".equals(testCollection1Itr.next())); + assertTrue(testCollection1Itr.hasNext()); + assertFalse(testCollection1.isEmpty()); + + // Compare behavior with LinkedList object + LinkedList testCollection2 = new LinkedList<>(); + + AddNObjectsLL(testCollection2, 10); + + Iterator testCollection2Itr = testCollection2.iterator(); + + testString = ""; + + while (testCollection2Itr.hasNext()) { + testString += testCollection2Itr.next(); + } + + assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); + assertEquals(10, testCollection2.size()); + + testCollection2Itr = testCollection2.iterator(); + + while(testCollection2Itr.hasNext()) { + testCollection2Itr.next(); + testCollection2Itr.remove(); + } + + assertEquals(0, testCollection2.size()); + assertFalse(testCollection2Itr.hasNext()); + assertTrue(testCollection2.isEmpty()); + + // Re-add + AddNObjectsLL(testCollection2, 10); + testCollection2Itr = testCollection2.iterator(); + + assertEquals(10, testCollection2.size()); + assertTrue("test0".equals(testCollection2Itr.next())); + assertTrue(testCollection2Itr.hasNext()); + assertFalse(testCollection2.isEmpty()); + } +} From 5b114f4bf302fbd9ff7a88373ce4b0d453870903 Mon Sep 17 00:00:00 2001 From: slumlord Date: Fri, 17 Aug 2018 08:37:03 +0000 Subject: [PATCH 08/12] Removing files temporarily to allow for propagation from i2p.i2p branch --- .../net/i2p/crypto/SU3FileSpec.scala | 2 +- .../src/net/i2p/router/RouterVersion.java | 32 - .../util/CachedIteratorCollectionTest.java | 799 ------------------ 3 files changed, 1 insertion(+), 832 deletions(-) delete mode 100644 router/java/src/net/i2p/router/RouterVersion.java delete mode 100644 router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java diff --git a/core/java/test/scalatest/net/i2p/crypto/SU3FileSpec.scala b/core/java/test/scalatest/net/i2p/crypto/SU3FileSpec.scala index a694631c1..a75bd0f2f 100644 --- a/core/java/test/scalatest/net/i2p/crypto/SU3FileSpec.scala +++ b/core/java/test/scalatest/net/i2p/crypto/SU3FileSpec.scala @@ -27,4 +27,4 @@ class SU3FileSpec extends FunSpec with Matchers { cheater("verifySigCLI", (seedFile.getAbsolutePath, classOf[String]), (certFile.getAbsolutePath, classOf[String])) } } -} \ No newline at end of file +} diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java deleted file mode 100644 index fa526f026..000000000 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.i2p.router; -/* - * free (adj.): unencumbered; not under the control of others - * Written by jrandom in 2003 and released into the public domain - * with no warranty of any kind, either expressed or implied. - * It probably won't make your computer catch on fire, or eat - * your children, but it might. Use at your own risk. - * - */ - -import net.i2p.CoreVersion; - -/** - * Expose a version string - * - */ -public class RouterVersion { - /** deprecated */ - public final static String ID = "Monotone"; - public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 23; - - /** for example "-test" */ - public final static String EXTRA = "-rc-sl"; - public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; - public static void main(String args[]) { - System.out.println("I2P Router version: " + FULL_VERSION); - System.out.println("Router ID: " + RouterVersion.ID); - System.out.println("I2P Core version: " + CoreVersion.VERSION); - System.out.println("Core ID: " + CoreVersion.ID); - } -} diff --git a/router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java b/router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java deleted file mode 100644 index 6b8d4689b..000000000 --- a/router/java/test/junit/net/i2p/router/util/CachedIteratorCollectionTest.java +++ /dev/null @@ -1,799 +0,0 @@ -package net.i2p.router.util; - -import static org.junit.Assert.*; -import org.junit.Test; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.ArrayList; -import java.util.NoSuchElementException; - -/* when using with JUnit5+Idea -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.DisplayName; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.fail; -*/ - - - -/** - * A set of tests to ensure that the CachedIteratorCollection class is - * functioning as intended - */ - -public class CachedIteratorCollectionTest { - - /* Add n-number of objects to the given CachedIteratorCollection object - * - */ - private void AddNObjects(CachedIteratorCollection a, int n) { - if (n > 0) { - for (int j = 0; j < n; j++) { - String s = "test" + j; - a.add(s); - } - } else { - throw new UnsupportedOperationException("Please use a positive integer"); - } - } - - private void AddNObjectsLL(LinkedList a, int n) { - if (n > 0) { - for (int j = 0; j < n; j++) { - String s = "test" + j; - a.add(s); - } - } else { - throw new UnsupportedOperationException("Please use a positive integer"); - } - } - - //@DisplayName("Add 1 Element Test") - @Test - public void Add1Test() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 1); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - while(testCollection1Itr.hasNext()) { - testString += testCollection1Itr.next(); - } - - assertEquals("test0", testString); - assertEquals(1, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 1); - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - while(testCollection2Itr.hasNext()) { - testString += testCollection2Itr.next(); - } - - assertEquals("test0", testString); - assertEquals(1, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } - - //@DisplayName("Add 10 Elements Test") - @Test - public void Add10Test() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - while(testCollection1Itr.hasNext()) { - testString += testCollection1Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList OBject - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - while(testCollection2Itr.hasNext()) { - testString += testCollection2Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } - - //@DisplayName("AddAll() Test") - @Test - public void AddAll() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - ArrayList stringArrayList = new ArrayList<>(); - - for (int i = 0; i < 10; i++) { - String s = "test" + i; - stringArrayList.add(s); - } - - testCollection1.addAll(stringArrayList); - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - String testString = ""; - - while(testCollection1Itr.hasNext()) { - testString += testCollection1Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - stringArrayList = new ArrayList<>(); - - for (int i = 0; i < 10; i++) { - String s = "test" + i; - stringArrayList.add(s); - } - - testCollection2.addAll(stringArrayList); - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - testString = ""; - - while(testCollection2Itr.hasNext()) { - testString += testCollection2Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } - - //@DisplayName("Single Element Remove Test - Size 1 Collection") - @Test - public void SingleRemove() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 1); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - while(testCollection1Itr.hasNext()) { - testString += testCollection1Itr.next(); - testCollection1Itr.remove(); - } - - assertEquals("test0", testString); - assertEquals(0, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertTrue(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 1); - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - while(testCollection2Itr.hasNext()) { - testString += testCollection2Itr.next(); - testCollection2Itr.remove(); - } - - assertEquals("test0", testString); - assertEquals(0, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertTrue(testCollection2.isEmpty()); - } - - //@DisplayName("Single Element Remove From Start Test - Size 10 Collection") - @Test - public void RemoveFromStart() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - String s = ""; - while (testCollection1Itr.hasNext()) { - s = testCollection1Itr.next(); - if (s.equals("test0")) { - testCollection1Itr.remove(); - } else { - testString += s; - } - } - - assertEquals("test1test2test3test4test5test6test7test8test9", testString); - assertEquals(9, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - s = ""; - while (testCollection2Itr.hasNext()) { - s = testCollection2Itr.next(); - if (s.equals("test0")) { - testCollection2Itr.remove(); - } else { - testString += s; - } - } - - assertEquals("test1test2test3test4test5test6test7test8test9", testString); - assertEquals(9, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } - - //@DisplayName("Single Element Remove From Middle Test") - @Test - public void RemoveFromMiddle() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - String s = ""; - while (testCollection1Itr.hasNext()) { - s = testCollection1Itr.next(); - if (s.equals("test5")) { - testCollection1Itr.remove(); - } else { - testString += s; - } - } - - assertEquals("test0test1test2test3test4test6test7test8test9", testString); - assertEquals(9, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - s = ""; - while (testCollection2Itr.hasNext()) { - s = testCollection2Itr.next(); - if (s.equals("test5")) { - testCollection2Itr.remove(); - } else { - testString += s; - } - } - - assertEquals("test0test1test2test3test4test6test7test8test9", testString); - assertEquals(9, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } - - //@DisplayName("Multiple Elements Remove From Middle Test") - @Test - public void RemoveMultipleFromMiddle() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - String s = ""; - while (testCollection1Itr.hasNext()) { - s = testCollection1Itr.next(); - if (s.equals("test5") || s.equals("test6")) { - testCollection1Itr.remove(); - } else { - testString += s; - } - } - - assertEquals("test0test1test2test3test4test7test8test9", testString); - assertEquals(8, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - s = ""; - while (testCollection2Itr.hasNext()) { - s = testCollection2Itr.next(); - if (s.equals("test5") || s.equals("test6")) { - testCollection2Itr.remove(); - } else { - testString += s; - } - } - - assertEquals(8, testCollection2.size()); - assertEquals("test0test1test2test3test4test7test8test9", testString); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } - - //@DisplayName("Single Element Remove From End Test") - @Test - public void RemoveFromEnd() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - String s = ""; - while (testCollection1Itr.hasNext()) { - s = testCollection1Itr.next(); - if (s.equals("test9")) { - testCollection1Itr.remove(); - } else { - testString += s; - } - } - - assertEquals("test0test1test2test3test4test5test6test7test8", testString); - assertEquals(9, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - s = ""; - while (testCollection2Itr.hasNext()) { - s = testCollection2Itr.next(); - if (s.equals("test9")) { - testCollection2Itr.remove(); - } else { - testString += s; - } - } - - assertEquals(9, testCollection2.size()); - assertEquals("test0test1test2test3test4test5test6test7test8", testString); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } - - //@DisplayName("Remove All - Size 10 Collection") - @Test - public void RemoveAll() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - assertEquals(10, testCollection1.size()); - assertTrue(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Remove all test - while (testCollection1Itr.hasNext()) { - testCollection1Itr.next(); - testCollection1Itr.remove(); - } - - assertEquals(0, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertTrue(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - assertEquals(10, testCollection2.size()); - assertTrue(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - - // Remove all test - while (testCollection2Itr.hasNext()) { - testCollection2Itr.next(); - testCollection2Itr.remove(); - } - - assertEquals(0, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertTrue(testCollection2.isEmpty()); - } - - //@DisplayName("Test Iterator Equality/Inequality") - @Test - public void Equality() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - Iterator testCollection1Itr1 = testCollection1.iterator(); - Iterator testCollection1Itr2 = testCollection1.iterator(); - Iterator testCollection1Itr3 = testCollection1.iterator(); - Iterator testCollection1Itr4 = testCollection1.iterator(); - - assertSame(testCollection1Itr1,testCollection1Itr2); - assertSame(testCollection1Itr2,testCollection1Itr3); - assertSame(testCollection1Itr3,testCollection1Itr4); - - // LinkedList object's iterator should return different objects - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - Iterator testCollection2Itr1 = testCollection2.iterator(); - Iterator testCollection2Itr2 = testCollection2.iterator(); - Iterator testCollection2Itr3 = testCollection2.iterator(); - Iterator testCollection2Itr4 = testCollection2.iterator(); - - assertNotSame(testCollection2Itr1,testCollection2Itr2); - assertNotSame(testCollection2Itr2,testCollection2Itr3); - assertNotSame(testCollection2Itr3,testCollection2Itr4); - } - - //@DisplayName("Restart Iterator Test") - @Test - public void Restart() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - String s = ""; - while(testCollection1Itr.hasNext()) { - testString += testCollection1Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Restart Iterator - testCollection1Itr = testCollection1.iterator(); - - assertTrue("test0".equals(testCollection1Itr.next())); - assertEquals(10, testCollection1.size()); - assertTrue(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - while(testCollection2Itr.hasNext()) { - testString += testCollection2Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - - // Restart Iterator - testCollection2Itr = testCollection2.iterator(); - - assertEquals(10, testCollection2.size()); - assertTrue("test0".equals(testCollection2Itr.next())); - assertTrue(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - - } - - //@DisplayName("Clear Test") - @Test - public void Clear() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - - String testString = ""; - - // Iterator test - Iterator testCollection1Itr = testCollection1.iterator(); - - assertEquals(10, testCollection1.size()); - assertTrue(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Clear - testCollection1.clear(); - - assertEquals(0, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertTrue(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - - testString = ""; - - // Iterator test - Iterator testCollection2Itr = testCollection2.iterator(); - - assertEquals(10, testCollection2.size()); - assertFalse(testCollection2.isEmpty()); - assertTrue(testCollection2Itr.hasNext()); - - // Clear - testCollection2.clear(); - - assertEquals(0, testCollection2.size()); - assertTrue(testCollection2.isEmpty()); - assertFalse(testCollection2Itr.hasNext()); - } - - //@DisplayName("Remove Twice Before next() Test") - @Test - public void RemoveTwice() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - - Iterator testCollection1Itr = testCollection1.iterator(); - testCollection1Itr.next(); - testCollection1Itr.remove(); - testCollection1Itr.next(); - testCollection1Itr.remove(); - - /* Junit5 + java8+ - assertThrows(IllegalStateException.class, () -> { - // Remove called once more here before a next() - testCollection1Itr.remove(); - }); - */ - - try { - testCollection1Itr.remove(); - fail("Exception should be caught; This should not print."); - } catch (IllegalStateException e) { - System.out.println("RemoveTwice()+CachedIteratorCollection: IllegalStateException caught successfully." + e); - } - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - - Iterator testCollection2Itr = testCollection2.iterator(); - testCollection2Itr.next(); - testCollection2Itr.remove(); - testCollection2Itr.next(); - testCollection2Itr.remove(); - - /* Junit5 + java8+ - assertThrows(IllegalStateException.class, () -> { - // Remove called once more here before a next() - testCollection2Itr.remove(); - }); - */ - - try { - testCollection2Itr.remove(); - fail("Exception should be caught; This should not print."); - } catch (IllegalStateException e) { - System.out.println("RemoveTwice()+LinkedList: IllegalStateException caught successfully." + e); - } - } - - //@DisplayName("next() When No Elements Left Test") - @Test - public void NextWhenNone() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - - Iterator testCollection1Itr = testCollection1.iterator(); - - while(testCollection1Itr.hasNext()) { - testCollection1Itr.next(); - } - - assertEquals(10, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - /* JUnit5 java8+ - // next() should throw an exception as there are no more nodes - assertThrows(NoSuchElementException.class, () -> { testCollection1Itr.next(); }); - */ - - try { - testCollection1Itr.next(); - fail("Exception should be caught; This should not print."); - } catch (NoSuchElementException e) { - System.out.println("NextWhenNone()+CachedIteratorCollection: NoSuchElementException caught successfully." + e); - } - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - - Iterator testCollection2Itr = testCollection2.iterator(); - - while(testCollection2Itr.hasNext()) { - testCollection2Itr.next(); - } - - assertEquals(10, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - /* JUnit5 java8+ - // next() should throw an exception as there are no more nodes - assertThrows(NoSuchElementException.class, () -> { testCollection2Itr.next(); }); - */ - - try { - testCollection2Itr.next(); - fail("Exception should be caught; This should not print."); - } catch (NoSuchElementException e) { - System.out.println("NextWhenNone()+LinkedList: NoSuchElementException caught successfully." + e); - } - } - - //@DisplayName("Add, Remove All and Add Again Test") - @Test - public void ReAdd() { - CachedIteratorCollection testCollection1 = new CachedIteratorCollection<>(); - - AddNObjects(testCollection1, 10); - - Iterator testCollection1Itr = testCollection1.iterator(); - - String testString = ""; - - while (testCollection1Itr.hasNext()) { - testString += testCollection1Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection1.size()); - - // Reset and remove all - testCollection1Itr = testCollection1.iterator(); - - while(testCollection1Itr.hasNext()) { - testCollection1Itr.next(); - testCollection1Itr.remove(); - } - - assertEquals(0, testCollection1.size()); - assertFalse(testCollection1Itr.hasNext()); - assertTrue(testCollection1.isEmpty()); - - // Re-add - AddNObjects(testCollection1, 10); - testCollection1Itr = testCollection1.iterator(); - - assertEquals(10, testCollection1.size()); - assertTrue("test0".equals(testCollection1Itr.next())); - assertTrue(testCollection1Itr.hasNext()); - assertFalse(testCollection1.isEmpty()); - - // Compare behavior with LinkedList object - LinkedList testCollection2 = new LinkedList<>(); - - AddNObjectsLL(testCollection2, 10); - - Iterator testCollection2Itr = testCollection2.iterator(); - - testString = ""; - - while (testCollection2Itr.hasNext()) { - testString += testCollection2Itr.next(); - } - - assertEquals("test0test1test2test3test4test5test6test7test8test9", testString); - assertEquals(10, testCollection2.size()); - - testCollection2Itr = testCollection2.iterator(); - - while(testCollection2Itr.hasNext()) { - testCollection2Itr.next(); - testCollection2Itr.remove(); - } - - assertEquals(0, testCollection2.size()); - assertFalse(testCollection2Itr.hasNext()); - assertTrue(testCollection2.isEmpty()); - - // Re-add - AddNObjectsLL(testCollection2, 10); - testCollection2Itr = testCollection2.iterator(); - - assertEquals(10, testCollection2.size()); - assertTrue("test0".equals(testCollection2Itr.next())); - assertTrue(testCollection2Itr.hasNext()); - assertFalse(testCollection2.isEmpty()); - } -} From 26189704f3cff72d3b62364f290fd608c4b1828a Mon Sep 17 00:00:00 2001 From: slumlord Date: Fri, 17 Aug 2018 08:37:41 +0000 Subject: [PATCH 09/12] Re-add file --- .../src/net/i2p/router/RouterVersion.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 router/java/src/net/i2p/router/RouterVersion.java diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java new file mode 100644 index 000000000..f7d70ed0a --- /dev/null +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -0,0 +1,32 @@ +package net.i2p.router; +/* + * free (adj.): unencumbered; not under the control of others + * Written by jrandom in 2003 and released into the public domain + * with no warranty of any kind, either expressed or implied. + * It probably won't make your computer catch on fire, or eat + * your children, but it might. Use at your own risk. + * + */ + +import net.i2p.CoreVersion; + +/** + * Expose a version string + * + */ +public class RouterVersion { + /** deprecated */ + public final static String ID = "Monotone"; + public final static String VERSION = CoreVersion.VERSION; + public final static long BUILD = 24; + + /** for example "-test" */ + public final static String EXTRA = "-rc"; + public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; + public static void main(String args[]) { + System.out.println("I2P Router version: " + FULL_VERSION); + System.out.println("Router ID: " + RouterVersion.ID); + System.out.println("I2P Core version: " + CoreVersion.VERSION); + System.out.println("Core ID: " + CoreVersion.ID); + } +} From 773676075c028e47865ea06385ff37bf40950abd Mon Sep 17 00:00:00 2001 From: slumlord Date: Mon, 27 Aug 2018 06:20:40 +0000 Subject: [PATCH 10/12] Revert PeerState.java temporarily to allow for propagation from i2p.i2p --- .../src/net/i2p/router/transport/udp/PeerState.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/udp/PeerState.java b/router/java/src/net/i2p/router/transport/udp/PeerState.java index 8a5dd9224..9a5f2ceb8 100644 --- a/router/java/src/net/i2p/router/transport/udp/PeerState.java +++ b/router/java/src/net/i2p/router/transport/udp/PeerState.java @@ -11,12 +11,14 @@ import java.util.Map; import java.util.Set; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.atomic.AtomicInteger; import net.i2p.data.Hash; import net.i2p.data.SessionKey; import net.i2p.router.OutNetMessage; import net.i2p.router.RouterContext; -import net.i2p.router.util.CachedIteratorCollection; +import net.i2p.router.util.CachedIteratorArrayList; +import net.i2p.router.util.CoDelPriorityBlockingQueue; import net.i2p.router.util.PriBlockingQueue; import net.i2p.util.Log; import net.i2p.util.ConcurrentHashSet; @@ -208,7 +210,7 @@ public class PeerState { * Mostly messages that have been transmitted and are awaiting acknowledgement, * although there could be some that have not been sent yet. */ - private final CachedIteratorCollection _outboundMessages; + private final List _outboundMessages; /** * Priority queue of messages that have not yet been sent. @@ -368,7 +370,7 @@ public class PeerState { _rtt = INIT_RTT; _rttDeviation = _rtt; _inboundMessages = new HashMap(8); - _outboundMessages = new CachedIteratorCollection(); + _outboundMessages = new CachedIteratorArrayList(32); //_outboundQueue = new CoDelPriorityBlockingQueue(ctx, "UDP-PeerState", 32); _outboundQueue = new PriBlockingQueue(ctx, "UDP-PeerState", 32); // all createRateStat() moved to EstablishmentManager @@ -1566,7 +1568,7 @@ public class PeerState { if (_dead) { dropOutbound(); return 0; - } + } int rv = 0; List succeeded = null; @@ -1584,7 +1586,6 @@ public class PeerState { iter.remove(); if (_retransmitter == state) _retransmitter = null; - _log.debug("CachedIteratorCollection: sendFailed update" + state); _context.statManager().addRateData("udp.sendFailed", state.getPushCount()); if (failed == null) failed = new ArrayList(4); failed.add(state); @@ -1592,7 +1593,6 @@ public class PeerState { iter.remove(); if (state == _retransmitter) _retransmitter = null; - _log.debug("CachedIteratorCollection: sendAggressiveFailed update" + state); _context.statManager().addRateData("udp.sendAggressiveFailed", state.getPushCount()); if (failed == null) failed = new ArrayList(4); failed.add(state); @@ -1904,7 +1904,6 @@ public class PeerState { _context.statManager().addRateData("udp.sendConfirmFragments", state.getFragmentCount()); _context.statManager().addRateData("udp.sendConfirmVolley", numSends); _transport.succeeded(state); - int numFragments = state.getFragmentCount(); // this adjusts the rtt/rto/window/etc messageACKed(state.getMessageSize(), state.getLifetime(), numSends); //if (getSendWindowBytesRemaining() > 0) From 92cc66ecb27b2f9d746f9631d7b95ae70ba003bb Mon Sep 17 00:00:00 2001 From: slumlord Date: Mon, 27 Aug 2018 06:25:51 +0000 Subject: [PATCH 11/12] Update RouterVersion.java to match i2p.i2p to allow for propagation from i2p.i2p --- router/java/src/net/i2p/router/RouterVersion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index f7d70ed0a..0725033fa 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,10 +18,10 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 24; + public final static long BUILD = 3; /** for example "-test" */ - public final static String EXTRA = "-rc"; + public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public static void main(String args[]) { System.out.println("I2P Router version: " + FULL_VERSION); From 873087441ab8e30a11189c34014ab6e22bee4fce Mon Sep 17 00:00:00 2001 From: slumlord Date: Mon, 27 Aug 2018 06:36:05 +0000 Subject: [PATCH 12/12] Use CachedIteratorCollection in PeerState --- router/java/src/net/i2p/router/transport/udp/PeerState.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/udp/PeerState.java b/router/java/src/net/i2p/router/transport/udp/PeerState.java index 9a5f2ceb8..ebb3a0ea6 100644 --- a/router/java/src/net/i2p/router/transport/udp/PeerState.java +++ b/router/java/src/net/i2p/router/transport/udp/PeerState.java @@ -17,7 +17,7 @@ import net.i2p.data.Hash; import net.i2p.data.SessionKey; import net.i2p.router.OutNetMessage; import net.i2p.router.RouterContext; -import net.i2p.router.util.CachedIteratorArrayList; +import net.i2p.router.util.CachedIteratorCollection; import net.i2p.router.util.CoDelPriorityBlockingQueue; import net.i2p.router.util.PriBlockingQueue; import net.i2p.util.Log; @@ -210,7 +210,7 @@ public class PeerState { * Mostly messages that have been transmitted and are awaiting acknowledgement, * although there could be some that have not been sent yet. */ - private final List _outboundMessages; + private final CachedIteratorCollection _outboundMessages; /** * Priority queue of messages that have not yet been sent. @@ -370,7 +370,7 @@ public class PeerState { _rtt = INIT_RTT; _rttDeviation = _rtt; _inboundMessages = new HashMap(8); - _outboundMessages = new CachedIteratorArrayList(32); + _outboundMessages = new CachedIteratorCollection(); //_outboundQueue = new CoDelPriorityBlockingQueue(ctx, "UDP-PeerState", 32); _outboundQueue = new PriBlockingQueue(ctx, "UDP-PeerState", 32); // all createRateStat() moved to EstablishmentManager