Skip to content

Commit 85d65b0

Browse files
committed
Add test case for bug 20004
1 parent dcdf070 commit 85d65b0

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

test/src/com/rabbitmq/client/test/AllTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static TestSuite suite() {
4343
suite.addTest(AMQConnectionTest.suite());
4444
suite.addTest(ValueOrExceptionTest.suite());
4545
suite.addTest(BrokenFramesTest.suite());
46+
suite.addTestSuite(Bug20004Test.class);
4647
return suite;
4748
}
4849
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// The contents of this file are subject to the Mozilla Public License
2+
// Version 1.1 (the "License"); you may not use this file except in
3+
// compliance with the License. You may obtain a copy of the License at
4+
// http://www.mozilla.org/MPL/
5+
//
6+
// Software distributed under the License is distributed on an "AS IS"
7+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
8+
// License for the specific language governing rights and limitations
9+
// under the License.
10+
//
11+
// The Original Code is RabbitMQ.
12+
//
13+
// The Initial Developers of the Original Code are LShift Ltd,
14+
// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
15+
//
16+
// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
17+
// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
18+
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
19+
// Technologies LLC, and Rabbit Technologies Ltd.
20+
//
21+
// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
22+
// Ltd. Portions created by Cohesive Financial Technologies LLC are
23+
// Copyright (C) 2007-2009 Cohesive Financial Technologies
24+
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
25+
// (C) 2007-2009 Rabbit Technologies Ltd.
26+
//
27+
// All Rights Reserved.
28+
//
29+
// Contributor(s): ______________________________________.
30+
//
31+
package com.rabbitmq.client.test;
32+
33+
import java.io.IOException;
34+
35+
import com.rabbitmq.client.test.functional.BrokerTestCase;
36+
37+
/**
38+
* Test for bug 20004 - deadlock through internal synchronization on
39+
* the channel object.
40+
*/
41+
public class Bug20004Test extends BrokerTestCase {
42+
public Exception caughtException = null;
43+
public boolean completed = false;
44+
public boolean created = false;
45+
46+
protected void releaseResources()
47+
throws IOException
48+
{
49+
if (created) {
50+
channel.queueDelete("Bug20004Test");
51+
}
52+
}
53+
54+
public void testBug20004()
55+
throws IOException
56+
{
57+
final Bug20004Test testInstance = this;
58+
59+
Thread declaringThread = new Thread(new Runnable() {
60+
public void run() {
61+
try {
62+
synchronized (channel) {
63+
channel.queueDeclare("Bug20004Test");
64+
testInstance.created = true;
65+
}
66+
} catch (Exception e) {
67+
testInstance.caughtException = e;
68+
}
69+
testInstance.completed = true;
70+
}
71+
});
72+
declaringThread.start();
73+
74+
long startTime = System.currentTimeMillis();
75+
while (!completed && (System.currentTimeMillis() - startTime < 5000)) {
76+
try {
77+
Thread.sleep(100);
78+
} catch (InterruptedException ie) {}
79+
}
80+
81+
declaringThread.stop(); // see bug 20012.
82+
83+
if (!completed) {
84+
fail("Deadlock detected. Probably.");
85+
}
86+
87+
assertNull(caughtException);
88+
assertTrue(created);
89+
}
90+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy