activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r515746 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubContainer.java
Date Wed, 07 Mar 2007 20:53:25 GMT
Author: jstrachan
Date: Wed Mar  7 12:53:24 2007
New Revision: 515746

URL: http://svn.apache.org/viewvc?view=rev&rev=515746
Log:
fix to avoid NPE

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubContainer.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubContainer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubContainer.java?view=diff&rev=515746&r1=515745&r2=515746
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubContainer.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/TopicSubContainer.java
Wed Mar  7 12:53:24 2007
@@ -1,73 +1,72 @@
 /**
- * 
+ *
  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements. See the NOTICE
  * file distributed with this work for additional information regarding copyright ownership.
The ASF licenses this file
  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the
  * License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the
  * specific language governing permissions and limitations under the License.
  */
-
 package org.apache.activemq.store.kahadaptor;
 
-import java.util.Iterator;
 import org.apache.activemq.command.MessageId;
 import org.apache.activemq.kaha.ListContainer;
 import org.apache.activemq.kaha.StoreEntry;
 
+import java.util.Iterator;
+
 /**
  * Holds information for the subscriber
- * 
+ *
  * @version $Revision: 1.10 $
  */
- public class TopicSubContainer{
-
+public class TopicSubContainer {
     private ListContainer listContainer;
     private StoreEntry batchEntry;
-    
-    public TopicSubContainer(ListContainer container){
+
+    public TopicSubContainer(ListContainer container) {
         this.listContainer = container;
     }
+
     /**
      * @return the batchEntry
      */
-     public StoreEntry getBatchEntry(){
+    public StoreEntry getBatchEntry() {
         return this.batchEntry;
     }
-    
+
     /**
      * @param batchEntry the batchEntry to set
      */
-     public void setBatchEntry(StoreEntry batchEntry){
-        this.batchEntry=batchEntry;
+    public void setBatchEntry(StoreEntry batchEntry) {
+        this.batchEntry = batchEntry;
     }
-    
-    
-     public void reset() {
+
+    public void reset() {
         batchEntry = null;
     }
-     
+
     public boolean isEmpty() {
         return listContainer.isEmpty();
     }
-    
+
     public StoreEntry add(ConsumerMessageRef ref) {
         return listContainer.placeLast(ref);
     }
-    
-    public ConsumerMessageRef remove(MessageId id){
-        ConsumerMessageRef result=null;
-        if(!listContainer.isEmpty()){
-            for(StoreEntry entry=listContainer.getFirst();entry!=null;entry=listContainer.getNext(entry)){
-                ConsumerMessageRef ref=(ConsumerMessageRef)listContainer.get(entry);
-                if(ref!=null&&ref.getMessageId().equals(id)){
+
+    public ConsumerMessageRef remove(MessageId id) {
+        ConsumerMessageRef result = null;
+        if (!listContainer.isEmpty()) {
+            for (StoreEntry entry = listContainer.getFirst(); entry != null; entry = listContainer.getNext(entry))
{
+                ConsumerMessageRef ref = (ConsumerMessageRef) listContainer.get(entry);
+                if (ref != null && ref.getMessageId().equals(id)) {
                     listContainer.remove(entry);
-                    result=ref;
-                    if(listContainer.isEmpty()||batchEntry.equals(entry)){
+                    result = ref;
+                    if (listContainer != null && batchEntry != null && (listContainer.isEmpty()
|| batchEntry.equals(entry))) {
                         reset();
                     }
                 }
@@ -75,34 +74,33 @@
         }
         return result;
     }
-    
+
     public ConsumerMessageRef get(StoreEntry entry) {
-        return (ConsumerMessageRef)listContainer.get(entry);
+        return (ConsumerMessageRef) listContainer.get(entry);
     }
-    
+
     public StoreEntry getEntry() {
         return listContainer.getFirst();
     }
-    
+
     public StoreEntry refreshEntry(StoreEntry entry) {
         return listContainer.refresh(entry);
     }
-    
+
     public StoreEntry getNextEntry(StoreEntry entry) {
         return listContainer.getNext(entry);
     }
-        
+
     public Iterator iterator() {
         return listContainer.iterator();
     }
-    
+
     public int size() {
         return listContainer.size();
     }
-    
+
     public void clear() {
         reset();
         listContainer.clear();
     }
-   
 }



Mime
View raw message