You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2017/10/02 11:21:06 UTC

qpid-broker-j git commit: QPID-7932: [Java Broker, AMQP 1.0] Further decoding improvements

Repository: qpid-broker-j
Updated Branches:
  refs/heads/master af10b7e4b -> a6a02baa7


QPID-7932: [Java Broker, AMQP 1.0] Further decoding improvements


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/a6a02baa
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/a6a02baa
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/a6a02baa

Branch: refs/heads/master
Commit: a6a02baa7e5c85c391750c5147a37e9eae343b00
Parents: af10b7e
Author: Lorenz Quack <lq...@apache.org>
Authored: Mon Oct 2 08:00:29 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Mon Oct 2 12:20:59 2017 +0100

----------------------------------------------------------------------
 .../v1_0/CompositeTypeConstructorGenerator.java |   2 +-
 .../v1_0/store/bdb/LinkKeyEntryBinding.java     |  11 +-
 .../protocol/v1_0/store/jdbc/JDBCLinkStore.java |   4 +
 .../protocol/v1_0/AMQPConnection_1_0Impl.java   |  13 +-
 .../protocol/v1_0/DeserializationFactories.java | 210 +++++++++----------
 .../protocol/v1_0/MessageMetaData_1_0.java      |   2 -
 .../protocol/v1_0/SendingLinkEndpoint.java      |   4 +-
 .../qpid/server/protocol/v1_0/Session_1_0.java  |   2 +-
 .../v1_0/StandardReceivingLinkEndpoint.java     |   2 +-
 .../protocol/v1_0/codec/ProtocolHandler.java    |   2 +-
 .../soleconn/SoleConnectionDetectionPolicy.java |  23 +-
 .../SoleConnectionEnforcementPolicy.java        |  23 +-
 .../v1_0/type/messaging/StdDistMode.java        |  22 +-
 .../v1_0/type/messaging/TerminusDurability.java |  36 ++--
 .../type/messaging/TerminusExpiryPolicy.java    |  45 ++--
 .../codec/AmqpSequenceConstructor.java          |  10 +-
 .../codec/ApplicationPropertiesConstructor.java |   9 +-
 .../type/messaging/codec/DataConstructor.java   |   9 +-
 .../codec/DeliveryAnnotationsConstructor.java   |   9 +-
 .../codec/ExactSubjectFilterConstructor.java    |   9 +-
 .../type/messaging/codec/FooterConstructor.java |   9 +-
 .../codec/JMSSelectorFilterConstructor.java     |   9 +-
 .../codec/MatchingSubjectFilterConstructor.java |   9 +-
 .../codec/MessageAnnotationsConstructor.java    |   9 +-
 .../protocol/v1_0/type/security/SaslCode.java   |  55 ++---
 .../type/transaction/TransactionErrors.java     |  34 +--
 .../v1_0/type/transaction/TxnCapability.java    |  55 ++---
 .../protocol/v1_0/type/transport/AmqpError.java | 140 +++++++------
 .../v1_0/type/transport/ConnectionError.java    |  44 ++--
 .../protocol/v1_0/type/transport/LinkError.java |  54 ++---
 .../v1_0/type/transport/ReceiverSettleMode.java |  24 ++-
 .../protocol/v1_0/type/transport/Role.java      |  24 ++-
 .../v1_0/type/transport/SenderSettleMode.java   |  35 ++--
 .../v1_0/type/transport/SessionError.java       |  44 ++--
 34 files changed, 539 insertions(+), 453 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-codegen/src/main/java/org/apache/qpid/server/protocol/v1_0/CompositeTypeConstructorGenerator.java
----------------------------------------------------------------------
diff --git a/broker-codegen/src/main/java/org/apache/qpid/server/protocol/v1_0/CompositeTypeConstructorGenerator.java b/broker-codegen/src/main/java/org/apache/qpid/server/protocol/v1_0/CompositeTypeConstructorGenerator.java
index 47308c8..2d76f5a 100644
--- a/broker-codegen/src/main/java/org/apache/qpid/server/protocol/v1_0/CompositeTypeConstructorGenerator.java
+++ b/broker-codegen/src/main/java/org/apache/qpid/server/protocol/v1_0/CompositeTypeConstructorGenerator.java
@@ -347,7 +347,7 @@ public class CompositeTypeConstructorGenerator  extends AbstractProcessor
         {
             pw.println(indent + "if (" + fieldName + " != null)");
             pw.println(indent + "{");
-            indent += "    ";
+            indent = "    " + indent;
         }
         f.accept(indent);
         if (wrap)

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-bdb-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/bdb/LinkKeyEntryBinding.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-bdb-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/bdb/LinkKeyEntryBinding.java b/broker-plugins/amqp-1-0-bdb-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/bdb/LinkKeyEntryBinding.java
index 16ba8a9..ee49b48 100644
--- a/broker-plugins/amqp-1-0-bdb-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/bdb/LinkKeyEntryBinding.java
+++ b/broker-plugins/amqp-1-0-bdb-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/bdb/LinkKeyEntryBinding.java
@@ -26,6 +26,7 @@ import com.sleepycat.bind.tuple.TupleOutput;
 
 import org.apache.qpid.server.protocol.v1_0.LinkKey;
 import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
+import org.apache.qpid.server.store.StoreException;
 
 public class LinkKeyEntryBinding extends TupleBinding<LinkKey>
 {
@@ -41,7 +42,15 @@ public class LinkKeyEntryBinding extends TupleBinding<LinkKey>
     {
         String remoteContainerId =  input.readString();
         String linkName = input.readString();
-        Role role = Role.valueOf(input.readBoolean());
+        Role role = null;
+        try
+        {
+            role = Role.valueOf(input.readBoolean());
+        }
+        catch (IllegalArgumentException e)
+        {
+            throw new StoreException("Cannot load link from store", e);
+        }
 
         final String remoteContainerId1 = remoteContainerId;
         final String linkName1 = linkName;

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java b/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
index 2539d9f..94de03c 100644
--- a/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
+++ b/broker-plugins/amqp-1-0-jdbc-store/src/main/java/org/apache/qpid/server/protocol/v1_0/store/jdbc/JDBCLinkStore.java
@@ -345,6 +345,10 @@ public class JDBCLinkStore extends AbstractLinkStore
                 links.add(new LinkDefinitionImpl<>(remoteContainerId, linkName, role, source, target));
             }
         }
+        catch (IllegalArgumentException e)
+        {
+            throw new StoreException("Cannot load links from store", e);
+        }
         return links;
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0Impl.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0Impl.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0Impl.java
index 344affb..1a91f95 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0Impl.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0Impl.java
@@ -57,6 +57,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
 import org.apache.qpid.server.common.ServerPropertyNames;
 import org.apache.qpid.server.configuration.CommonProperties;
 import org.apache.qpid.server.logging.messages.ConnectionMessages;
@@ -71,7 +72,6 @@ import org.apache.qpid.server.protocol.ConnectionClosingTicker;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.codec.FrameWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ProtocolHandler;
-import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
 import org.apache.qpid.server.protocol.v1_0.codec.SectionDecoderRegistry;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
@@ -848,7 +848,16 @@ public class AMQPConnection_1_0Impl extends AbstractAMQPConnection<AMQPConnectio
         {
             if (_remoteProperties != null && _remoteProperties.containsKey(SOLE_CONNECTION_ENFORCEMENT_POLICY))
             {
-                _soleConnectionEnforcementPolicy = SoleConnectionEnforcementPolicy.valueOf(_remoteProperties.get(SOLE_CONNECTION_ENFORCEMENT_POLICY));
+                try
+                {
+                    _soleConnectionEnforcementPolicy = SoleConnectionEnforcementPolicy.valueOf(_remoteProperties.get(
+                            SOLE_CONNECTION_ENFORCEMENT_POLICY));
+                }
+                catch (IllegalArgumentException e)
+                {
+                    closeConnection(AmqpError.INVALID_FIELD, e.getMessage());
+                    return;
+                }
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/DeserializationFactories.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/DeserializationFactories.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/DeserializationFactories.java
index f76edf4..b8b00a1 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/DeserializationFactories.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/DeserializationFactories.java
@@ -42,177 +42,169 @@ public class DeserializationFactories
     @SuppressWarnings("unused")
     public static Map<Symbol, Object> convertToNodeProperties(final Object value) throws AmqpErrorException
     {
-        if (value != null)
+        if (!(value instanceof Map))
         {
-            if (!(value instanceof Map))
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR,
+                                         String.format("Cannot construct 'node-properties' from type '%s'",
+                                                       value == null ? null : value.getClass().getSimpleName()));
+        }
+        Map<Symbol, Object> nodeProperties = new LinkedHashMap<>();
+        Map<?, ?> map = (Map<?, ?>) value;
+        for (Map.Entry<?, ?> entry : map.entrySet())
+        {
+            Object key = entry.getKey();
+            if (!(key instanceof Symbol))
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR,
-                                             String.format("Cannot construct 'node-properties' from type '%s'",
-                                                           value.getClass().getSimpleName()));
+                                             String.format(
+                                                     "'node-properties' must have only keys of type 'symbol' but got '%s'",
+                                                     key.getClass().getSimpleName()));
             }
-            Map<Symbol, Object> nodeProperties = new LinkedHashMap<>();
-            Map<?, ?> map = (Map<?, ?>) value;
-            for (Map.Entry<?,?> entry : map.entrySet())
+            if (Session_1_0.LIFETIME_POLICY.equals(key))
             {
-                Object key = entry.getKey();
-                if (!(key instanceof Symbol))
+                final Object lifetimePolicy = entry.getValue();
+                if (!(lifetimePolicy instanceof LifetimePolicy))
                 {
+                    String typeName = lifetimePolicy == null ? null : lifetimePolicy.getClass().getSimpleName();
                     throw new AmqpErrorException(AmqpError.DECODE_ERROR,
-                                                 String.format("'node-properties' must have only keys of type 'symbol' but got '%s'",
-                                                               key.getClass().getSimpleName()));
+                                                 String.format("Cannot construct 'lifetime-policy' from type '%s'",
+                                                               typeName));
                 }
-                if (Session_1_0.LIFETIME_POLICY.equals(key))
+                nodeProperties.put((Symbol) key, lifetimePolicy);
+            }
+            else if (Symbol.valueOf("supported-dist-modes").equals(key))
+            {
+                final Object distributionMode = entry.getValue();
+                final DistributionMode[] converted;
+                if (distributionMode == null)
                 {
-                    final Object lifetimePolicy = entry.getValue();
-                    if (!(lifetimePolicy instanceof LifetimePolicy))
-                    {
-                        String typeName = lifetimePolicy == null ? null : lifetimePolicy.getClass().getSimpleName();
-                        throw new AmqpErrorException(AmqpError.DECODE_ERROR,
-                                                     String.format("Cannot construct 'lifetime-policy' from type '%s'",
-                                                                   typeName));
-                    }
-                    nodeProperties.put((Symbol) key, lifetimePolicy);
+                    converted = null;
                 }
-                else if (Symbol.valueOf("supported-dist-modes").equals(key))
+                else if (distributionMode.getClass().isArray())
                 {
-                    final Object distributionMode = entry.getValue();
-                    final DistributionMode[] converted;
-                    if (distributionMode == null)
+                    converted = new DistributionMode[Array.getLength(distributionMode)];
+                    for (int i = 0; i < converted.length; ++i)
                     {
-                        converted = null;
-
-                    }
-                    else if (distributionMode.getClass().isArray())
-                    {
-                        converted = new DistributionMode[Array.getLength(distributionMode)];
-                        for (int i = 0; i < converted.length; ++i)
+                        final Object item = Array.get(distributionMode, i);
+                        if (item == null)
                         {
-                            final Object item = Array.get(distributionMode, i);
-                            if (item == null)
-                            {
-                                throw new AmqpErrorException(AmqpError.DECODE_ERROR,
-                                                             "'null' not allowed in 'supported-distribution-modes'");
-                            }
-                            converted[i] = convertToDistributionMode(item);
+                            throw new AmqpErrorException(AmqpError.DECODE_ERROR,
+                                                         "'null' not allowed in 'supported-distribution-modes'");
                         }
+                        converted[i] = convertToDistributionMode(item);
                     }
-                    else
-                    {
-                        converted = new DistributionMode[] {convertToDistributionMode(distributionMode)};
-                    }
-                    nodeProperties.put((Symbol) key, converted);
                 }
                 else
                 {
-                    nodeProperties.put((Symbol) key, entry.getValue());
+                    converted = new DistributionMode[]{convertToDistributionMode(distributionMode)};
                 }
+                nodeProperties.put((Symbol) key, converted);
+            }
+            else
+            {
+                nodeProperties.put((Symbol) key, entry.getValue());
             }
-            return nodeProperties;
-        }
-        else
-        {
-            return null;
         }
+        return nodeProperties;
     }
 
     @SuppressWarnings("unused")
     public static DistributionMode convertToDistributionMode(final Object value) throws AmqpErrorException
     {
-        DistributionMode distributionMode = null;
-        if (value != null)
+        if (value instanceof DistributionMode)
         {
-            if (value instanceof DistributionMode)
-            {
-                distributionMode = (DistributionMode) value;
-            }
-            else if (value instanceof Symbol)
+            return (DistributionMode) value;
+        }
+        else if (value instanceof Symbol)
+        {
+            try
             {
-                distributionMode = StdDistMode.valueOf(value);
-                if (distributionMode == null)
-                {
-                    distributionMode = new UnknownDistributionMode((Symbol) value);
-                }
+                return StdDistMode.valueOf(value);
             }
-            else
+            catch (IllegalArgumentException e)
             {
-                throw new AmqpErrorException(AmqpError.DECODE_ERROR,
-                                             String.format("Cannot construct 'distribution-mode' from type '%s'",
-                                                           value.getClass().getSimpleName()));
+                return new UnknownDistributionMode((Symbol) value);
             }
         }
-        return distributionMode;
+
+        final String message = String.format("Cannot construct 'distribution-mode' from type '%s'",
+                                             value == null ? null : value.getClass().getSimpleName());
+        throw new AmqpErrorException(AmqpError.DECODE_ERROR, message);
     }
 
     @SuppressWarnings("unused")
     public static TxnCapability convertToTxnCapability(final Object value) throws AmqpErrorException
     {
-        TxnCapability capability = null;
-        if (value != null)
+        if (value instanceof TxnCapability)
         {
-            if (value instanceof TxnCapability)
+            return (TxnCapability) value;
+        }
+        else if (value instanceof Symbol)
+        {
+            try
             {
-                capability = (TxnCapability) value;
+                return org.apache.qpid.server.protocol.v1_0.type.transaction.TxnCapability.valueOf(value);
             }
-            else if (value instanceof Symbol)
+            catch (IllegalArgumentException e)
             {
-                capability = org.apache.qpid.server.protocol.v1_0.type.transaction.TxnCapability.valueOf(value);
-                if (capability == null)
-                {
-                    capability = new UnknownTxnCapability((Symbol) value);
-                }
-            }
-            else
-            {
-                throw new AmqpErrorException(AmqpError.DECODE_ERROR,
-                                             String.format("Cannot construct 'txn-capability' from type '%s'",
-                                                           value.getClass().getSimpleName()));
+                return new UnknownTxnCapability((Symbol) value);
             }
         }
-        return capability;
+
+        final String message = String.format("Cannot construct 'txn-capability' from type '%s'",
+                                             value == null ? null : value.getClass().getSimpleName());
+        throw new AmqpErrorException(AmqpError.DECODE_ERROR, message);
     }
 
     @SuppressWarnings("unsued")
     public static ErrorCondition convertToErrorCondition(final Object value) throws AmqpErrorException
     {
-        ErrorCondition condition = null;
-        if (value != null)
+        if (value instanceof ErrorCondition)
+        {
+            return (ErrorCondition) value;
+        }
+        else if (value instanceof Symbol)
         {
-            if (value instanceof ErrorCondition)
+            try
             {
-                condition = (ErrorCondition) value;
+                return AmqpError.valueOf(value);
             }
-            else if (value instanceof Symbol)
+            catch (IllegalArgumentException e)
             {
-                condition = AmqpError.valueOf(value);
-                if (condition == null)
+                try
+                {
+                    return ConnectionError.valueOf(value);
+                }
+                catch (IllegalArgumentException e1)
                 {
-                    condition = ConnectionError.valueOf(value);
-                    if (condition == null)
+                    try
                     {
-                        condition = SessionError.valueOf(value);
-                        if (condition == null)
+                        return SessionError.valueOf(value);
+                    }
+                    catch (IllegalArgumentException e2)
+                    {
+                        try
+                        {
+                            return LinkError.valueOf(value);
+                        }
+                        catch (IllegalArgumentException e3)
                         {
-                            condition = LinkError.valueOf(value);
-                            if (condition == null)
+                            try
                             {
-                                condition = TransactionErrors.valueOf(value);
-                                if (condition == null)
-                                {
-                                    condition = new UnknownErrorCondition((Symbol) value);
-                                }
+                                return TransactionErrors.valueOf(value);
+                            }
+                            catch (IllegalArgumentException e4)
+                            {
+                                return new UnknownErrorCondition((Symbol) value);
                             }
                         }
                     }
                 }
             }
-            else
-            {
-                throw new AmqpErrorException(AmqpError.DECODE_ERROR,
-                                             String.format("Cannot construct 'error-condition' from type '%s'",
-                                                           value.getClass().getSimpleName()));
-            }
         }
-        return condition;
+        final String message = String.format("Cannot construct 'error-condition' from type '%s'",
+                                             value == null ? null : value.getClass().getSimpleName());
+        throw new AmqpErrorException(AmqpError.DECODE_ERROR, message);
     }
 
     private static final class UnknownErrorCondition implements ErrorCondition

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
index b82b132..2eb919f 100755
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
@@ -653,8 +653,6 @@ public class MessageMetaData_1_0 implements StorableMessageMetaData
                 if (_decodedUserId.get() == null)
                 {
                     Binary encodededUserId = _propertiesSection.getValue().getUserId();
-                    // TODO the specification does not state the encoding of the binary.
-                    // Trying to convert to UTF-8 is guaranteed not to throw an exception.
                     _decodedUserId.set(new String(encodededUserId.getArray(), StandardCharsets.UTF_8));
                 }
                 return _decodedUserId.get();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java
index fe3a629..93f19cb 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java
@@ -718,7 +718,7 @@ public class SendingLinkEndpoint extends AbstractLinkEndpoint<Source, Target>
                     }
                 }
 
-                // TODO: Handle rejected and modified outcome
+                // TODO: QPID-7845: Handle rejected and modified outcome
 
                 remoteUnsettled.remove(deliveryTag);
                 _resumeAcceptedTransfers.add(deliveryTag);
@@ -727,7 +727,7 @@ public class SendingLinkEndpoint extends AbstractLinkEndpoint<Source, Target>
             {
                 _resumeFullTransfers.add(queueEntry);
 
-                // TODO: exists in receivers map, but not yet got an outcome ... should resend with resume = true
+                // TODO:PID-7845: exists in receivers map, but not yet got an outcome ... should resend with resume = true
             }
         }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
index 46718fb..77c2714 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
@@ -1381,7 +1381,7 @@ public class Session_1_0 extends AbstractAMQPSession<Session_1_0, ConsumerTarget
                     }
                     else
                     {
-                        // TODO - link stealing???
+                        // TODO - close connection or session with internal error
                     }
                 }
             });

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java
index ea4b8b8..bb9fa92 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java
@@ -144,7 +144,7 @@ public class StandardReceivingLinkEndpoint extends AbstractReceivingLinkEndpoint
             }
             else
             {
-                // TODO: create message ?
+                // TODO: QPID-7845: create message ?
             }
         }
         else

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ProtocolHandler.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ProtocolHandler.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ProtocolHandler.java
index ff7849e..d087503 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ProtocolHandler.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ProtocolHandler.java
@@ -24,7 +24,7 @@ import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 
 public interface ProtocolHandler
 {
-    // TODO rv is unused
+
     ProtocolHandler parse(QpidByteBuffer in);
 
     boolean isDone();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionDetectionPolicy.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionDetectionPolicy.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionDetectionPolicy.java
index 86ceffb..8acaeae 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionDetectionPolicy.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionDetectionPolicy.java
@@ -45,20 +45,23 @@ public class SoleConnectionDetectionPolicy implements RestrictedType<UnsignedInt
 
     public static SoleConnectionDetectionPolicy valueOf(Object obj)
     {
-        UnsignedInteger val = (UnsignedInteger) obj;
-
-        if (STRONG._val.equals(val))
+        if (obj instanceof UnsignedInteger)
         {
-            return STRONG;
-        }
+            UnsignedInteger val = (UnsignedInteger) obj;
 
-        if (WEAK._val.equals(val))
-        {
-            return WEAK;
+            if (STRONG._val.equals(val))
+            {
+                return STRONG;
+            }
+
+            if (WEAK._val.equals(val))
+            {
+                return WEAK;
+            }
         }
 
-        throw new IllegalArgumentException(String.format(
-                "SoleConnectionDetectionPolicy must be either 0 or 1. Got '%s'", obj));
+        final String message = String.format("Cannot convert '%s' into 'sole-connection-detection-policy'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionEnforcementPolicy.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionEnforcementPolicy.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionEnforcementPolicy.java
index 8a41986..35055ba 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionEnforcementPolicy.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/extensions/soleconn/SoleConnectionEnforcementPolicy.java
@@ -45,20 +45,23 @@ public class SoleConnectionEnforcementPolicy implements RestrictedType<UnsignedI
 
     public static SoleConnectionEnforcementPolicy valueOf(Object obj)
     {
-        UnsignedInteger val = (UnsignedInteger) obj;
-
-        if (REFUSE_CONNECTION._val.equals(val))
+        if (obj instanceof UnsignedInteger)
         {
-            return REFUSE_CONNECTION;
-        }
+            UnsignedInteger val = (UnsignedInteger) obj;
 
-        if (CLOSE_EXISTING._val.equals(val))
-        {
-            return CLOSE_EXISTING;
+            if (REFUSE_CONNECTION._val.equals(val))
+            {
+                return REFUSE_CONNECTION;
+            }
+
+            if (CLOSE_EXISTING._val.equals(val))
+            {
+                return CLOSE_EXISTING;
+            }
         }
 
-        throw new IllegalArgumentException(String.format(
-                "SoleConnectionEnforcementPolicy must be either 0 or 1. Got '%s'", obj));
+        final String message = String.format("Cannot convert '%s' into 'sole-connection-enforcement-policy'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/StdDistMode.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/StdDistMode.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/StdDistMode.java
index 3f0630e..e770f95 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/StdDistMode.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/StdDistMode.java
@@ -68,18 +68,22 @@ public class StdDistMode implements DistributionMode, RestrictedType<Symbol>
 
     public static StdDistMode valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (MOVE._val.equals(val))
+        if (obj instanceof Symbol)
         {
-            return MOVE;
-        }
+            Symbol val = (Symbol) obj;
 
-        if (COPY._val.equals(val))
-        {
-            return COPY;
+            if (MOVE._val.equals(val))
+            {
+                return MOVE;
+            }
+
+            if (COPY._val.equals(val))
+            {
+                return COPY;
+            }
         }
 
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'std-dist-mode'", obj);
+        throw new IllegalArgumentException(message);
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java
index 5b03e06..38466ed 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java
@@ -74,25 +74,27 @@ public class TerminusDurability implements RestrictedType<UnsignedInteger>
 
     public static TerminusDurability valueOf(Object obj)
     {
-        UnsignedInteger val = (UnsignedInteger) obj;
-
-        if (NONE._val.equals(val))
-        {
-            return NONE;
-        }
-
-        if (CONFIGURATION._val.equals(val))
+        if (obj instanceof UnsignedInteger)
         {
-            return CONFIGURATION;
+            UnsignedInteger val = (UnsignedInteger) obj;
+
+            if (NONE._val.equals(val))
+            {
+                return NONE;
+            }
+
+            if (CONFIGURATION._val.equals(val))
+            {
+                return CONFIGURATION;
+            }
+
+            if (UNSETTLED_STATE._val.equals(val))
+            {
+                return UNSETTLED_STATE;
+            }
         }
-
-        if (UNSETTLED_STATE._val.equals(val))
-        {
-            return UNSETTLED_STATE;
-        }
-
-        // TODO ERROR
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'terminus-durability'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     public static TerminusDurability min(TerminusDurability durabilityA, TerminusDurability durabilityB)

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusExpiryPolicy.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusExpiryPolicy.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusExpiryPolicy.java
index 735eac8..4db2f32 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusExpiryPolicy.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusExpiryPolicy.java
@@ -83,29 +83,32 @@ public class TerminusExpiryPolicy implements RestrictedType<Symbol>
 
     public static TerminusExpiryPolicy valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (LINK_DETACH._val.equals(val))
-        {
-            return LINK_DETACH;
-        }
-
-        if (SESSION_END._val.equals(val))
-        {
-            return SESSION_END;
-        }
-
-        if (CONNECTION_CLOSE._val.equals(val))
-        {
-            return CONNECTION_CLOSE;
-        }
-
-        if (NEVER._val.equals(val))
+        if (obj instanceof Symbol)
         {
-            return NEVER;
+            Symbol val = (Symbol) obj;
+
+            if (LINK_DETACH._val.equals(val))
+            {
+                return LINK_DETACH;
+            }
+
+            if (SESSION_END._val.equals(val))
+            {
+                return SESSION_END;
+            }
+
+            if (CONNECTION_CLOSE._val.equals(val))
+            {
+                return CONNECTION_CLOSE;
+            }
+
+            if (NEVER._val.equals(val))
+            {
+                return NEVER;
+            }
         }
 
-        // TODO ERROR
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'terminus-expiry-policy'", obj);
+        throw new IllegalArgumentException(message);
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceConstructor.java
index cd7a31d..bbc999e 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceConstructor.java
@@ -27,9 +27,11 @@ import java.util.List;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequence;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class AmqpSequenceConstructor extends AbstractDescribedTypeConstructor<AmqpSequence>
 {
@@ -50,17 +52,17 @@ public class AmqpSequenceConstructor extends AbstractDescribedTypeConstructor<Am
 
 
     @Override
-    public AmqpSequence construct(Object underlying)
+    public AmqpSequence construct(Object underlying) throws AmqpErrorException
     {
-
         if(underlying instanceof List)
         {
             return new AmqpSequence((List)underlying);
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'amqp-sequence' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesConstructor.java
index 1c8cccb..e68b7fa 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesConstructor.java
@@ -27,9 +27,11 @@ import java.util.Map;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class ApplicationPropertiesConstructor extends AbstractDescribedTypeConstructor<ApplicationProperties>
 {
@@ -50,7 +52,7 @@ public class ApplicationPropertiesConstructor extends AbstractDescribedTypeConst
 
 
     @Override
-    public ApplicationProperties construct(Object underlying)
+    public ApplicationProperties construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof Map)
@@ -59,8 +61,9 @@ public class ApplicationPropertiesConstructor extends AbstractDescribedTypeConst
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'application-properties' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataConstructor.java
index a7c2c60..a9eda5e 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataConstructor.java
@@ -25,10 +25,12 @@ package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Binary;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.Data;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class DataConstructor extends AbstractDescribedTypeConstructor<Data>
 {
@@ -49,7 +51,7 @@ public class DataConstructor extends AbstractDescribedTypeConstructor<Data>
 
 
     @Override
-    public Data construct(Object underlying)
+    public Data construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof Binary)
@@ -58,8 +60,9 @@ public class DataConstructor extends AbstractDescribedTypeConstructor<Data>
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'data' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java
index 70c92b3..997f43a 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java
@@ -27,9 +27,11 @@ import java.util.Map;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class DeliveryAnnotationsConstructor extends AbstractDescribedTypeConstructor<DeliveryAnnotations>
 {
@@ -50,7 +52,7 @@ public class DeliveryAnnotationsConstructor extends AbstractDescribedTypeConstru
 
 
     @Override
-    public DeliveryAnnotations construct(Object underlying)
+    public DeliveryAnnotations construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof Map)
@@ -59,8 +61,9 @@ public class DeliveryAnnotationsConstructor extends AbstractDescribedTypeConstru
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'delivery-annotations' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ExactSubjectFilterConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ExactSubjectFilterConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ExactSubjectFilterConstructor.java
index 063e61b..ddf220f 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ExactSubjectFilterConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ExactSubjectFilterConstructor.java
@@ -25,8 +25,10 @@ package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.ExactSubjectFilter;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class ExactSubjectFilterConstructor extends AbstractDescribedTypeConstructor<ExactSubjectFilter>
 {
@@ -47,7 +49,7 @@ public class ExactSubjectFilterConstructor extends AbstractDescribedTypeConstruc
 
 
     @Override
-    public ExactSubjectFilter construct(Object underlying)
+    public ExactSubjectFilter construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof String)
@@ -56,8 +58,9 @@ public class ExactSubjectFilterConstructor extends AbstractDescribedTypeConstruc
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'apache.org:legacy-amqp-direct-binding' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterConstructor.java
index b345866..523138f 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterConstructor.java
@@ -27,9 +27,11 @@ import java.util.Map;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.Footer;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class FooterConstructor extends AbstractDescribedTypeConstructor<Footer>
 {
@@ -50,7 +52,7 @@ public class FooterConstructor extends AbstractDescribedTypeConstructor<Footer>
 
 
     @Override
-    public Footer construct(Object underlying)
+    public Footer construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof Map)
@@ -59,8 +61,9 @@ public class FooterConstructor extends AbstractDescribedTypeConstructor<Footer>
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'footer' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/JMSSelectorFilterConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/JMSSelectorFilterConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/JMSSelectorFilterConstructor.java
index a232070..a5a1227 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/JMSSelectorFilterConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/JMSSelectorFilterConstructor.java
@@ -25,9 +25,11 @@ package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.JMSSelectorFilter;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class JMSSelectorFilterConstructor extends AbstractDescribedTypeConstructor<JMSSelectorFilter>
 {
@@ -49,7 +51,7 @@ public class JMSSelectorFilterConstructor extends AbstractDescribedTypeConstruct
 
 
     @Override
-    public JMSSelectorFilter construct(Object underlying)
+    public JMSSelectorFilter construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof String)
@@ -58,8 +60,9 @@ public class JMSSelectorFilterConstructor extends AbstractDescribedTypeConstruct
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'apache.org:jms-selector-filter' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java
index a66fd47..9515596 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java
@@ -25,9 +25,11 @@ package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.MatchingSubjectFilter;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class MatchingSubjectFilterConstructor extends AbstractDescribedTypeConstructor<MatchingSubjectFilter>
 {
@@ -48,7 +50,7 @@ public class MatchingSubjectFilterConstructor extends AbstractDescribedTypeConst
 
 
     @Override
-    public MatchingSubjectFilter construct(Object underlying)
+    public MatchingSubjectFilter construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof String)
@@ -57,8 +59,9 @@ public class MatchingSubjectFilterConstructor extends AbstractDescribedTypeConst
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'apache.org:legacy-amqp-topic-binding' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsConstructor.java
index 956b6fd..d7f43ed 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsConstructor.java
@@ -27,9 +27,11 @@ import java.util.Map;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
 
 public class MessageAnnotationsConstructor extends AbstractDescribedTypeConstructor<MessageAnnotations>
 {
@@ -50,7 +52,7 @@ public class MessageAnnotationsConstructor extends AbstractDescribedTypeConstruc
 
 
     @Override
-    public MessageAnnotations construct(Object underlying)
+    public MessageAnnotations construct(Object underlying) throws AmqpErrorException
     {
 
         if(underlying instanceof Map)
@@ -59,8 +61,9 @@ public class MessageAnnotationsConstructor extends AbstractDescribedTypeConstruc
         }
         else
         {
-            // TODO - error
-            return null;
+            final String msg = String.format("Cannot decode 'message-annotations' from '%s'",
+                                             underlying == null ? null : underlying.getClass().getSimpleName());
+            throw new AmqpErrorException(AmqpError.DECODE_ERROR, msg);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/SaslCode.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/SaslCode.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/SaslCode.java
index ec58ef4..5329f8d 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/SaslCode.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/SaslCode.java
@@ -88,34 +88,37 @@ public class SaslCode implements RestrictedType<UnsignedByte>
 
     public static SaslCode valueOf(Object obj)
     {
-        UnsignedByte val = (UnsignedByte) obj;
-
-        if (OK._val.equals(val))
-        {
-            return OK;
-        }
-
-        if (AUTH._val.equals(val))
-        {
-            return AUTH;
-        }
-
-        if (SYS._val.equals(val))
-        {
-            return SYS;
-        }
-
-        if (SYS_PERM._val.equals(val))
-        {
-            return SYS_PERM;
-        }
-
-        if (SYS_TEMP._val.equals(val))
+        if (obj instanceof UnsignedByte)
         {
-            return SYS_TEMP;
+            UnsignedByte val = (UnsignedByte) obj;
+
+            if (OK._val.equals(val))
+            {
+                return OK;
+            }
+
+            if (AUTH._val.equals(val))
+            {
+                return AUTH;
+            }
+
+            if (SYS._val.equals(val))
+            {
+                return SYS;
+            }
+
+            if (SYS_PERM._val.equals(val))
+            {
+                return SYS_PERM;
+            }
+
+            if (SYS_TEMP._val.equals(val))
+            {
+                return SYS_TEMP;
+            }
         }
 
-        // TODO ERROR
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'sasl-code'", obj);
+        throw new IllegalArgumentException(message);
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TransactionErrors.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TransactionErrors.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TransactionErrors.java
index 5297f8f..1995eff 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TransactionErrors.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TransactionErrors.java
@@ -75,23 +75,27 @@ public class TransactionErrors implements ErrorCondition, RestrictedType<Symbol>
 
     public static TransactionErrors valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (UNKNOWN_ID._val.equals(val))
-        {
-            return UNKNOWN_ID;
-        }
-
-        if (TRANSACTION_ROLLBACK._val.equals(val))
-        {
-            return TRANSACTION_ROLLBACK;
-        }
-
-        if (TRANSACTION_TIMEOUT._val.equals(val))
+        if (obj instanceof Symbol)
         {
-            return TRANSACTION_TIMEOUT;
+            Symbol val = (Symbol) obj;
+
+            if (UNKNOWN_ID._val.equals(val))
+            {
+                return UNKNOWN_ID;
+            }
+
+            if (TRANSACTION_ROLLBACK._val.equals(val))
+            {
+                return TRANSACTION_ROLLBACK;
+            }
+
+            if (TRANSACTION_TIMEOUT._val.equals(val))
+            {
+                return TRANSACTION_TIMEOUT;
+            }
         }
 
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'transaction-error'", obj);
+        throw new IllegalArgumentException(message);
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TxnCapability.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TxnCapability.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TxnCapability.java
index c00dfcb..6de3933 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TxnCapability.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/TxnCapability.java
@@ -91,34 +91,37 @@ public class TxnCapability implements org.apache.qpid.server.protocol.v1_0.type.
 
     public static TxnCapability valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (LOCAL_TXN._val.equals(val))
-        {
-            return LOCAL_TXN;
-        }
-
-        if (DISTRIBUTED_TXN._val.equals(val))
-        {
-            return DISTRIBUTED_TXN;
-        }
-
-        if (PROMOTABLE_TXN._val.equals(val))
-        {
-            return PROMOTABLE_TXN;
-        }
-
-        if (MULTI_TXNS_PER_SSN._val.equals(val))
-        {
-            return MULTI_TXNS_PER_SSN;
-        }
-
-        if (MULTI_SSNS_PER_TXN._val.equals(val))
+        if (obj instanceof Symbol)
         {
-            return MULTI_SSNS_PER_TXN;
+            Symbol val = (Symbol) obj;
+
+            if (LOCAL_TXN._val.equals(val))
+            {
+                return LOCAL_TXN;
+            }
+
+            if (DISTRIBUTED_TXN._val.equals(val))
+            {
+                return DISTRIBUTED_TXN;
+            }
+
+            if (PROMOTABLE_TXN._val.equals(val))
+            {
+                return PROMOTABLE_TXN;
+            }
+
+            if (MULTI_TXNS_PER_SSN._val.equals(val))
+            {
+                return MULTI_TXNS_PER_SSN;
+            }
+
+            if (MULTI_SSNS_PER_TXN._val.equals(val))
+            {
+                return MULTI_SSNS_PER_TXN;
+            }
         }
 
-        // TODO ERROR
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'txn-capability'", obj);
+        throw new IllegalArgumentException(message);
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/AmqpError.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/AmqpError.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/AmqpError.java
index 88c6202..df6ecea 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/AmqpError.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/AmqpError.java
@@ -54,74 +54,78 @@ public class AmqpError implements ErrorCondition, RestrictedType<Symbol>
 
     public static AmqpError valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (INTERNAL_ERROR._val.equals(val))
-        {
-            return INTERNAL_ERROR;
-        }
-
-        if (NOT_FOUND._val.equals(val))
-        {
-            return NOT_FOUND;
-        }
-
-        if (UNAUTHORIZED_ACCESS._val.equals(val))
-        {
-            return UNAUTHORIZED_ACCESS;
-        }
-
-        if (DECODE_ERROR._val.equals(val))
-        {
-            return DECODE_ERROR;
-        }
-
-        if (RESOURCE_LIMIT_EXCEEDED._val.equals(val))
-        {
-            return RESOURCE_LIMIT_EXCEEDED;
-        }
-
-        if (NOT_ALLOWED._val.equals(val))
-        {
-            return NOT_ALLOWED;
-        }
-
-        if (INVALID_FIELD._val.equals(val))
-        {
-            return INVALID_FIELD;
-        }
-
-        if (NOT_IMPLEMENTED._val.equals(val))
-        {
-            return NOT_IMPLEMENTED;
-        }
-
-        if (RESOURCE_LOCKED._val.equals(val))
-        {
-            return RESOURCE_LOCKED;
-        }
-
-        if (PRECONDITION_FAILED._val.equals(val))
-        {
-            return PRECONDITION_FAILED;
-        }
-
-        if (RESOURCE_DELETED._val.equals(val))
-        {
-            return RESOURCE_DELETED;
-        }
-
-        if (ILLEGAL_STATE._val.equals(val))
-        {
-            return ILLEGAL_STATE;
-        }
-
-        if (FRAME_SIZE_TOO_SMALL._val.equals(val))
-        {
-            return FRAME_SIZE_TOO_SMALL;
-        }
-
-        return null;
+        if (obj instanceof Symbol)
+        {
+            Symbol val = (Symbol) obj;
+
+            if (INTERNAL_ERROR._val.equals(val))
+            {
+                return INTERNAL_ERROR;
+            }
+
+            if (NOT_FOUND._val.equals(val))
+            {
+                return NOT_FOUND;
+            }
+
+            if (UNAUTHORIZED_ACCESS._val.equals(val))
+            {
+                return UNAUTHORIZED_ACCESS;
+            }
+
+            if (DECODE_ERROR._val.equals(val))
+            {
+                return DECODE_ERROR;
+            }
+
+            if (RESOURCE_LIMIT_EXCEEDED._val.equals(val))
+            {
+                return RESOURCE_LIMIT_EXCEEDED;
+            }
+
+            if (NOT_ALLOWED._val.equals(val))
+            {
+                return NOT_ALLOWED;
+            }
+
+            if (INVALID_FIELD._val.equals(val))
+            {
+                return INVALID_FIELD;
+            }
+
+            if (NOT_IMPLEMENTED._val.equals(val))
+            {
+                return NOT_IMPLEMENTED;
+            }
+
+            if (RESOURCE_LOCKED._val.equals(val))
+            {
+                return RESOURCE_LOCKED;
+            }
+
+            if (PRECONDITION_FAILED._val.equals(val))
+            {
+                return PRECONDITION_FAILED;
+            }
+
+            if (RESOURCE_DELETED._val.equals(val))
+            {
+                return RESOURCE_DELETED;
+            }
+
+            if (ILLEGAL_STATE._val.equals(val))
+            {
+                return ILLEGAL_STATE;
+            }
+
+            if (FRAME_SIZE_TOO_SMALL._val.equals(val))
+            {
+                return FRAME_SIZE_TOO_SMALL;
+            }
+        }
+
+        final String message = String.format("Cannot convert '%s' into 'amqp-error'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ConnectionError.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ConnectionError.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ConnectionError.java
index e1fe139..deb7d05 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ConnectionError.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ConnectionError.java
@@ -47,29 +47,33 @@ public class ConnectionError implements ErrorCondition, RestrictedType<Symbol>
 
     public static ConnectionError valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (CONNECTION_FORCED._val.equals(val))
-        {
-            return CONNECTION_FORCED;
-        }
-
-        if (FRAMING_ERROR._val.equals(val))
-        {
-            return FRAMING_ERROR;
-        }
-
-        if (REDIRECT._val.equals(val))
-        {
-            return REDIRECT;
-        }
-
-        if (SOCKET_ERROR._val.equals(val))
+        if (obj instanceof Symbol)
         {
-            return SOCKET_ERROR;
+            Symbol val = (Symbol) obj;
+
+            if (CONNECTION_FORCED._val.equals(val))
+            {
+                return CONNECTION_FORCED;
+            }
+
+            if (FRAMING_ERROR._val.equals(val))
+            {
+                return FRAMING_ERROR;
+            }
+
+            if (REDIRECT._val.equals(val))
+            {
+                return REDIRECT;
+            }
+
+            if (SOCKET_ERROR._val.equals(val))
+            {
+                return SOCKET_ERROR;
+            }
         }
 
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'connection-error'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/LinkError.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/LinkError.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/LinkError.java
index 99ec089..e90effe 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/LinkError.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/LinkError.java
@@ -47,34 +47,38 @@ public class LinkError implements ErrorCondition, RestrictedType<Symbol>
 
     public static LinkError valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (DETACH_FORCED._val.equals(val))
-        {
-            return DETACH_FORCED;
-        }
-
-        if (TRANSFER_LIMIT_EXCEEDED._val.equals(val))
-        {
-            return TRANSFER_LIMIT_EXCEEDED;
-        }
-
-        if (MESSAGE_SIZE_EXCEEDED._val.equals(val))
-        {
-            return MESSAGE_SIZE_EXCEEDED;
-        }
-
-        if (REDIRECT._val.equals(val))
-        {
-            return REDIRECT;
-        }
-
-        if (STOLEN._val.equals(val))
+        if (obj instanceof Symbol)
         {
-            return STOLEN;
+            Symbol val = (Symbol) obj;
+
+            if (DETACH_FORCED._val.equals(val))
+            {
+                return DETACH_FORCED;
+            }
+
+            if (TRANSFER_LIMIT_EXCEEDED._val.equals(val))
+            {
+                return TRANSFER_LIMIT_EXCEEDED;
+            }
+
+            if (MESSAGE_SIZE_EXCEEDED._val.equals(val))
+            {
+                return MESSAGE_SIZE_EXCEEDED;
+            }
+
+            if (REDIRECT._val.equals(val))
+            {
+                return REDIRECT;
+            }
+
+            if (STOLEN._val.equals(val))
+            {
+                return STOLEN;
+            }
         }
 
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'link-error'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ReceiverSettleMode.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ReceiverSettleMode.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ReceiverSettleMode.java
index 89a8fee..c8c0072 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ReceiverSettleMode.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/ReceiverSettleMode.java
@@ -41,20 +41,22 @@ public class ReceiverSettleMode implements RestrictedType<UnsignedByte>
 
     public static ReceiverSettleMode valueOf(Object obj)
     {
-        UnsignedByte val = (UnsignedByte) obj;
-
-        if (FIRST._val.equals(val))
-        {
-            return FIRST;
-        }
-
-        if (SECOND._val.equals(val))
+        if (obj instanceof UnsignedByte)
         {
-            return SECOND;
+            UnsignedByte val = (UnsignedByte) obj;
+            if (FIRST._val.equals(val))
+            {
+                return FIRST;
+            }
+
+            if (SECOND._val.equals(val))
+            {
+                return SECOND;
+            }
         }
 
-        // TODO ERROR
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'receiver-settle-mode'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Role.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Role.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Role.java
index c8d5619..d2ba4d9 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Role.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Role.java
@@ -40,20 +40,22 @@ public class Role implements RestrictedType<Boolean>
 
     public static Role valueOf(Object obj)
     {
-        boolean val = (Boolean) obj;
-
-        if (SENDER._val == (val))
+        if (obj instanceof Boolean)
         {
-            return SENDER;
-        }
+            boolean val = (Boolean) obj;
 
-        if (RECEIVER._val == (val))
-        {
-            return RECEIVER;
-        }
+            if (SENDER._val == (val))
+            {
+                return SENDER;
+            }
 
-        // TODO ERROR
-        return null;
+            if (RECEIVER._val == (val))
+            {
+                return RECEIVER;
+            }
+        }
+        final String message = String.format("Cannot convert '%s' into 'role'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SenderSettleMode.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SenderSettleMode.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SenderSettleMode.java
index 4ada342..9d9767f 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SenderSettleMode.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SenderSettleMode.java
@@ -42,25 +42,28 @@ public class SenderSettleMode implements RestrictedType<UnsignedByte>
 
     public static SenderSettleMode valueOf(Object obj)
     {
-        UnsignedByte val = (UnsignedByte) obj;
-
-        if (UNSETTLED._val.equals(val))
-        {
-            return UNSETTLED;
-        }
-
-        if (SETTLED._val.equals(val))
-        {
-            return SETTLED;
-        }
-
-        if (MIXED._val.equals(val))
+        if (obj instanceof UnsignedByte)
         {
-            return MIXED;
+            UnsignedByte val = (UnsignedByte) obj;
+
+            if (UNSETTLED._val.equals(val))
+            {
+                return UNSETTLED;
+            }
+
+            if (SETTLED._val.equals(val))
+            {
+                return SETTLED;
+            }
+
+            if (MIXED._val.equals(val))
+            {
+                return MIXED;
+            }
         }
 
-        // TODO ERROR
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'sender-settle-mode'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a6a02baa/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SessionError.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SessionError.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SessionError.java
index 190bb3a..f332f46 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SessionError.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/SessionError.java
@@ -46,29 +46,33 @@ public class SessionError implements ErrorCondition, RestrictedType<Symbol>
 
     public static SessionError valueOf(Object obj)
     {
-        Symbol val = (Symbol) obj;
-
-        if (WINDOW_VIOLATION._val.equals(val))
-        {
-            return WINDOW_VIOLATION;
-        }
-
-        if (ERRANT_LINK._val.equals(val))
-        {
-            return ERRANT_LINK;
-        }
-
-        if (HANDLE_IN_USE._val.equals(val))
-        {
-            return HANDLE_IN_USE;
-        }
-
-        if (UNATTACHED_HANDLE._val.equals(val))
+        if (obj instanceof Symbol)
         {
-            return UNATTACHED_HANDLE;
+            Symbol val = (Symbol) obj;
+
+            if (WINDOW_VIOLATION._val.equals(val))
+            {
+                return WINDOW_VIOLATION;
+            }
+
+            if (ERRANT_LINK._val.equals(val))
+            {
+                return ERRANT_LINK;
+            }
+
+            if (HANDLE_IN_USE._val.equals(val))
+            {
+                return HANDLE_IN_USE;
+            }
+
+            if (UNATTACHED_HANDLE._val.equals(val))
+            {
+                return UNATTACHED_HANDLE;
+            }
         }
 
-        return null;
+        final String message = String.format("Cannot convert '%s' into 'session-error'", obj);
+        throw new IllegalArgumentException(message);
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org