activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r582910 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedList.java
Date Mon, 08 Oct 2007 17:47:47 GMT
Author: rajdavies
Date: Mon Oct  8 10:47:47 2007
New Revision: 582910

URL: http://svn.apache.org/viewvc?rev=582910&view=rev
Log:
quick fix for npe

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedList.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedList.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedList.java?rev=582910&r1=582909&r2=582910&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedList.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/VMIndexLinkedList.java
Mon Oct  8 10:47:47 2007
@@ -36,7 +36,7 @@
         root.prev = root;
     }
 
-    public IndexItem getRoot() {
+    public synchronized IndexItem getRoot() {
         return root;
     }
 
@@ -45,7 +45,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#getFirst()
      */
-    public IndexItem getFirst() {
+    public synchronized IndexItem getFirst() {
         if (size == 0) {
             return null;
         }
@@ -57,7 +57,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#getLast()
      */
-    public IndexItem getLast() {
+    public synchronized IndexItem getLast() {
         if (size == 0) {
             return null;
         }
@@ -69,7 +69,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#removeFirst()
      */
-    public StoreEntry removeFirst() {
+    public synchronized StoreEntry removeFirst() {
         if (size == 0) {
             return null;
         }
@@ -83,7 +83,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#removeLast()
      */
-    public Object removeLast() {
+    public synchronized Object removeLast() {
         if (size == 0) {
             return null;
         }
@@ -97,7 +97,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#addFirst(org.apache.activemq.kaha.impl.IndexItem)
      */
-    public void addFirst(IndexItem item) {
+    public synchronized void addFirst(IndexItem item) {
         addBefore(item, root.next);
     }
 
@@ -106,7 +106,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#addLast(org.apache.activemq.kaha.impl.IndexItem)
      */
-    public void addLast(IndexItem item) {
+    public synchronized void addLast(IndexItem item) {
         addBefore(item, root);
     }
 
@@ -115,7 +115,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#size()
      */
-    public int size() {
+    public synchronized int size() {
         return size;
     }
 
@@ -124,7 +124,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#isEmpty()
      */
-    public boolean isEmpty() {
+    public synchronized boolean isEmpty() {
         return size == 0;
     }
 
@@ -133,7 +133,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#add(org.apache.activemq.kaha.impl.IndexItem)
      */
-    public boolean add(IndexItem item) {
+    public synchronized boolean add(IndexItem item) {
         addBefore(item, root);
         return true;
     }
@@ -143,7 +143,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#clear()
      */
-    public void clear() {
+    public synchronized void clear() {
         root.next = root;
         root.prev = root;
         size = 0;
@@ -155,7 +155,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#get(int)
      */
-    public IndexItem get(int index) {
+    public synchronized IndexItem get(int index) {
         return entry(index);
     }
 
@@ -165,7 +165,7 @@
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#add(int,
      *      org.apache.activemq.kaha.impl.IndexItem)
      */
-    public void add(int index, IndexItem element) {
+    public synchronized void add(int index, IndexItem element) {
         addBefore(element, index == size ? root : entry(index));
     }
 
@@ -174,7 +174,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#remove(int)
      */
-    public Object remove(int index) {
+    public synchronized Object remove(int index) {
         IndexItem e = entry(index);
         remove(e);
         return e;
@@ -206,7 +206,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#indexOf(org.apache.activemq.kaha.impl.IndexItem)
      */
-    public int indexOf(StoreEntry o) {
+    public synchronized int indexOf(StoreEntry o) {
         int index = 0;
         for (IndexItem e = root.next; e != root; e = e.next) {
             if (o == e) {
@@ -222,7 +222,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#getNextEntry(org.apache.activemq.kaha.impl.IndexItem)
      */
-    public IndexItem getNextEntry(IndexItem entry) {
+    public synchronized IndexItem getNextEntry(IndexItem entry) {
         return entry.next != root ? entry.next : null;
     }
 
@@ -231,7 +231,7 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#getPrevEntry(org.apache.activemq.kaha.impl.IndexItem)
      */
-    public IndexItem getPrevEntry(IndexItem entry) {
+    public synchronized IndexItem getPrevEntry(IndexItem entry) {
         return entry.prev != root ? entry.prev : null;
     }
 
@@ -241,7 +241,7 @@
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#addBefore(org.apache.activemq.kaha.impl.IndexItem,
      *      org.apache.activemq.kaha.impl.IndexItem)
      */
-    public void addBefore(IndexItem insert, IndexItem e) {
+    public synchronized void addBefore(IndexItem insert, IndexItem e) {
         insert.next = e;
         insert.prev = e.prev;
         insert.prev.next = insert;
@@ -254,10 +254,16 @@
      * 
      * @see org.apache.activemq.kaha.impl.IndexLinkedList#remove(org.apache.activemq.kaha.impl.IndexItem)
      */
-    public void remove(IndexItem e) {
-        if (e == root) {
+    public synchronized void remove(IndexItem e) {
+        if (e == root || e.equals(root)) {
             return;
         }
+        if (e.prev==null){
+        	e.prev=root;
+        }
+        if (e.next==null){
+        	e.next=root;
+        }
         e.prev.next = e.next;
         e.next.prev = e.prev;
         size--;
@@ -266,7 +272,7 @@
     /**
      * @return clone
      */
-    public Object clone() {
+    public synchronized Object clone() {
         IndexLinkedList clone = new VMIndexLinkedList(this.root);
         for (IndexItem e = root.next; e != root; e = e.next) {
             clone.add(e);
@@ -274,7 +280,7 @@
         return clone;
     }
 
-    public StoreEntry getEntry(StoreEntry current) {
+    public synchronized StoreEntry getEntry(StoreEntry current) {
         return current;
     }
 
@@ -283,7 +289,7 @@
      * 
      * @param current
      */
-    public StoreEntry refreshEntry(StoreEntry current) {
+    public synchronized StoreEntry refreshEntry(StoreEntry current) {
         return current;
     }
 }



Mime
View raw message