Skip to content

Commit ea62faa

Browse files
committed
merge v1_5 into default
2 parents 585aac2 + 62f2e23 commit ea62faa

File tree

3 files changed

+58
-25
lines changed

3 files changed

+58
-25
lines changed

src/com/rabbitmq/client/ShutdownSignalException.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public ShutdownSignalException(boolean hardError,
6666
boolean initiatedByApplication,
6767
Object reason, Object ref)
6868
{
69+
super((initiatedByApplication
70+
? ("clean " + (hardError ? "connection" : "channel") + " shutdown")
71+
: ((hardError ? "connection" : "channel") + " error"))
72+
+ "; reason: " + reason);
6973
this._hardError = hardError;
7074
this._initiatedByApplication = initiatedByApplication;
7175
this._reason = reason;
@@ -88,13 +92,6 @@ public ShutdownSignalException(boolean hardError,
8892
/** @return Reference to Connection or Channel object that fired the signal **/
8993
public Object getReference() { return _ref; }
9094

91-
public String toString() {
92-
return super.toString() + " (" +
93-
(_initiatedByApplication
94-
? ("clean " + (_hardError ? "connection" : "channel") + " shutdown")
95-
: ((_hardError ? "connection" : "channel") + " error"))
96-
+ "; reason: " + _reason + ")";
97-
}
9895
}
9996

10097

test/src/com/rabbitmq/client/test/functional/BindingLifecycle.java

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@
3636
import com.rabbitmq.client.GetResponse;
3737
import com.rabbitmq.client.QueueingConsumer;
3838

39+
import com.rabbitmq.tools.Host;
40+
3941
import java.io.IOException;
4042

4143
/**
4244
* This tests whether bindings are created and nuked properly.
4345
*
46+
* The tests attempt to declare durable queues on a secondary node, if
47+
* present, and that node is restarted as part of the tests while the
48+
* primary node is still running. That way we exercise any node-down
49+
* handler code in the server.
50+
*
4451
* TODO: Adjust this test when Queue.Unbind is implemented in the
4552
* server
4653
*/
@@ -55,27 +62,56 @@ public class BindingLifecycle extends PersisterRestartBase {
5562
protected static final String X = "X-" + System.currentTimeMillis();
5663
protected static final String K = "K-" + System.currentTimeMillis();
5764

58-
/**
59-
* Create a durable queue on secondary node, if possible, falling
60-
* back on the primary node if necessary.
61-
*/
62-
@Override protected void declareDurableQueue(String q)
63-
throws IOException
64-
{
65-
Connection connection;
66-
try {
67-
connection = connectionFactory.newConnection("localhost", 5673);
68-
} catch (IOException e) {
69-
super.declareDurableQueue(q);
70-
return;
65+
public Connection secondaryConnection;
66+
public Channel secondaryChannel;
67+
68+
@Override public void openConnection() throws IOException {
69+
super.openConnection();
70+
if (secondaryConnection == null) {
71+
try {
72+
secondaryConnection = connectionFactory.newConnection("localhost", 5673);
73+
} catch (IOException e) {
74+
// just use a single node
75+
}
7176
}
77+
}
7278

73-
Channel channel = connection.createChannel();
79+
@Override public void closeConnection() throws IOException {
80+
if (secondaryConnection != null) {
81+
secondaryConnection.abort();
82+
secondaryConnection = null;
83+
}
84+
super.closeConnection();
85+
}
7486

75-
channel.queueDeclare(q, true);
87+
@Override public void openChannel() throws IOException {
88+
if (secondaryConnection != null) {
89+
secondaryChannel = secondaryConnection.createChannel();
90+
}
91+
super.openChannel();
92+
}
93+
94+
@Override public void closeChannel() throws IOException {
95+
if (secondaryChannel != null) {
96+
secondaryChannel.abort();
97+
secondaryChannel = null;
98+
}
99+
super.closeChannel();
100+
}
101+
102+
@Override protected void restart() throws IOException {
103+
if (secondaryConnection != null) {
104+
secondaryConnection.abort();
105+
secondaryConnection = null;
106+
secondaryChannel = null;
107+
Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node");
108+
}
109+
super.restart();
110+
}
76111

77-
channel.abort();
78-
connection.abort();
112+
@Override protected void declareDurableQueue(String q) throws IOException {
113+
(secondaryChannel == null ? channel : secondaryChannel).
114+
queueDeclare(q, true);
79115
}
80116

81117
/**

test/src/com/rabbitmq/client/test/functional/PersisterRestartBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected void restart()
5858
throws IOException
5959
{
6060
tearDown();
61-
Host.executeCommand("cd ../rabbitmq-test; make restart-on-node");
61+
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
6262
setUp();
6363
}
6464

0 commit comments

Comments
 (0)