PROTON-2236: restore prior usage of DecodeException and fix up some other cases
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
index a34bd6f..12be526 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
@@ -32,7 +32,6 @@
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.proton.ProtonException;
 import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.Decimal128;
 import org.apache.qpid.proton.amqp.Decimal32;
@@ -189,7 +188,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Boolean type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Boolean type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -209,7 +208,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Boolean type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Boolean type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -230,7 +229,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Byte type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Byte type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -274,7 +273,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Short type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Short type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -320,7 +319,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Integer type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Integer type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -366,7 +365,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Long type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Long type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -410,7 +409,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected UnsignedByte type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected UnsignedByte type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -432,7 +431,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected UnsignedShort type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected UnsignedShort type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -458,7 +457,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected UnsignedInteger type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected UnsignedInteger type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -484,7 +483,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected UnsignedLong type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected UnsignedLong type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -506,7 +505,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Character type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Character type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -522,7 +521,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Character type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Character type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -544,7 +543,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Float type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Float type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -588,7 +587,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected Double type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Double type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -632,7 +631,7 @@
             case EncodingCodes.NULL:
                 return defaultVal;
             default:
-                throw new ProtonException("Expected UUID type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected UUID type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -654,7 +653,7 @@
             case EncodingCodes.NULL:
                 return defaultValue;
             default:
-                throw new ProtonException("Expected Decimal32 type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Decimal32 type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -676,7 +675,7 @@
             case EncodingCodes.NULL:
                 return defaultValue;
             default:
-                throw new ProtonException("Expected Decimal64 type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Decimal64 type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -698,7 +697,7 @@
             case EncodingCodes.NULL:
                 return defaultValue;
             default:
-                throw new ProtonException("Expected Decimal128 type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Decimal128 type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -720,7 +719,7 @@
             case EncodingCodes.NULL:
                 return defaultValue;
             default:
-                throw new ProtonException("Expected Timestamp type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Timestamp type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -744,7 +743,7 @@
             case EncodingCodes.NULL:
                 return defaultValue;
             default:
-                throw new ProtonException("Expected Binary type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Binary type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -768,7 +767,7 @@
             case EncodingCodes.NULL:
                 return defaultValue;
             default:
-                throw new ProtonException("Expected Symbol type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Symbol type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -792,7 +791,7 @@
             case EncodingCodes.NULL:
                 return defaultValue;
             default:
-                throw new ProtonException("Expected String type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected String type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -813,7 +812,7 @@
             case EncodingCodes.NULL:
                 return null;
             default:
-                throw new ProtonException("Expected List type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected List type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
@@ -838,7 +837,7 @@
             case EncodingCodes.NULL:
                 return null;
             default:
-                throw new ProtonException("Expected Map type but found encoding: " + EncodingCodes.toString(encodingCode));
+                throw new DecodeException("Expected Map type but found encoding: " + EncodingCodes.toString(encodingCode));
         }
     }
 
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java
index 5f9415e..3bf3985 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java
@@ -35,7 +35,6 @@
 import java.util.Set;
 import java.util.UUID;
 
-import org.apache.qpid.proton.ProtonException;
 import org.apache.qpid.proton.amqp.messaging.AmqpValue;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -241,7 +240,7 @@
 
         try {
             decoder.readString();
-        } catch (ProtonException ex) {
+        } catch (DecodeException ex) {
             // Should indicate the type that it found in the error
             assertTrue(ex.getMessage().contains(EncodingCodes.toString(EncodingCodes.UUID)));
         }
@@ -273,7 +272,7 @@
 
         try {
             decoder.readString();
-        } catch (ProtonException ex) {
+        } catch (DecodeException ex) {
             // Should indicate the type that it found in the error
             assertTrue(ex.getMessage().contains("Unknown-Type:0x01"));
         }
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
index 1f89075..5217421 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/TransportImplTest.java
@@ -4004,6 +4004,17 @@
         doInvalidTransferProvokesDecodeErrorTestImpl(bytes, "Unexpected null value - mandatory field not set? (the handle field is mandatory)");
     }
 
+    @Test
+    public void testTransferWithWrongHandleTypeCodeProvokesDecodeError() {
+        // Provide the bytes for Transfer, but give the wrong type code for a not-really-present handle. Provokes a decode error.
+        byte[] bytes = new byte[] {  0x00, 0x00, 0x00, 0x0F, // Frame size = 15 bytes.
+                0x02, 0x00, 0x00, 0x00, // DOFF, TYPE, 2x CHANNEL
+                0x00, 0x53, 0x14, (byte) 0xC0, // Described-type, ulong type, Transfer descriptor, list8.
+                0x03, 0x01, (byte) 0xA3 }; // size (3), count (1), handle (invalid sym8 type constructor given, not really present).
+
+        doInvalidTransferProvokesDecodeErrorTestImpl(bytes, "Expected UnsignedInteger type but found encoding: SYM8:0xa3");
+    }
+
     private void doInvalidTransferProvokesDecodeErrorTestImpl(byte[] bytes, String description) {
         MockTransportImpl transport = new MockTransportImpl();
         Connection connection = Proton.connection();