Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit bc3176d

Browse files
authored
Merge pull request javaee-samples#427 from flowlogix/JMS-Fix
Fix race condition in jms/send-receive
2 parents 2257940 + f61c321 commit bc3176d

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

jms/send-receive/src/test/java/org/javaee7/jms/send/receive/mdb/ReceptionSynchronizer.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ void registerInvocation(Method m) {
5656
synchronized (barrier) {
5757
if (barrier.containsKey(m)) {
5858
latch = barrier.get(m);
59+
} else {
60+
barrier.put(m, new CountDownLatch(0));
5961
}
6062
}
6163
if (latch != null) {
@@ -85,11 +87,6 @@ private static void waitFor(Method method, int timeoutInMillis) throws Interrupt
8587
synchronized (barrier) {
8688
if (barrier.containsKey(method)) {
8789
latch = barrier.get(method);
88-
if (latch.getCount() == 0) {
89-
throw new IllegalStateException("The invocation already happened");
90-
} else {
91-
throw new IllegalStateException("Sorry, I only serve the first one");
92-
}
9390
} else {
9491
latch = new CountDownLatch(1);
9592
barrier.put(method, latch);
@@ -99,5 +96,4 @@ private static void waitFor(Method method, int timeoutInMillis) throws Interrupt
9996
throw new AssertionError("Expected method has not been invoked in " + timeoutInMillis + "ms");
10097
}
10198
}
102-
10399
}

0 commit comments

Comments
 (0)