Author: j16sdiz
Date: 2008-09-07 11:30:08 +0000 (Sun, 07 Sep 2008)
New Revision: 22517

Modified:
   trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java
   trunk/freenet/test/freenet/support/DoublyLinkedListImplTest.java
Log:
more consistency: remove non-exist item return null

Modified: trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java
===================================================================
--- trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java 2008-09-07 
11:29:43 UTC (rev 22516)
+++ trunk/freenet/src/freenet/support/DoublyLinkedListImpl.java 2008-09-07 
11:30:08 UTC (rev 22517)
@@ -270,11 +270,8 @@
      * {@inheritDoc}
      */
     public DoublyLinkedList.Item<T> remove(DoublyLinkedList.Item<T> i) {
-       if (i.getParent() == null) return null; // not in list
-       if(isEmpty()) {
-               Logger.error(this, "Illegal ERROR: Removing from an empty 
list!!");
-               throw new IllegalStateException("Illegal ERROR: Removing from 
an empty list!!");
-       }
+       if (i.getParent() == null || isEmpty())
+                       return null; // not in list
        if (i.getParent() != this)
                throw new PromiscuousItemException(i, i.getParent());
         DoublyLinkedList.Item<T> next = i.getNext(), prev = i.getPrev();

Modified: trunk/freenet/test/freenet/support/DoublyLinkedListImplTest.java
===================================================================
--- trunk/freenet/test/freenet/support/DoublyLinkedListImplTest.java    
2008-09-07 11:29:43 UTC (rev 22516)
+++ trunk/freenet/test/freenet/support/DoublyLinkedListImplTest.java    
2008-09-07 11:30:08 UTC (rev 22517)
@@ -305,6 +305,8 @@
                ((T) list.shift()).assertV(2);
                ((T) list.shift()).assertV(4);
                ((T) list.shift()).assertV(3);
+
+               assertNull(list.remove(new T(-1)));
        }

        public void testRandomShiftPush() {


Reply via email to