activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r386099 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
Date Wed, 15 Mar 2006 16:02:31 GMT
Author: jstrachan
Date: Wed Mar 15 08:02:20 2006
New Revision: 386099

URL: http://svn.apache.org/viewcvs?rev=386099&view=rev
Log:
added logging if we can't properly cast things when closing things down

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java?rev=386099&r1=386098&r2=386099&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
Wed Mar 15 08:02:20 2006
@@ -29,6 +29,8 @@
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.TopicMessageStore;
 import org.apache.activemq.store.TransactionStore;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
 
@@ -38,6 +40,7 @@
  * @version $Revision: 1.4 $
  */
 public class MemoryPersistenceAdapter implements PersistenceAdapter {
+    private static final Log log = LogFactory.getLog(MemoryPersistenceAdapter.class);
 
     MemoryTransactionStore transactionStore;
     ConcurrentHashMap topics = new ConcurrentHashMap();
@@ -111,12 +114,16 @@
 
     public void deleteAllMessages() throws IOException {
         for (Iterator iter = topics.values().iterator(); iter.hasNext();) {
-            MemoryMessageStore store = (MemoryMessageStore) iter.next();
-            store.delete();
+            MemoryMessageStore store = asMemoryMessageStore(iter.next());
+            if (store != null) {
+                store.delete();
+            }
         }
         for (Iterator iter = queues.values().iterator(); iter.hasNext();) {
-            MemoryMessageStore store = (MemoryMessageStore) iter.next();
-            store.delete();
+            MemoryMessageStore store = asMemoryMessageStore(iter.next());
+            if (store != null) {
+                store.delete();
+            }
         }
         transactionStore.delete();
     }
@@ -127,6 +134,14 @@
 
     public void setUseExternalMessageReferences(boolean useExternalMessageReferences) {
         this.useExternalMessageReferences = useExternalMessageReferences;
+    }
+
+    protected MemoryMessageStore asMemoryMessageStore(Object value) {
+        if (value instanceof MemoryMessageStore) {
+            return (MemoryMessageStore) value;
+        }
+        log.warn("Expected an instance of MemoryMessageStore but was: " + value);
+        return null;
     }
 
 }



Mime
View raw message