Skip to content

Commit 65da6b3

Browse files
author
Matthew Sackman
committed
Merging bug 22405 onto default
2 parents 1e1e346 + e3a140e commit 65da6b3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
* Convenience "factory" class to facilitate opening a {@link Connection} to an AMQP broker.
5353
*/
5454

55-
public class ConnectionFactory {
55+
public class ConnectionFactory implements Cloneable {
5656
/** Default user name */
5757
public static final String DEFAULT_USER = "guest";
5858

@@ -399,4 +399,13 @@ public Connection newConnection() throws IOException {
399399
0,
400400
new HashMap<Address,Integer>());
401401
}
402+
403+
404+
@Override public ConnectionFactory clone(){
405+
try {
406+
return (ConnectionFactory)super.clone();
407+
} catch (CloneNotSupportedException e) {
408+
throw new Error(e);
409+
}
410+
}
402411
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.rabbitmq.client.Connection;
3939
import com.rabbitmq.client.GetResponse;
4040
import com.rabbitmq.client.QueueingConsumer;
41+
import com.rabbitmq.client.ConnectionFactory;
4142
import java.io.IOException;
4243

4344
/**
@@ -75,9 +76,10 @@ public void openConnection() throws IOException {
7576
super.openConnection();
7677
if (secondaryConnection == null) {
7778
try {
78-
connectionFactory.setHost("localhost");
79-
connectionFactory.setPort(5673);
80-
secondaryConnection = connectionFactory.newConnection();
79+
ConnectionFactory cf2 = connectionFactory.clone();
80+
cf2.setHost("localhost");
81+
cf2.setPort(5673);
82+
secondaryConnection = cf2.newConnection();
8183
}
8284
catch (IOException e) {
8385
}

0 commit comments

Comments
 (0)