diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java index 7e249575b2..a1730c02bd 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java @@ -27,6 +27,7 @@ import java.util.LinkedList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import javax.jms.InvalidClientIDException; import javax.jms.InvalidSelectorException; import org.apache.activemq.command.ActiveMQDestination; @@ -426,7 +427,13 @@ class AmqpProtocolConverter implements IAmqpProtocolConverter { if (response.isException()) { Throwable exception = ((ExceptionResponse) response).getException(); - protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); + if (exception instanceof SecurityException) { + protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); + } else if (exception instanceof InvalidClientIDException) { + protonConnection.setCondition(new ErrorCondition(AmqpError.INVALID_FIELD, exception.getMessage())); + } else { + protonConnection.setCondition(new ErrorCondition(AmqpError.ILLEGAL_STATE, exception.getMessage())); + } protonConnection.close(); pumpProtonToSocket(); amqpTransport.onException(IOExceptionSupport.create(exception));