AMQ-2049 Fix race condition on ConnectionInfo by copying. Minor javaodc cleanup

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@730226 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Jencks 2008-12-30 20:05:16 +00:00
parent 90fd917a67
commit e08cc350e0
2 changed files with 15 additions and 5 deletions

View File

@ -51,6 +51,7 @@ import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicSession;
import javax.jms.XAConnection;
import javax.jms.InvalidDestinationException;
import org.apache.activemq.blob.BlobTransferPolicy;
import org.apache.activemq.command.ActiveMQDestination;
@ -1332,11 +1333,11 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
if (isConnectionInfoSentToBroker || closed.get()) {
return;
}
//TODO shouldn't this check be on userSpecifiedClientID rather than the value of clientID?
if (info.getClientId() == null || info.getClientId().trim().length() == 0) {
info.setClientId(clientIdGenerator.generateId());
}
syncSendPacket(info);
syncSendPacket(info.copy());
this.isConnectionInfoSentToBroker = true;
// Add a temp destination advisory consumer so that
@ -2043,7 +2044,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
* specified.
* @since 1.1
*/
public void unsubscribe(String name) throws JMSException {
public void unsubscribe(String name) throws InvalidDestinationException, JMSException {
checkClosedOrFailed();
RemoveSubscriptionInfo rsi = new RemoveSubscriptionInfo();
rsi.setConnectionId(getConnectionInfo().getConnectionId());

View File

@ -48,14 +48,23 @@ public class ConnectionInfo extends BaseCommand {
return DATA_STRUCTURE_TYPE;
}
public void copy(ConnectionInfo copy) {
public ConnectionInfo copy() {
ConnectionInfo copy = new ConnectionInfo();
copy(copy);
return copy;
}
private void copy(ConnectionInfo copy) {
super.copy(copy);
copy.connectionId = connectionId;
copy.clientId = clientId;
copy.userName = userName;
copy.password = password;
copy.brokerPath = brokerPath;
copy.brokerMasterConnector = brokerMasterConnector;
copy.manageable = manageable;
copy.clientMaster = clientMaster;
copy.transportContext = transportContext;
}
/**
@ -133,7 +142,7 @@ public class ConnectionInfo extends BaseCommand {
}
/**
* @param brokerMasterConnector The brokerMasterConnector to set.
* @param slaveBroker The brokerMasterConnector to set.
*/
public void setBrokerMasterConnector(boolean slaveBroker) {
this.brokerMasterConnector = slaveBroker;