activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1165797 - in /activemq/trunk/kahadb/src: main/java/org/apache/kahadb/util/SequenceSet.java test/java/org/apache/kahadb/util/SequenceSetTest.java
Date Tue, 06 Sep 2011 19:35:33 GMT
Author: tabish
Date: Tue Sep  6 19:35:33 2011
New Revision: 1165797

URL: http://svn.apache.org/viewvc?rev=1165797&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3467

Handle a potential NPE case.

Modified:
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/SequenceSet.java
    activemq/trunk/kahadb/src/test/java/org/apache/kahadb/util/SequenceSetTest.java

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/SequenceSet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/SequenceSet.java?rev=1165797&r1=1165796&r2=1165797&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/SequenceSet.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/SequenceSet.java Tue Sep  6
19:35:33 2011
@@ -369,11 +369,13 @@ public class SequenceSet extends LinkedN
     private class SequenceIterator implements Iterator<Long> {
 
         private Sequence currentEntry;
-        private long lastReturned;
+        private long lastReturned = -1;
 
         public SequenceIterator() {
             currentEntry = getHead();
-            lastReturned = currentEntry.first - 1;
+            if (currentEntry != null) {
+                lastReturned = currentEntry.first - 1;
+            }
         }
 
         public boolean hasNext() {

Modified: activemq/trunk/kahadb/src/test/java/org/apache/kahadb/util/SequenceSetTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/test/java/org/apache/kahadb/util/SequenceSetTest.java?rev=1165797&r1=1165796&r2=1165797&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/test/java/org/apache/kahadb/util/SequenceSetTest.java (original)
+++ activemq/trunk/kahadb/src/test/java/org/apache/kahadb/util/SequenceSetTest.java Tue Sep
 6 19:35:33 2011
@@ -126,4 +126,14 @@ public class SequenceSetTest {
             assertEquals(expected[index++], iterator.next().longValue());
         }
     }
+
+    @Test
+    public void testIteratorEmptySequenceSet() {
+        SequenceSet set = new SequenceSet();
+
+        Iterator<Long> iterator = set.iterator();
+        while(iterator.hasNext()) {
+            fail("Should not have any elements");
+        }
+    }
 }



Mime
View raw message