Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java Sat Nov 19 21:19:11 2016 @@ -51,30 +51,42 @@ import java.util.concurrent.ThreadFactor import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.jms.*; +import javax.jms.ConnectionConsumer; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; import javax.jms.IllegalStateException; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageEOFException; +import javax.jms.Queue; +import javax.jms.QueueSession; +import javax.jms.ServerSessionPool; +import javax.jms.StreamMessage; +import javax.jms.Topic; +import javax.jms.TopicSession; import javax.naming.NamingException; import javax.naming.Reference; import javax.naming.Referenceable; import javax.naming.StringRefAddr; -import org.apache.qpid.client.state.AMQState; -import org.apache.qpid.client.util.ClassLoadingAwareObjectInputStream; -import org.apache.qpid.jndi.ObjectFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.qpid.AMQConnectionFailureException; import org.apache.qpid.AMQDisconnectedException; -import org.apache.qpid.QpidException; import org.apache.qpid.AMQException; import org.apache.qpid.AMQProtocolException; import org.apache.qpid.AMQUnresolvedAddressException; +import org.apache.qpid.QpidException; import org.apache.qpid.client.failover.ConnectionRedirectException; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.client.failover.FailoverProtectedOperation; import org.apache.qpid.client.security.CallbackHandlerRegistry; +import org.apache.qpid.client.state.AMQState; import org.apache.qpid.client.state.AMQStateManager; +import org.apache.qpid.client.util.ClassLoadingAwareObjectInputStream; import org.apache.qpid.client.util.JMSExceptionHelper; import org.apache.qpid.configuration.ClientProperties; import org.apache.qpid.configuration.CommonProperties; @@ -84,7 +96,8 @@ import org.apache.qpid.jms.ConnectionLis import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.jms.FailoverPolicy; import org.apache.qpid.jms.Session; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.jndi.ObjectFactory; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.transport.ConnectionSettings; import org.apache.qpid.url.URLSyntaxException; @@ -695,12 +708,11 @@ public class AMQConnection extends Close } catch (ClassNotFoundException e) { - throw new AMQProtocolException - (AMQConstant.UNSUPPORTED_CLIENT_PROTOCOL_ERROR, - String.format("Protocol: %s.%s is required by the broker but is not " + - "currently supported by this client library implementation", - pe.getMajorVersion(), pe.getMinorVersion()), - e); + String errorMessage = String.format("Protocol: %s.%s is required by the broker but is not " + + "currently supported by this client library implementation", + pe.getMajorVersion(), pe.getMinorVersion()); + + throw new AMQProtocolException(errorMessage, e); } catch (NoSuchMethodException e) { @@ -1518,19 +1530,19 @@ public class AMQConnection extends Close } else { - AMQConstant code = null; + int errorCode = 0; if (cause instanceof AMQException) { - code = ((AMQException) cause).getErrorCode(); + errorCode = ((AMQException) cause).getErrorCode(); } - if (code != null) + if (errorCode != 0) { je = JMSExceptionHelper.chainJMSException(new JMSException("Exception thrown against " + toString() + ": " - + cause, Integer.toString(code.getCode())), + + cause, Integer.toString(errorCode)), cause); } else @@ -1860,7 +1872,7 @@ public class AMQConnection extends Close { if (!_delegate.verifyClientID()) { - throw new AMQException(AMQConstant.ALREADY_EXISTS,"ClientID must be unique"); + throw new AMQException(ErrorCodes.ALREADY_EXISTS, "ClientID must be unique"); } } catch(JMSException e)
Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java Sat Nov 19 21:19:11 2016 @@ -49,7 +49,7 @@ import org.apache.qpid.jms.ChannelLimitR import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.jms.Session; import org.apache.qpid.properties.ConnectionStartProperties; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.transport.Connection; import org.apache.qpid.transport.ConnectionClose; import org.apache.qpid.transport.ConnectionCloseCode; @@ -261,10 +261,10 @@ public class AMQConnectionDelegate_0_10 } catch (ConnectionException ce) { - AMQConstant code = AMQConstant.REPLY_SUCCESS; + int code = ErrorCodes.REPLY_SUCCESS; if (ce.getClose() != null && ce.getClose().getReplyCode() != null) { - code = AMQConstant.getConstant(ce.getClose().getReplyCode().getValue()); + code = ce.getClose().getReplyCode().getValue(); } String msg = "Cannot connect to broker ("+brokerDetail+"): " + ce.getMessage(); throw new AMQException(code, msg, ce); @@ -620,7 +620,7 @@ public class AMQConnectionDelegate_0_10 } else { - throw new AMQException(AMQConstant.INTERNAL_ERROR, "Unexpected SessionException thrown while awaiting session opening", se); + throw new AMQException(ErrorCodes.INTERNAL_ERROR, "Unexpected SessionException thrown while awaiting session opening", se); } } return true; Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoConsumersException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoConsumersException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoConsumersException.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoConsumersException.java Sat Nov 19 21:19:11 2016 @@ -21,7 +21,7 @@ package org.apache.qpid.client; import org.apache.qpid.AMQUndeliveredException; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** * AMQNoConsumersException indicates failure to pass an immediate message to a consumer. @@ -30,6 +30,12 @@ public class AMQNoConsumersException ext { public AMQNoConsumersException(String msg, Object bounced, Throwable cause) { - super(AMQConstant.NO_CONSUMERS, msg, bounced, cause); + super(ErrorCodes.NO_CONSUMERS, msg, bounced, cause); + } + + @Override + public AMQNoConsumersException cloneForCurrentThread() + { + return new AMQNoConsumersException(getMessage(), getUndeliveredMessage(), getCause()); } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoRouteException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoRouteException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoRouteException.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQNoRouteException.java Sat Nov 19 21:19:11 2016 @@ -21,7 +21,7 @@ package org.apache.qpid.client; import org.apache.qpid.AMQUndeliveredException; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** * AMQNoRouteException indicates that a mandatory message could not be routed. @@ -30,6 +30,12 @@ public class AMQNoRouteException extends { public AMQNoRouteException(String msg, Object bounced, Throwable cause) { - super(AMQConstant.NO_ROUTE, msg, bounced, cause); + super(ErrorCodes.NO_ROUTE, msg, bounced, cause); + } + + @Override + public AMQNoRouteException cloneForCurrentThread() + { + return new AMQNoRouteException(getMessage(), getUndeliveredMessage(), getCause()); } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java Sat Nov 19 21:19:11 2016 @@ -30,18 +30,18 @@ import java.util.concurrent.CopyOnWriteA import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.qpid.client.protocol.AMQProtocolSession; -import org.apache.qpid.client.protocol.BlockingMethodFrameListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.qpid.AMQConnectionClosedException; import org.apache.qpid.AMQDisconnectedException; -import org.apache.qpid.QpidException; import org.apache.qpid.AMQException; import org.apache.qpid.AMQTimeoutException; +import org.apache.qpid.QpidException; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.client.failover.FailoverState; +import org.apache.qpid.client.protocol.AMQProtocolSession; +import org.apache.qpid.client.protocol.BlockingMethodFrameListener; import org.apache.qpid.client.state.AMQState; import org.apache.qpid.client.state.AMQStateManager; import org.apache.qpid.client.state.StateWaiter; @@ -60,7 +60,7 @@ import org.apache.qpid.framing.Heartbeat import org.apache.qpid.framing.MethodRegistry; import org.apache.qpid.framing.ProtocolInitiation; import org.apache.qpid.framing.ProtocolVersion; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.protocol.AMQMethodEvent; import org.apache.qpid.protocol.AMQMethodListener; import org.apache.qpid.thread.Threading; @@ -631,7 +631,7 @@ public class AMQProtocolHandler implemen } else { - throw new AMQException(AMQConstant.INTERNAL_ERROR, e.getMessage(), e); + throw new AMQException(ErrorCodes.INTERNAL_ERROR, e.getMessage(), e); } } } @@ -691,7 +691,7 @@ public class AMQProtocolHandler implemen try { final ConnectionCloseBody body = _protocolSession.getMethodRegistry().createConnectionCloseBody( - AMQConstant.REPLY_SUCCESS.getCode(), + ErrorCodes.REPLY_SUCCESS, // replyCode new AMQShortString("JMS client is closing the connection."), 0, Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java Sat Nov 19 21:19:11 2016 @@ -20,26 +20,28 @@ */ package org.apache.qpid.client; -import javax.jms.InvalidDestinationException; -import javax.jms.InvalidSelectorException; -import org.apache.qpid.QpidException; -import org.apache.qpid.AMQInternalException; -import org.apache.qpid.AMQException; -import org.apache.qpid.client.filter.JMSSelectorFilter; -import org.apache.qpid.client.util.JMSExceptionHelper; -import org.apache.qpid.protocol.AMQConstant; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.IllegalStateException; +import javax.jms.InvalidDestinationException; +import javax.jms.InvalidSelectorException; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; import javax.jms.QueueBrowser; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.NoSuchElementException; -import java.util.concurrent.atomic.AtomicBoolean; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.qpid.AMQException; +import org.apache.qpid.AMQInternalException; +import org.apache.qpid.QpidException; +import org.apache.qpid.client.filter.JMSSelectorFilter; +import org.apache.qpid.client.util.JMSExceptionHelper; +import org.apache.qpid.protocol.ErrorCodes; public class AMQQueueBrowser implements QueueBrowser { @@ -89,15 +91,15 @@ public class AMQQueueBrowser implements } catch (QpidException e) { - AMQConstant errorCode = (e instanceof AMQException) ? ((AMQException)e).getErrorCode() : null; - if(errorCode == AMQConstant.NOT_FOUND) + int errorCode = (e instanceof AMQException) ? ((AMQException)e).getErrorCode() : 0; + if(errorCode == ErrorCodes.NOT_FOUND) { throw new InvalidDestinationException(e.getMessage()); } else { throw JMSExceptionHelper.chainJMSException(new JMSException(e.getMessage(), - String.valueOf(errorCode.getCode())), + String.valueOf(errorCode)), e); } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession.java Sat Nov 19 21:19:11 2016 @@ -78,7 +78,7 @@ import org.apache.qpid.configuration.Cli import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.jms.ListMessage; import org.apache.qpid.jms.Session; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.thread.Threading; import org.apache.qpid.transport.SessionException; import org.apache.qpid.transport.TransportException; @@ -478,7 +478,7 @@ public abstract class AMQSession<C exten QpidException ex = getLastException(); if (ex != null) { - AMQConstant code = null; + int code = 0; if (ex instanceof AMQException) { @@ -486,7 +486,7 @@ public abstract class AMQSession<C exten } throw JMSExceptionHelper.chainJMSException(new IllegalStateException("Session has been closed", - code == null ? null : code.toString()), ex); + code == 0 ? null : Integer.toString(code)), ex); } else { @@ -2844,7 +2844,7 @@ public abstract class AMQSession<C exten } catch (TransportException e) { - throw new AMQException(AMQConstant.getConstant(getErrorCode(e)), e.getMessage(), e); + throw new AMQException(getErrorCode(e), e.getMessage(), e); } } }, _connection).execute(); @@ -3249,7 +3249,7 @@ public abstract class AMQSession<C exten } catch (TransportException e) { - throw new AMQException(AMQConstant.getConstant(getErrorCode(e)), e.getMessage(), e); + throw new AMQException(getErrorCode(e), e.getMessage(), e); } } } @@ -3741,7 +3741,7 @@ public abstract class AMQSession<C exten private int getErrorCode(TransportException e) { - int code = AMQConstant.INTERNAL_ERROR.getCode(); + int code = ErrorCodes.INTERNAL_ERROR; if (e instanceof SessionException) { SessionException se = (SessionException) e; @@ -3756,22 +3756,21 @@ public abstract class AMQSession<C exten JMSException toJMSException(String message, QpidException e) { JMSException ex; - AMQConstant errorCode = null; + int errorCode = 0; if (e instanceof AMQException) { errorCode = ((AMQException) e).getErrorCode(); } - if (errorCode == AMQConstant.ACCESS_REFUSED) + if (errorCode == ErrorCodes.ACCESS_REFUSED) { ex = JMSExceptionHelper.chainJMSException(new JMSSecurityException(message, - String.valueOf(errorCode.getCode())), e); + Integer.toString(errorCode)), e); } else { - String errorCode1 = errorCode == null ? null : String.valueOf(errorCode.getCode()); - ex = JMSExceptionHelper.chainJMSException(new JMSException(message, errorCode1), e); + ex = JMSExceptionHelper.chainJMSException(new JMSException(message, errorCode == 0 ? null : Integer.toString(errorCode)), e); } return ex; } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java Sat Nov 19 21:19:11 2016 @@ -54,7 +54,7 @@ import org.apache.qpid.client.messaging. import org.apache.qpid.client.messaging.address.Link.SubscriptionQueue; import org.apache.qpid.client.messaging.address.Node; import org.apache.qpid.common.AMQPFilterTypes; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.transport.*; import org.apache.qpid.util.Serial; import org.apache.qpid.util.Strings; @@ -851,7 +851,7 @@ public class AMQSession_0_10 extends AMQ } catch (Exception e) { - throw new AMQException(AMQConstant.INTERNAL_ERROR, "Error while trying to get the listener", e); + throw new AMQException(ErrorCodes.INTERNAL_ERROR, "Error while trying to get the listener", e); } } } @@ -1053,12 +1053,12 @@ public class AMQSession_0_10 extends AMQ synchronized (_currentExceptionLock) { ExecutionException ee = se.getException(); - int code = AMQConstant.INTERNAL_ERROR.getCode(); + int code = ErrorCodes.INTERNAL_ERROR; if (ee != null) { code = ee.getErrorCode().getValue(); } - QpidException amqe = new AMQException(AMQConstant.getConstant(code), _isHardError, se.getMessage(), se.getCause()); + QpidException amqe = new AMQException(code, _isHardError, se.getMessage(), se.getCause()); _currentException = amqe; } if (!_isHardError) @@ -1173,7 +1173,7 @@ public class AMQSession_0_10 extends AMQ } else { - throw new AMQException(AMQConstant.getConstant(underlying.getErrorCode().getValue()), + throw new AMQException(underlying.getErrorCode().getValue(), "Error querying queue", e); } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java Sat Nov 19 21:19:11 2016 @@ -63,7 +63,7 @@ import org.apache.qpid.common.AMQPFilter import org.apache.qpid.configuration.ClientProperties; import org.apache.qpid.framing.*; import org.apache.qpid.jms.Session; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.protocol.AMQMethodEvent; import org.apache.qpid.transport.TransportException; import org.apache.qpid.util.Strings; @@ -242,7 +242,7 @@ public class AMQSession_0_8 extends AMQS getProtocolHandler().closeSession(this); getProtocolHandler().syncWrite(getProtocolHandler().getMethodRegistry() - .createChannelCloseBody(AMQConstant.REPLY_SUCCESS.getCode(), + .createChannelCloseBody(ErrorCodes.REPLY_SUCCESS, new AMQShortString( "JMS client closing channel"), 0, 0) .generateFrame(getChannelId()), @@ -772,25 +772,25 @@ public class AMQSession_0_8 extends AMQS _queueDestinationCache, _topicDestinationCache, AMQDestination.UNKNOWN_TYPE); - AMQConstant errorCode = AMQConstant.getConstant(msg.getReplyCode()); + int replyCode = msg.getReplyCode(); AMQShortString reason = msg.getReplyText(); - _logger.debug("Message returned with error code " + errorCode + " (" + reason + ")"); + _logger.debug("Message returned with error code " + replyCode + " (" + reason + ")"); // @TODO should this be moved to an exception handler of sorts. Somewhere errors are converted to correct execeptions. - if (errorCode == AMQConstant.NO_CONSUMERS) + if (replyCode == ErrorCodes.NO_CONSUMERS) { getAMQConnection().exceptionReceived(new AMQNoConsumersException("Error: " + reason, bouncedMessage, null)); } - else if (errorCode == AMQConstant.NO_ROUTE) + else if (replyCode == ErrorCodes.NO_ROUTE) { getAMQConnection().exceptionReceived(new AMQNoRouteException("Error: " + reason, bouncedMessage, null)); } else { getAMQConnection().exceptionReceived( - new AMQUndeliveredException(errorCode, "Error: " + reason, bouncedMessage, null)); + new AMQUndeliveredException(replyCode, "Error: " + reason, bouncedMessage, null)); } } @@ -1150,7 +1150,7 @@ public class AMQSession_0_8 extends AMQS final String queue, final String exchange) throws QpidException { - new FailoverNoopSupport<Object, QpidException>(new FailoverProtectedOperation<Object, QpidException>() + new FailoverNoopSupport<>(new FailoverProtectedOperation<Object, QpidException>() { public Object execute() throws QpidException, FailoverException { @@ -1160,7 +1160,7 @@ public class AMQSession_0_8 extends AMQS if(ProtocolVersion.v0_8.equals(getProtocolVersion())) { - throw new AMQException(AMQConstant.NOT_IMPLEMENTED, "Cannot unbind a queue in AMQP 0-8"); + throw new AMQException(ErrorCodes.NOT_IMPLEMENTED, "Cannot unbind a queue in AMQP 0-8"); } MethodRegistry methodRegistry = getProtocolHandler().getMethodRegistry(); @@ -1427,8 +1427,7 @@ public class AMQSession_0_8 extends AMQS } else { - return new AMQException(AMQConstant.getConstant(AMQConstant.INTERNAL_ERROR.getCode()), - e.getMessage(), e.getCause()); + return new AMQException(ErrorCodes.INTERNAL_ERROR, e.getMessage(), e.getCause()); } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java Sat Nov 19 21:19:11 2016 @@ -39,7 +39,7 @@ import org.apache.qpid.client.message.Un import org.apache.qpid.client.util.JMSExceptionHelper; import org.apache.qpid.common.ServerPropertyNames; import org.apache.qpid.jms.Session; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.transport.Acquired; import org.apache.qpid.transport.MessageCreditUnit; import org.apache.qpid.transport.Option; @@ -231,7 +231,7 @@ public class BasicMessageConsumer_0_10 e } catch (Exception e) { - throw new AMQException(AMQConstant.INTERNAL_ERROR, "Error when evaluating message selector", e); + throw new AMQException(ErrorCodes.INTERNAL_ERROR, "Error when evaluating message selector", e); } if (_logger.isDebugEnabled()) Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java Sat Nov 19 21:19:11 2016 @@ -34,7 +34,7 @@ import org.apache.qpid.framing.AMQFrame; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.ChannelCloseBody; import org.apache.qpid.framing.ChannelCloseOkBody; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; public class ChannelCloseMethodHandler implements StateAwareMethodListener<ChannelCloseBody> { @@ -52,11 +52,11 @@ public class ChannelCloseMethodHandler i { _logger.debug("ChannelClose method received"); - AMQConstant errorCode = AMQConstant.getConstant(method.getReplyCode()); + int replyCode = method.getReplyCode(); AMQShortString reason = method.getReplyText(); if (_logger.isDebugEnabled()) { - _logger.debug("Channel close reply code: " + errorCode + ", reason: " + reason); + _logger.debug("Channel close reply code: " + replyCode + ", reason: " + reason); } ChannelCloseOkBody body = session.getMethodRegistry().createChannelCloseOkBody(); @@ -64,28 +64,28 @@ public class ChannelCloseMethodHandler i session.writeFrame(frame); try { - if (errorCode != AMQConstant.REPLY_SUCCESS) + if (replyCode != ErrorCodes.REPLY_SUCCESS) { if (_logger.isDebugEnabled()) { - _logger.debug("Channel close received with errorCode " + errorCode + ", and reason " + reason); + _logger.debug("Channel close received with errorCode " + replyCode + ", and reason " + reason); } - if (errorCode == AMQConstant.NO_CONSUMERS) + if (replyCode == ErrorCodes.NO_CONSUMERS) { throw new AMQNoConsumersException("Error: " + reason, null, null); } - else if (errorCode == AMQConstant.NO_ROUTE) + else if (replyCode == ErrorCodes.NO_ROUTE) { throw new AMQNoRouteException("Error: " + reason, null, null); } - else if (errorCode == AMQConstant.ARGUMENT_INVALID) + else if (replyCode == ErrorCodes.ARGUMENT_INVALID) { _logger.debug("Broker responded with Invalid Argument."); throw new org.apache.qpid.AMQInvalidArgumentException(String.valueOf(reason), null); } - else if (errorCode == AMQConstant.INVALID_ROUTING_KEY) + else if (replyCode == ErrorCodes.INVALID_ROUTING_KEY) { _logger.debug("Broker responded with Invalid Routing Key."); @@ -94,7 +94,7 @@ public class ChannelCloseMethodHandler i else { - throw new AMQChannelClosedException(errorCode, "Error: " + reason, null); + throw new AMQChannelClosedException(replyCode, "Error: " + reason, null); } } @@ -114,7 +114,7 @@ public class ChannelCloseMethodHandler i // have problems during the session close as it will attempt to // close the session that the broker has closed, - session.channelClosed(channelId, errorCode, String.valueOf(reason)); + session.channelClosed(channelId, replyCode, String.valueOf(reason)); } } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseOkMethodHandler.java Sat Nov 19 21:19:11 2016 @@ -27,7 +27,7 @@ import org.apache.qpid.QpidException; import org.apache.qpid.client.protocol.AMQProtocolSession; import org.apache.qpid.client.state.StateAwareMethodListener; import org.apache.qpid.framing.ChannelCloseOkBody; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; public class ChannelCloseOkMethodHandler implements StateAwareMethodListener<ChannelCloseOkBody> { @@ -45,6 +45,6 @@ public class ChannelCloseOkMethodHandler { _logger.info("Received channel-close-ok for channel-id " + channelId); - session.channelClosed(channelId, AMQConstant.REPLY_SUCCESS, "Channel closed successfully"); + session.channelClosed(channelId, ErrorCodes.REPLY_SUCCESS, "Channel closed successfully"); } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java Sat Nov 19 21:19:11 2016 @@ -32,7 +32,7 @@ import org.apache.qpid.client.state.Stat import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.ConnectionCloseBody; import org.apache.qpid.framing.ConnectionCloseOkBody; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.transport.ByteBufferSender; import org.apache.qpid.transport.TransportException; @@ -56,7 +56,7 @@ public class ConnectionCloseMethodHandle { _logger.info("ConnectionClose frame received"); - AMQConstant errorCode = AMQConstant.getConstant(method.getReplyCode()); + int replyCode = method.getReplyCode(); AMQShortString reason = method.getReplyText(); QpidException error = null; @@ -69,25 +69,25 @@ public class ConnectionCloseMethodHandle // Be aware of possible changes to parameter order as versions change. session.writeFrame(closeOkBody.generateFrame(0)); - if (errorCode != AMQConstant.REPLY_SUCCESS) + if (replyCode != ErrorCodes.REPLY_SUCCESS) { - if (errorCode == AMQConstant.NOT_ALLOWED) + if (replyCode == ErrorCodes.NOT_ALLOWED) { - _logger.info("Error :" + errorCode + ":" + Thread.currentThread().getName()); + _logger.info("Error :" + replyCode + ":" + Thread.currentThread().getName()); - error = new AMQAuthenticationException(errorCode, reason == null ? null : reason.toString(), null); + error = new AMQAuthenticationException(reason == null ? null : reason.toString(), null); } - else if (errorCode == AMQConstant.ACCESS_REFUSED) + else if (replyCode == ErrorCodes.ACCESS_REFUSED) { - _logger.info("Error :" + errorCode + ":" + Thread.currentThread().getName()); + _logger.info("Error :" + replyCode + ":" + Thread.currentThread().getName()); error = new AMQSecurityException(reason == null ? null : reason.toString(), null); } else { - _logger.info("Connection close received with error code " + errorCode); + _logger.info("Connection close received with error code " + replyCode); - error = new AMQConnectionClosedException(errorCode, "Error: " + reason, null); + error = new AMQConnectionClosedException(replyCode, "Error: " + reason, null); } } } Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java (original) +++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java Sat Nov 19 21:19:11 2016 @@ -26,13 +26,13 @@ import java.util.concurrent.ConcurrentMa import javax.jms.JMSException; import javax.security.sasl.SaslClient; -import org.apache.qpid.client.AMQProtocolHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.qpid.QpidException; import org.apache.qpid.AMQException; +import org.apache.qpid.QpidException; import org.apache.qpid.client.AMQConnection; +import org.apache.qpid.client.AMQProtocolHandler; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.ConnectionTuneParameters; import org.apache.qpid.client.handler.ClientMethodDispatcherImpl; @@ -51,7 +51,6 @@ import org.apache.qpid.framing.MethodDis import org.apache.qpid.framing.MethodRegistry; import org.apache.qpid.framing.ProtocolInitiation; import org.apache.qpid.framing.ProtocolVersion; -import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; import org.apache.qpid.transport.ByteBufferSender; import org.apache.qpid.transport.ConnectionSettings; @@ -348,7 +347,7 @@ public class AMQProtocolSession implemen * @return true if the client must respond to the server, i.e. if the server initiated the channel close, false if * the channel close is just the server responding to the client's earlier request to close the channel. */ - public boolean channelClosed(int channelId, AMQConstant code, String text) throws QpidException + public boolean channelClosed(int channelId, int code, String text) throws QpidException { // if this is not a response to an earlier request to close the channel @@ -372,6 +371,7 @@ public class AMQProtocolSession implemen } } + public AMQConnection getAMQConnection() { return _connection; Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java (original) +++ qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java Sat Nov 19 21:19:11 2016 @@ -95,7 +95,7 @@ public class AMQConnectionUnitTest exten } JMSException exception = receivedException.get(); assertNotNull("Expected JMSException but got null", exception); - assertEquals("JMSException error code is incorrect", Integer.toString(expectedException.getErrorCode().getCode()), exception.getErrorCode()); + assertEquals("JMSException error code is incorrect", Integer.toString(expectedException.getErrorCode()), exception.getErrorCode()); assertNotNull("Expected not null message for JMSException", exception.getMessage()); assertTrue("JMSException error message is incorrect", exception.getMessage().contains(expectedException.getMessage())); assertEquals("JMSException linked exception is incorrect", expectedException, exception.getLinkedException()); Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java (original) +++ qpid/java/trunk/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java Sat Nov 19 21:19:11 2016 @@ -27,14 +27,13 @@ import java.net.UnknownHostException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.qpid.AMQException; -import org.apache.qpid.client.AMQProtocolHandler; -import org.apache.qpid.test.utils.QpidTestCase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.apache.qpid.AMQException; import org.apache.qpid.QpidException; import org.apache.qpid.client.AMQAuthenticationException; +import org.apache.qpid.client.AMQProtocolHandler; import org.apache.qpid.client.MockAMQConnection; import org.apache.qpid.client.state.AMQState; import org.apache.qpid.client.transport.TestNetworkConnection; @@ -43,7 +42,8 @@ import org.apache.qpid.framing.AMQFrame; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.BasicRecoverSyncOkBody; import org.apache.qpid.framing.ProtocolVersion; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; +import org.apache.qpid.test.utils.QpidTestCase; /** * This is a test address QPID-1431 where frame listeners would fail to be notified of an incomming exception. @@ -102,8 +102,8 @@ public class AMQProtocolHandlerTest exte */ public void testFrameListenerUpdateWithAMQException() throws InterruptedException { - AMQAuthenticationException trigger = new AMQAuthenticationException(AMQConstant.ACCESS_REFUSED, - "AMQPHTest", new RuntimeException()); + AMQAuthenticationException trigger = new AMQAuthenticationException( + "AMQPHTest", new RuntimeException()); performWithException(trigger); @@ -132,7 +132,7 @@ public class AMQProtocolHandlerTest exte performWithException(trigger); assertEquals("The _Listener did not receive the correct error code", - AMQConstant.INTERNAL_ERROR, ((AMQException)_listener.getReceivedException()).getErrorCode()); + ErrorCodes.INTERNAL_ERROR, ((AMQException)_listener.getReceivedException()).getErrorCode()); } Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java (original) +++ qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseMethodHandlerNoCloseOk.java Sat Nov 19 21:19:11 2016 @@ -33,7 +33,7 @@ import org.apache.qpid.client.protocol.A import org.apache.qpid.client.state.StateAwareMethodListener; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.ChannelCloseBody; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; public class ChannelCloseMethodHandlerNoCloseOk implements StateAwareMethodListener<ChannelCloseBody> { @@ -51,35 +51,35 @@ public class ChannelCloseMethodHandlerNo { _logger.debug("ChannelClose method received"); - AMQConstant errorCode = AMQConstant.getConstant(method.getReplyCode()); + int replyCode = method.getReplyCode(); AMQShortString reason = method.getReplyText(); if (_logger.isDebugEnabled()) { - _logger.debug("Channel close reply code: " + errorCode + ", reason: " + reason); + _logger.debug("Channel close reply code: " + replyCode + ", reason: " + reason); } // For this test Method Handler .. don't send Close-OK // // TODO: Be aware of possible changes to parameter order as versions change. // AMQFrame frame = ChannelCloseOkBody.createAMQFrame(evt.getChannelId(), method.getMajor(), method.getMinor()); // protocolSession.writeFrame(frame); - if (errorCode != AMQConstant.REPLY_SUCCESS) + if (replyCode != ErrorCodes.REPLY_SUCCESS) { - _logger.error("Channel close received with errorCode " + errorCode + ", and reason " + reason); - if (errorCode == AMQConstant.NO_CONSUMERS) + _logger.error("Channel close received with errorCode " + replyCode + ", and reason " + reason); + if (replyCode == ErrorCodes.NO_CONSUMERS) { throw new AMQNoConsumersException("Error: " + reason, null, null); } - else if (errorCode == AMQConstant.NO_ROUTE) + else if (replyCode == ErrorCodes.NO_ROUTE) { throw new AMQNoRouteException("Error: " + reason, null, null); } - else if (errorCode == AMQConstant.ARGUMENT_INVALID) + else if (replyCode == ErrorCodes.ARGUMENT_INVALID) { _logger.debug("Broker responded with Invalid Argument."); throw new AMQInvalidArgumentException(String.valueOf(reason), null); } - else if (errorCode == AMQConstant.INVALID_ROUTING_KEY) + else if (replyCode == ErrorCodes.INVALID_ROUTING_KEY) { _logger.debug("Broker responded with Invalid Routing Key."); @@ -87,11 +87,11 @@ public class ChannelCloseMethodHandlerNo } else { - throw new AMQChannelClosedException(errorCode, "Error: " + reason, null); + throw new AMQChannelClosedException(replyCode, "Error: " + reason, null); } } - session.channelClosed(channelId, errorCode, String.valueOf(reason)); + session.channelClosed(channelId, replyCode, String.valueOf(reason)); } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQChannelClosedException.java Sat Nov 19 21:19:11 2016 @@ -20,14 +20,12 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; - /** * AMQChannelClosedException indicates that an operation cannot be performed becauase a channel has been closed. */ public class AMQChannelClosedException extends AMQException { - public AMQChannelClosedException(AMQConstant errorCode, String msg, Throwable cause) + public AMQChannelClosedException(int errorCode, String msg, Throwable cause) { super(errorCode, msg, cause); } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionClosedException.java Sat Nov 19 21:19:11 2016 @@ -20,8 +20,6 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; - /** * AMQConnectionClosedException indicates that a connection has been closed. * @@ -30,7 +28,7 @@ import org.apache.qpid.protocol.AMQConst */ public class AMQConnectionClosedException extends AMQException { - public AMQConnectionClosedException(AMQConstant errorCode, String msg, Throwable cause) + public AMQConnectionClosedException(int errorCode, String msg, Throwable cause) { super(errorCode, msg, cause); } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQConnectionException.java Sat Nov 19 21:19:11 2016 @@ -22,10 +22,8 @@ package org.apache.qpid; import org.apache.qpid.framing.AMQFrame; -import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.MethodRegistry; -import org.apache.qpid.protocol.AMQConstant; /** * AMQConnectionException indicates that an error that requires the channel to be closed has occurred. @@ -37,12 +35,7 @@ public class AMQConnectionException exte private final MethodRegistry _methodRegistry; - public AMQConnectionException(AMQConstant errorCode, String msg, AMQMethodBody body, MethodRegistry methodRegistry) - { - this(errorCode, msg, body.getClazz(), body.getMethod(), methodRegistry, null); - } - - public AMQConnectionException(AMQConstant errorCode, String msg, int classId, int methodId, MethodRegistry methodRegistry, + public AMQConnectionException(int errorCode, String msg, int classId, int methodId, MethodRegistry methodRegistry, Throwable cause) { super(errorCode, msg, cause); @@ -52,14 +45,20 @@ public class AMQConnectionException exte } + public AMQFrame getCloseFrame() { return new AMQFrame(0, - _methodRegistry.createConnectionCloseBody(getErrorCode().getCode(), + _methodRegistry.createConnectionCloseBody(getErrorCode(), AMQShortString.validValueOf(getMessage()), _classId, _methodId)); } + @Override + public AMQException cloneForCurrentThread() + { + return new AMQConnectionException(getErrorCode(), getMessage(), _classId, _methodId, _methodRegistry, getCause()); + } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQException.java Sat Nov 19 21:19:11 2016 @@ -18,33 +18,28 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; public class AMQException extends QpidException { - private final AMQConstant _errorCode; + private final int _errorCode; private final boolean _isHardError; - public AMQException(final AMQConstant errorCode, final String message) + public AMQException(final int errorCode, final String message) { this(errorCode, message, null); } - /** - * Constructor for a Protocol Exception - * - * @param msg A description of the reason of this exception . - * @param errorCode A string specifying the error code of this exception. - * @param cause The linked Execption. - */ - public AMQException(AMQConstant errorCode, String msg, Throwable cause) + + public AMQException(int errorCode, String msg, Throwable cause) { this(errorCode, true, msg, cause); } - public AMQException(final AMQConstant errorCode, + + public AMQException(final int errorCode, final boolean isHardError, final String message, final Throwable cause) @@ -55,18 +50,14 @@ public class AMQException extends QpidEx } + @Override public String toString() { - return getClass().getName() + ": " + getMessage() + (_errorCode == null ? "" : " [error code " + _errorCode + "]"); + return getClass().getName() + ": " + getMessage() + (_errorCode == 0 ? "" : " [error code: " + _errorCode + "("+getDefaultDescription(_errorCode) + ")]"); } - /** - * Gets the AMQ protocol exception code associated with this exception. - * - * @return The AMQ protocol exception code associated with this exception. - */ - public AMQConstant getErrorCode() + public int getErrorCode() { return _errorCode; } @@ -80,7 +71,7 @@ public class AMQException extends QpidEx public AMQException cloneForCurrentThread() { Class amqeClass = this.getClass(); - Class<?>[] paramClasses = {AMQConstant.class, String.class, Throwable.class}; + Class<?>[] paramClasses = {Integer.TYPE, String.class, Throwable.class}; Object[] params = {_errorCode, getMessage(), this}; AMQException newAMQE; @@ -97,4 +88,62 @@ public class AMQException extends QpidEx return newAMQE; } + + private static String getDefaultDescription(int errorCode) + { + switch(errorCode) + { + case ErrorCodes.REPLY_SUCCESS: + return "reply success"; + case ErrorCodes.NOT_DELIVERED: + return "not delivered"; + case ErrorCodes.MESSAGE_TOO_LARGE: + return "message too large"; + case ErrorCodes.NO_ROUTE: + return "no route"; + case ErrorCodes.NO_CONSUMERS: + return "no consumers"; + case ErrorCodes.CONNECTION_FORCED: + return "connection forced"; + case ErrorCodes.INVALID_PATH: + return "invalid path"; + case ErrorCodes.ACCESS_REFUSED: + return "access refused"; + case ErrorCodes.NOT_FOUND: + return "not found"; + case ErrorCodes.ALREADY_EXISTS: + return "Already exists"; + case ErrorCodes.IN_USE: + return "In use"; + case ErrorCodes.INVALID_ROUTING_KEY: + return "routing key invalid"; + case ErrorCodes.REQUEST_TIMEOUT: + return "Request Timeout"; + case ErrorCodes.ARGUMENT_INVALID: + return "argument invalid"; + case ErrorCodes.FRAME_ERROR: + return "frame error"; + case ErrorCodes.SYNTAX_ERROR: + return "syntax error"; + case ErrorCodes.COMMAND_INVALID: + return "command invalid"; + case ErrorCodes.CHANNEL_ERROR: + return "channel error"; + case ErrorCodes.RESOURCE_ERROR: + return "resource error"; + case ErrorCodes.NOT_ALLOWED: + return "not allowed"; + case ErrorCodes.NOT_IMPLEMENTED: + return "not implemented"; + case ErrorCodes.INTERNAL_ERROR: + return "internal error"; + case ErrorCodes.INVALID_ARGUMENT: + return "invalid argument"; + case ErrorCodes.UNSUPPORTED_CLIENT_PROTOCOL_ERROR: + return "client unsupported protocol"; + default: + return "<<unknown>>"; + } + } + } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInternalException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInternalException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInternalException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInternalException.java Sat Nov 19 21:19:11 2016 @@ -20,10 +20,10 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** - * InternalException encapsulates error code 541, or {@link AMQConstant#INTERNAL_ERROR} exceptions relating to the + * InternalException encapsulates error code 541, or {@link ErrorCodes#INTERNAL_ERROR} exceptions relating to the * AMQ protocol. It is used to report internal failures and errors that occur within the broker. */ public class AMQInternalException extends AMQException @@ -39,11 +39,12 @@ public class AMQInternalException extend */ public AMQInternalException(String msg, Throwable cause) { - super(AMQConstant.INTERNAL_ERROR, ((msg == null) ? "Internal error" : msg), cause); + super(ErrorCodes.INTERNAL_ERROR, ((msg == null) ? "Internal error" : msg), cause); } - - public AMQInternalException(String msg) + + @Override + public AMQInternalException cloneForCurrentThread() { - this(msg, null); + return new AMQInternalException(getMessage(), getCause()); } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidArgumentException.java Sat Nov 19 21:19:11 2016 @@ -20,7 +20,7 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** * AMQInvalidArgumentException indicates that an invalid argument has been passed to an AMQP method. @@ -29,7 +29,13 @@ public class AMQInvalidArgumentException { public AMQInvalidArgumentException(String message, Throwable cause) { - super(AMQConstant.ARGUMENT_INVALID, message, cause); + super(ErrorCodes.ARGUMENT_INVALID, message, cause); + } + + @Override + public AMQInvalidArgumentException cloneForCurrentThread() + { + return new AMQInvalidArgumentException(getMessage(), getCause()); } public boolean isHardError() Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQInvalidRoutingKeyException.java Sat Nov 19 21:19:11 2016 @@ -20,7 +20,7 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** * AMQInvalidRoutingKeyException indicates an error with a routing key having an invalid format. @@ -29,6 +29,12 @@ public class AMQInvalidRoutingKeyExcepti { public AMQInvalidRoutingKeyException(String message, Throwable cause) { - super(AMQConstant.INVALID_ROUTING_KEY, message, cause); + super(ErrorCodes.INVALID_ROUTING_KEY, message, cause); + } + + @Override + public AMQInvalidRoutingKeyException cloneForCurrentThread() + { + return new AMQInvalidRoutingKeyException(getMessage(), getCause()); } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQProtocolException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQProtocolException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQProtocolException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQProtocolException.java Sat Nov 19 21:19:11 2016 @@ -20,7 +20,7 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; public class AMQProtocolException extends AMQException { @@ -28,13 +28,17 @@ public class AMQProtocolException extend * Constructor for a Protocol Exception * <p> This is the only provided constructor and the parameters have to be * set to null when they are unknown. - * - * @param msg A description of the reason of this exception . - * @param errorCode A string specifyin the error code of this exception. + * @param msg A description of the reason of this exception . * @param cause The linked Execption. */ - public AMQProtocolException(AMQConstant errorCode, String msg, Throwable cause) + public AMQProtocolException(String msg, Throwable cause) { - super(errorCode, msg, cause); + super(ErrorCodes.UNSUPPORTED_CLIENT_PROTOCOL_ERROR, msg, cause); + } + + @Override + public AMQProtocolException cloneForCurrentThread() + { + return new AMQProtocolException(getMessage(), getCause()); } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQSecurityException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQSecurityException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQSecurityException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQSecurityException.java Sat Nov 19 21:19:11 2016 @@ -20,10 +20,10 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** - * SecurityException encapsulates error code 403, or {@link AMQConstant#ACCESS_REFUSED} exceptions relating to the + * SecurityException encapsulates error code 403, or {@link ErrorCodes#ACCESS_REFUSED} exceptions relating to the * AMQ protocol. It is used to report authorisation failures and security errors. */ public class AMQSecurityException extends AMQException @@ -39,7 +39,12 @@ public class AMQSecurityException extend */ public AMQSecurityException(String msg, Throwable cause) { - super(AMQConstant.ACCESS_REFUSED, ((msg == null) ? "Permission denied" : msg), cause); + super(ErrorCodes.ACCESS_REFUSED, ((msg == null) ? "Permission denied" : msg), cause); } + @Override + public AMQSecurityException cloneForCurrentThread() + { + return new AMQSecurityException(getMessage(), getCause()); + } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQTimeoutException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQTimeoutException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQTimeoutException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQTimeoutException.java Sat Nov 19 21:19:11 2016 @@ -20,7 +20,7 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** * AMQTimeoutException indicates that an expected response from a broker took too long. @@ -29,6 +29,12 @@ public class AMQTimeoutException extends { public AMQTimeoutException(String message, Throwable cause) { - super(AMQConstant.REQUEST_TIMEOUT, message, cause); + super(ErrorCodes.REQUEST_TIMEOUT, message, cause); + } + + @Override + public AMQTimeoutException cloneForCurrentThread() + { + return new AMQTimeoutException(getMessage(), getCause()); } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/AMQUndeliveredException.java Sat Nov 19 21:19:11 2016 @@ -20,8 +20,6 @@ */ package org.apache.qpid; -import org.apache.qpid.protocol.AMQConstant; - /** * AMQUndeliveredException indicates that a message, marked immediate or mandatory, could not be delivered. */ @@ -29,7 +27,7 @@ public class AMQUndeliveredException ext { private Object _bounced; - public AMQUndeliveredException(AMQConstant errorCode, String msg, Object bounced, Throwable cause) + public AMQUndeliveredException(int errorCode, String msg, Object bounced, Throwable cause) { super(errorCode, msg, cause); @@ -45,5 +43,10 @@ public class AMQUndeliveredException ext { return false; } - + + @Override + public AMQUndeliveredException cloneForCurrentThread() + { + return new AMQUndeliveredException(getErrorCode(), getMessage(), getUndeliveredMessage(), getCause()); + } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/QpidException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/QpidException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/QpidException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/QpidException.java Sat Nov 19 21:19:11 2016 @@ -46,7 +46,7 @@ public class QpidException extends Excep * Rethrown this exception as a new exception. * * Attempt to create a new exception of the same class if they have the default constructor of: - * {AMQConstant.class, String.class, Throwable.class}. + * {String, Throwable}. * * @return cloned exception */ Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java Sat Nov 19 21:19:11 2016 @@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory; import org.apache.qpid.bytebuffer.QpidByteBuffer; import org.apache.qpid.framing.*; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** * AMQDecoder delegates the decoding of AMQP either to a data block decoder, or in the case of new connections, to a @@ -54,7 +54,8 @@ public abstract class AMQDecoder<T exten private boolean _firstRead = true; - private int _maxFrameSize = AMQConstant.FRAME_MIN_SIZE.getCode(); + public static final int FRAME_MIN_SIZE = 4096; + private int _maxFrameSize = FRAME_MIN_SIZE; /** * Creates a new AMQP decoder. @@ -147,8 +148,8 @@ public abstract class AMQDecoder<T exten final long bodySize = ((long)in.getInt(in.position()+3)) & 0xffffffffL; if (bodySize > _maxFrameSize) { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, - "Incoming frame size of " + throw new AMQFrameDecodingException( + "Incoming frame size of " + bodySize + " is larger than negotiated maximum of " + _maxFrameSize); @@ -170,8 +171,8 @@ public abstract class AMQDecoder<T exten // bodySize can be zero if ((channel < 0) || (bodySize < 0)) { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, - "Undecodable frame: type = " + type + " channel = " + channel + throw new AMQFrameDecodingException( + "Undecodable frame: type = " + type + " channel = " + channel + " bodySize = " + bodySize); } @@ -180,8 +181,8 @@ public abstract class AMQDecoder<T exten byte marker = in.get(); if ((marker & 0xFF) != 0xCE) { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, - "End of frame marker not found. Read " + marker + " length=" + bodySize + throw new AMQFrameDecodingException( + "End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type); } @@ -205,7 +206,7 @@ public abstract class AMQDecoder<T exten HeartbeatBody.process(channel, in, _methodProcessor, bodySize); break; default: - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, "Unsupported frame type: " + type); + throw new AMQFrameDecodingException("Unsupported frame type: " + type); } } @@ -218,7 +219,7 @@ public abstract class AMQDecoder<T exten final int methodId, ProtocolVersion protocolVersion) { - return new AMQFrameDecodingException(AMQConstant.COMMAND_INVALID, + return new AMQFrameDecodingException(ErrorCodes.COMMAND_INVALID, "Method " + methodId + " unknown in AMQP version " @@ -227,7 +228,7 @@ public abstract class AMQDecoder<T exten + classId + " method " + methodId - + "."); + + ".", null); } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java Sat Nov 19 21:19:11 2016 @@ -21,7 +21,7 @@ package org.apache.qpid.framing; import org.apache.qpid.AMQException; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; /** * AMQFrameDecodingException indicates that an AMQP frame cannot be decoded because it does not have the correct @@ -29,14 +29,20 @@ import org.apache.qpid.protocol.AMQConst */ public class AMQFrameDecodingException extends AMQException { - public AMQFrameDecodingException(AMQConstant errorCode, String message, Throwable cause) + public AMQFrameDecodingException(String message, Throwable cause) { - super(errorCode, message, cause); + super(ErrorCodes.FRAME_ERROR, message, cause); + } + + public AMQFrameDecodingException(String message) + { + super(ErrorCodes.FRAME_ERROR, message, null); } - public AMQFrameDecodingException(AMQConstant errorCode, String message) + + public AMQFrameDecodingException(int errorCode, String message, final Throwable cause) { - super(errorCode, message, null); + super(errorCode, message, cause); } } Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java Sat Nov 19 21:19:11 2016 @@ -22,7 +22,6 @@ package org.apache.qpid.framing; import org.apache.qpid.QpidException; import org.apache.qpid.bytebuffer.QpidByteBuffer; -import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.protocol.AMQVersionAwareProtocolSession; import org.apache.qpid.transport.ByteBufferSender; @@ -175,7 +174,7 @@ public class ContentHeaderBody implement if (classId != CLASS_ID) { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, "Unsupported content header class id: " + classId, null); + throw new AMQFrameDecodingException("Unsupported content header class id: " + classId, null); } properties = new BasicContentHeaderProperties(); properties.populatePropertiesFromBuffer(buffer, propertyFlags, (int)(size-14)); Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java Sat Nov 19 21:19:11 2016 @@ -21,7 +21,6 @@ package org.apache.qpid.framing; import org.apache.qpid.bytebuffer.QpidByteBuffer; -import org.apache.qpid.protocol.AMQConstant; public class ContentHeaderPropertiesFactory { @@ -50,7 +49,7 @@ public class ContentHeaderPropertiesFact } else { - throw new AMQFrameDecodingException(AMQConstant.FRAME_ERROR, "Unsupport content header class id: " + classId, null); + throw new AMQFrameDecodingException("Unsupport content header class id: " + classId, null); } properties.populatePropertiesFromBuffer(buffer, propertyFlags, size); return properties; Copied: qpid/java/trunk/common/src/main/java/org/apache/qpid/protocol/ErrorCodes.java (from r1770513, qpid/java/trunk/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java) URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/protocol/ErrorCodes.java?p2=qpid/java/trunk/common/src/main/java/org/apache/qpid/protocol/ErrorCodes.java&p1=qpid/java/trunk/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java&r1=1770513&r2=1770514&rev=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java (original) +++ qpid/java/trunk/common/src/main/java/org/apache/qpid/protocol/ErrorCodes.java Sat Nov 19 21:19:11 2016 @@ -20,208 +20,116 @@ */ package org.apache.qpid.protocol; -import org.apache.qpid.framing.AMQShortString; - -import java.util.HashMap; -import java.util.Map; - /** - * Defines constants for AMQP codes and also acts as a factory for creating such constants from the raw codes. Each - * constant also defines a short human readable description of the constant. - * <p> - * TODO Why would a constant be defined that is not in the map? Seems more natural that getConstant should raise an - * exception for an unknown constant. Or else provide an explanation of why this is so. Also, there is no way for - * callers to determine the unknown status of a code except by comparing its name to "unknown code", which would - * seem to render this scheme a little bit pointless? - * <p> - * TODO Java has a nice enum construct for doing this sort of thing. Maybe this is done in the old style for Java 1.4 - * backward compatability? Now that is handled through retrotranslater it may be time to use enum. + * Defines constants for AMQP codes */ -public final class AMQConstant +public interface ErrorCodes { - /** Defines a map from codes to constants. */ - private static Map<Integer, AMQConstant> _codeMap = new HashMap<Integer, AMQConstant>(); - /** Indicates that the method completed successfully. */ - public static final AMQConstant REPLY_SUCCESS = new AMQConstant(200, "reply success", true); - - public static final AMQConstant FRAME_END = new AMQConstant(206, "frame end", true); + int REPLY_SUCCESS = 200; /** * The client asked for a specific message that is no longer available. The message was delivered to another * client, or was purged from the queue for some other reason. */ - public static final AMQConstant NOT_DELIVERED = new AMQConstant(310, "not delivered", true); + int NOT_DELIVERED = 310; /** * The client attempted to transfer content larger than the server could accept at the present time. The client * may retry at a later time. */ - public static final AMQConstant MESSAGE_TOO_LARGE = new AMQConstant(311, "message too large", true); + int MESSAGE_TOO_LARGE = 311; /** * When the exchange cannot route the result of a .Publish, most likely due to an invalid routing key. Only when * the mandatory flag is set. */ - public static final AMQConstant NO_ROUTE = new AMQConstant(312, "no route", true); + int NO_ROUTE = 312; /** * When the exchange cannot deliver to a consumer when the immediate flag is set. As a result of pending data on * the queue or the absence of any consumers of the queue. */ - public static final AMQConstant NO_CONSUMERS = new AMQConstant(313, "no consumers", true); + int NO_CONSUMERS = 313; /** * An operator intervened to close the connection for some reason. The client may retry at some later date. */ - public static final AMQConstant CONNECTION_FORCED = new AMQConstant(320, "connection forced", true); + int CONNECTION_FORCED = 320; /** The client tried to work with an unknown virtual host or cluster. */ - public static final AMQConstant INVALID_PATH = new AMQConstant(402, "invalid path", true); + int INVALID_PATH = 402; /** The client attempted to work with a server entity to which it has no access due to security settings. */ - public static final AMQConstant ACCESS_REFUSED = new AMQConstant(403, "access refused", true); + int ACCESS_REFUSED = 403; /** The client attempted to work with a server entity that does not exist. */ - public static final AMQConstant NOT_FOUND = new AMQConstant(404, "not found", true); + int NOT_FOUND = 404; /** * The client attempted to work with a server entity to which it has no access because another client is * working with it. */ - public static final AMQConstant ALREADY_EXISTS = new AMQConstant(405, "Already exists", true); + int ALREADY_EXISTS = 405; /** The client requested a method that was not allowed because some precondition failed. */ - public static final AMQConstant IN_USE = new AMQConstant(406, "In use", true); + int IN_USE = 406; - public static final AMQConstant INVALID_ROUTING_KEY = new AMQConstant(407, "routing key invalid", true); + int INVALID_ROUTING_KEY = 407; - public static final AMQConstant REQUEST_TIMEOUT = new AMQConstant(408, "Request Timeout", true); + int REQUEST_TIMEOUT = 408; - public static final AMQConstant ARGUMENT_INVALID = new AMQConstant(409, "argument invalid", true); + int ARGUMENT_INVALID = 409; /** * The client sent a malformed frame that the server could not decode. This strongly implies a programming error * in the client. */ - public static final AMQConstant FRAME_ERROR = new AMQConstant(501, "frame error", true); - + int FRAME_ERROR = 501; + /** * The client sent a frame that contained illegal values for one or more fields. This strongly implies a * programming error in the client. */ - public static final AMQConstant SYNTAX_ERROR = new AMQConstant(502, "syntax error", true); + int SYNTAX_ERROR = 502; /** * The client sent an invalid sequence of frames, attempting to perform an operation that was considered invalid * by the server. This usually implies a programming error in the client. */ - public static final AMQConstant COMMAND_INVALID = new AMQConstant(503, "command invalid", true); + int COMMAND_INVALID = 503; /** * The client attempted to work with a channel that had not been correctly opened. This most likely indicates a * fault in the client layer. */ - public static final AMQConstant CHANNEL_ERROR = new AMQConstant(504, "channel error", true); + int CHANNEL_ERROR = 504; /** * The server could not complete the method because it lacked sufficient resources. This may be due to the client * creating too many of some type of entity. */ - public static final AMQConstant RESOURCE_ERROR = new AMQConstant(506, "resource error", true); - + int RESOURCE_ERROR = 506; + /** * The client tried to work with some entity in a manner that is prohibited by the server, due to security settings * or by some other criteria. */ - public static final AMQConstant NOT_ALLOWED = new AMQConstant(530, "not allowed", true); + int NOT_ALLOWED = 530; /** The client tried to use functionality that is not implemented in the server. */ - public static final AMQConstant NOT_IMPLEMENTED = new AMQConstant(540, "not implemented", true); + int NOT_IMPLEMENTED = 540; /** * The server could not complete the method because of an internal error. The server may require intervention by * an operator in order to resume normal operations. */ - public static final AMQConstant INTERNAL_ERROR = new AMQConstant(541, "internal error", true); - - public static final AMQConstant FRAME_MIN_SIZE = new AMQConstant(4096, "frame min size", true); - - public static final AMQConstant INVALID_ARGUMENT = new AMQConstant(542, "invalid argument", true); - /** - * The client imp does not support the protocol version - */ - public static final AMQConstant UNSUPPORTED_CLIENT_PROTOCOL_ERROR = new AMQConstant(543, "client unsupported protocol", true); - - /** The AMQP status code. */ - private int _code; - - /** A short description of the status code. */ - private AMQShortString _name; - - /** - * Creates a new AMQP status code. - * - * @param code The code. - * @param name A short description of the code. - * @param map <tt>true</tt> to register the code as a known code, <tt>false</tt> otherwise. - */ - private AMQConstant(int code, String name, boolean map) - { - _code = code; - _name = new AMQShortString(name); - if (map) - { - _codeMap.put(Integer.valueOf(code), this); - } - } - - /** - * Creates a constant for a status code by looking up the code in the map of known codes. If the code is not known - * a constant is still created for it, but it is marked as unknown. - * - * @param code The AMQP status code. - * - * @return The AMQP status code encapsulated as a constant. - */ - public static AMQConstant getConstant(int code) - { - AMQConstant c = _codeMap.get(Integer.valueOf(code)); - if (c == null) - { - c = new AMQConstant(code, "unknown code", false); - } - - return c; - } - - /** - * Gets the underlying AMQP status code. - * - * @return The AMQP status code. - */ - public int getCode() - { - return _code; - } - - /** - * Gets a short description of the status code. - * - * @return A short description of the status code. - */ - public AMQShortString getName() - { - return _name; - } + int INTERNAL_ERROR = 541; + int INVALID_ARGUMENT = 542; + /** - * Renders the constant as a string, mainly for debugging purposes. - * - * @return The status code and its description. + * The client impl does not support the protocol version */ - public String toString() - { - return _code + ": " + _name; - } + int UNSUPPORTED_CLIENT_PROTOCOL_ERROR = 543; } Modified: qpid/java/trunk/common/src/test/java/org/apache/qpid/QpidExceptionTest.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/test/java/org/apache/qpid/QpidExceptionTest.java?rev=1770514&r1=1770513&r2=1770514&view=diff ============================================================================== --- qpid/java/trunk/common/src/test/java/org/apache/qpid/QpidExceptionTest.java (original) +++ qpid/java/trunk/common/src/test/java/org/apache/qpid/QpidExceptionTest.java Sat Nov 19 21:19:11 2016 @@ -22,7 +22,7 @@ package org.apache.qpid; import org.apache.qpid.framing.AMQFrameDecodingException; import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.protocol.ErrorCodes; import org.apache.qpid.test.utils.QpidTestCase; /** @@ -54,8 +54,8 @@ public class QpidExceptionTest extends Q */ public void testRethrowAMQESubclass() { - AMQFrameDecodingException test = new AMQFrameDecodingException(AMQConstant.INTERNAL_ERROR, - "Error", + AMQFrameDecodingException test = new AMQFrameDecodingException( + "Error", new Exception()); QpidException e = reThrowException(test); @@ -101,7 +101,7 @@ public class QpidExceptionTest extends Q { sb.append("message [" + i + "]"); } - AMQException e = new AMQException(AMQConstant.INTERNAL_ERROR, sb.toString(), null); + AMQException e = new AMQException(ErrorCodes.INTERNAL_ERROR, sb.toString(), null); AMQShortString message = AMQShortString.validValueOf(e.getMessage()); assertEquals(sb.substring(0, AMQShortString.MAX_LENGTH - 3) + "...", message.toString()); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
