activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6477
Date Tue, 01 Nov 2016 14:31:51 GMT
Repository: activemq
Updated Branches:
  refs/heads/master a8a650cbe -> 5c80eda32


https://issues.apache.org/jira/browse/AMQ-6477

Fixing potential concurrent modification exception


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/5c80eda3
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/5c80eda3
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/5c80eda3

Branch: refs/heads/master
Commit: 5c80eda321e7edb5f34ffd62c71523310d26b2ca
Parents: a8a650c
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Tue Nov 1 10:25:01 2016 -0400
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Tue Nov 1 10:31:20 2016 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/usecases/AMQ6477Test.java | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/5c80eda3/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ6477Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ6477Test.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ6477Test.java
index 02d9425..50292c1 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ6477Test.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AMQ6477Test.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -174,15 +175,22 @@ public class AMQ6477Test {
 
     @SuppressWarnings("unchecked")
     protected List<MessageReference> getSubscriptionMessages(Subscription sub) throws
Exception {
-        Field f = null;
+        Field dispatchedField = null;
+        Field dispatchLockField = null;
 
         if (sub instanceof TopicSubscription) {
-            f = TopicSubscription.class.getDeclaredField("dispatched");
+            dispatchedField = TopicSubscription.class.getDeclaredField("dispatched");
+            dispatchLockField = TopicSubscription.class.getDeclaredField("dispatchLock");
         } else {
-            f = PrefetchSubscription.class.getDeclaredField("dispatched");
+            dispatchedField = PrefetchSubscription.class.getDeclaredField("dispatched");
+            dispatchLockField = PrefetchSubscription.class.getDeclaredField("dispatchLock");
+        }
+        dispatchedField.setAccessible(true);
+        dispatchLockField.setAccessible(true);
+
+        synchronized (dispatchLockField.get(sub)) {
+            return new ArrayList<MessageReference>((List<MessageReference>)dispatchedField.get(sub));
         }
-        f.setAccessible(true);
-        return (List<MessageReference>) f.get(sub);
     }
 
 }
\ No newline at end of file


Mime
View raw message