This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git


The following commit(s) were added to refs/heads/main by this push:
     new f538027  PROTON-2380 Improve the exception message for missing 
mandatory fields
f538027 is described below

commit f538027250cebad9940551a364f7e9dccc5cdf29
Author: Timothy Bish <[email protected]>
AuthorDate: Fri May 7 15:09:12 2021 -0400

    PROTON-2380 Improve the exception message for missing mandatory fields
---
 .../decoders/transport/AttachTypeDecoder.java      |  6 ++---
 .../codec/decoders/transport/BeginTypeDecoder.java |  6 ++---
 .../decoders/transport/DetachTypeDecoder.java      |  4 ++--
 .../decoders/transport/DispositionTypeDecoder.java |  4 ++--
 .../codec/decoders/transport/FlowTypeDecoder.java  |  6 ++---
 .../codec/decoders/transport/OpenTypeDecoder.java  |  8 +++----
 .../decoders/transport/TransferTypeDecoder.java    |  4 ++--
 .../engine/impl/ProtonDecodeErrorTest.java         | 26 +++++++++++-----------
 8 files changed, 32 insertions(+), 32 deletions(-)

diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/AttachTypeDecoder.java
 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/AttachTypeDecoder.java
index 4fb5d06..766809a 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/AttachTypeDecoder.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/AttachTypeDecoder.java
@@ -287,11 +287,11 @@ public final class AttachTypeDecoder extends 
AbstractDescribedTypeDecoder<Attach
     private String errorForMissingRequiredFields(int present) {
         switch (present) {
             case 2:
-                return "The role field cannot be omitted";
+                return "The role field cannot be omitted from the Attach";
             case 1:
-                return "The handle field cannot be omitted";
+                return "The handle field cannot be omitted from the Attach";
             default:
-                return "The name field cannot be omitted";
+                return "The name field cannot be omitted from the Attach";
         }
     }
 }
diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/BeginTypeDecoder.java
 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/BeginTypeDecoder.java
index 5c887f9..c7e76fe 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/BeginTypeDecoder.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/BeginTypeDecoder.java
@@ -240,11 +240,11 @@ public final class BeginTypeDecoder extends 
AbstractDescribedTypeDecoder<Begin>
     private String errorForMissingRequiredFields(int present) {
         switch (present) {
             case 3:
-                return "The outgoing-window field cannot be omitted";
+                return "The outgoing-window field cannot be omitted from the 
Begin";
             case 2:
-                return "The incoming-window field cannot be omitted";
+                return "The incoming-window field cannot be omitted from the 
Begin";
             default:
-                return "The next-outgoing-id field cannot be omitted";
+                return "The next-outgoing-id field cannot be omitted from the 
Begin";
         }
     }
 }
diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DetachTypeDecoder.java
 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DetachTypeDecoder.java
index 46c9e2a..655ae64 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DetachTypeDecoder.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DetachTypeDecoder.java
@@ -106,7 +106,7 @@ public final class DetachTypeDecoder extends 
AbstractDescribedTypeDecoder<Detach
             final boolean nullValue = buffer.getByte(buffer.getReadIndex()) == 
EncodingCodes.NULL;
             if (nullValue) {
                 if (index == 0) {
-                    throw new DecodeException("The handle field is mandatory");
+                    throw new DecodeException("The handle field is mandatory 
in a Detach");
                 }
                 buffer.readByte();
                 continue;
@@ -164,7 +164,7 @@ public final class DetachTypeDecoder extends 
AbstractDescribedTypeDecoder<Detach
         final int count = listDecoder.readCount(stream);
 
         if (count < MIN_DETACH_LIST_ENTRIES) {
-            throw new DecodeException("The handle field is mandatory");
+            throw new DecodeException("The handle field is mandatory in a 
Detach");
         }
 
         if (count > MAX_DETACH_LIST_ENTRIES) {
diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DispositionTypeDecoder.java
 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DispositionTypeDecoder.java
index 6d6b612..b2d8879 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DispositionTypeDecoder.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DispositionTypeDecoder.java
@@ -143,9 +143,9 @@ public final class DispositionTypeDecoder extends 
AbstractDescribedTypeDecoder<D
     private String errorForMissingRequiredFields(int present) {
         switch (present) {
             case 1:
-                return "The first field cannot be omitted";
+                return "The first field cannot be omitted from the 
Disposition";
             default:
-                return "The role field cannot be omitted";
+                return "The role field cannot be omitted from the Disposition";
         }
     }
 
diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/FlowTypeDecoder.java
 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/FlowTypeDecoder.java
index 3132a9f..ba831d1 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/FlowTypeDecoder.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/FlowTypeDecoder.java
@@ -260,11 +260,11 @@ public final class FlowTypeDecoder extends 
AbstractDescribedTypeDecoder<Flow> {
     private String errorForMissingRequiredFields(int present) {
         switch (present) {
             case 3:
-                return "The outgoing-window field cannot be omitted";
+                return "The outgoing-window field cannot be omitted from the 
Flow";
             case 2:
-                return "The next-outgoing-id field cannot be omitted";
+                return "The next-outgoing-id field cannot be omitted from the 
Flow";
             default:
-                return "The incoming-window field cannot be omitted";
+                return "The incoming-window field cannot be omitted from the 
Flow";
         }
     }
 }
diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/OpenTypeDecoder.java
 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/OpenTypeDecoder.java
index 040345f..c0a8b6a 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/OpenTypeDecoder.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/OpenTypeDecoder.java
@@ -91,7 +91,7 @@ public final class OpenTypeDecoder extends 
AbstractDescribedTypeDecoder<Open> {
         final int count = listDecoder.readCount(buffer);
 
         if (count < MIN_OPEN_LIST_ENTRIES) {
-            throw new DecodeException("The container-id field cannot be 
omitted");
+            throw new DecodeException("The container-id field cannot be 
omitted from the Open");
         }
 
         if (count > MAX_OPEN_LIST_ENTRIES) {
@@ -105,7 +105,7 @@ public final class OpenTypeDecoder extends 
AbstractDescribedTypeDecoder<Open> {
             final boolean nullValue = buffer.getByte(buffer.getReadIndex()) == 
EncodingCodes.NULL;
             if (nullValue) {
                 if (index == 0) {
-                    throw new DecodeException("The container-id field cannot 
be omitted");
+                    throw new DecodeException("The container-id field cannot 
be omitted from the Open");
                 }
                 buffer.readByte();
                 continue;
@@ -184,7 +184,7 @@ public final class OpenTypeDecoder extends 
AbstractDescribedTypeDecoder<Open> {
         final int count = listDecoder.readCount(stream);
 
         if (count < MIN_OPEN_LIST_ENTRIES) {
-            throw new DecodeException("The container-id field cannot be 
omitted");
+            throw new DecodeException("The container-id field cannot be 
omitted from the Open");
         }
 
         if (count > MAX_OPEN_LIST_ENTRIES) {
@@ -200,7 +200,7 @@ public final class OpenTypeDecoder extends 
AbstractDescribedTypeDecoder<Open> {
                 final boolean nullValue = ProtonStreamUtils.readByte(stream) 
== EncodingCodes.NULL;
                 if (nullValue) {
                     if (index == 0) {
-                        throw new DecodeException("The container-id field 
cannot be omitted");
+                        throw new DecodeException("The container-id field 
cannot be omitted from the Open");
                     }
 
                     continue;
diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/TransferTypeDecoder.java
 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/TransferTypeDecoder.java
index ee978cb..ca47d75 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/TransferTypeDecoder.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/TransferTypeDecoder.java
@@ -109,7 +109,7 @@ public final class TransferTypeDecoder extends 
AbstractDescribedTypeDecoder<Tran
             final boolean nullValue = buffer.getByte(buffer.getReadIndex()) == 
EncodingCodes.NULL;
             if (nullValue) {
                 if (index == 0) {
-                    throw new DecodeException("The handle field cannot be 
omitted");
+                    throw new DecodeException("The handle field cannot be 
omitted from the Transfer");
                 }
 
                 buffer.readByte();
@@ -210,7 +210,7 @@ public final class TransferTypeDecoder extends 
AbstractDescribedTypeDecoder<Tran
                 final boolean nullValue = ProtonStreamUtils.readByte(stream) 
== EncodingCodes.NULL;
                 if (nullValue) {
                     if (index == 0) {
-                        throw new DecodeException("The handle field cannot be 
omitted");
+                        throw new DecodeException("The handle field cannot be 
omitted from the Transfer");
                     }
 
                     continue;
diff --git 
a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonDecodeErrorTest.java
 
b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonDecodeErrorTest.java
index 924d36b..95e6728 100644
--- 
a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonDecodeErrorTest.java
+++ 
b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonDecodeErrorTest.java
@@ -46,7 +46,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
                                      0x00, 0x53, 0x10, (byte) 0xC0, // 
Described-type, ulong type, open descriptor, list0.
                                      0x03, 0x01, 0x40 }; // size (3), count 
(1), container-id (null).
 
-        doInvalidOpenProvokesDecodeErrorTestImpl(bytes, "The container-id 
field cannot be omitted");
+        doInvalidOpenProvokesDecodeErrorTestImpl(bytes, "The container-id 
field cannot be omitted from the Open");
     }
 
     @Test
@@ -56,7 +56,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
                                      0x02, 0x00, 0x00, 0x00, // DOFF, TYPE, 2x 
CHANNEL
                                      0x00, 0x53, 0x10, 0x45};// 
Described-type, ulong type, open descriptor, list0.
 
-        doInvalidOpenProvokesDecodeErrorTestImpl(bytes, "The container-id 
field cannot be omitted");
+        doInvalidOpenProvokesDecodeErrorTestImpl(bytes, "The container-id 
field cannot be omitted from the Open");
     }
 
     private void doInvalidOpenProvokesDecodeErrorTestImpl(byte[] bytes, String 
errorDescription) throws Exception {
@@ -89,7 +89,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x02, 0x00, 0x00, 0x00, // DOFF, TYPE, 2x CHANNEL
             0x00, 0x53, 0x11, 0x45};// Described-type, ulong type, Begin 
descriptor, list0.
 
-        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The next-outgoing-id 
field cannot be omitted");
+        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The next-outgoing-id 
field cannot be omitted from the Begin");
     }
 
     @Test
@@ -101,7 +101,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x11, (byte) 0xC0, // Described-type, ulong type, 
Begin descriptor, list8.
             0x03, 0x01, 0x40 }; // size (3), count (1), remote-channel (null).
 
-        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The next-outgoing-id 
field cannot be omitted");
+        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The next-outgoing-id 
field cannot be omitted from the Begin");
     }
 
     @Test
@@ -113,7 +113,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x11, (byte) 0xC0, // Described-type, ulong type, 
Begin descriptor, list8.
             0x05, 0x03, 0x40, 0x43, 0x43 }; // size (5), count (3), 
remote-channel (null), next-outgoing-id (uint0), incoming-window (uint0).
 
-        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted");
+        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted from the Begin");
     }
 
     @Test
@@ -125,7 +125,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x11, (byte) 0xC0, // Described-type, ulong type, 
Begin descriptor, list8.
             0x06, 0x04, 0x40, 0x43, 0x43, 0x40 }; // size (5), count (4), 
remote-channel (null), next-outgoing-id (uint0), incoming-window (uint0), 
outgoing-window (null).
 
-        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted");
+        doInvalidBeginProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted from the Begin");
     }
 
     private void doInvalidBeginProvokesDecodeErrorTestImpl(byte[] bytes, 
String errorDescription) throws Exception {
@@ -158,7 +158,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x02, 0x00, 0x00, 0x00, // DOFF, TYPE, 2x CHANNEL
             0x00, 0x53, 0x13, 0x45};// Described-type, ulong type, Flow 
descriptor, list0.
 
-        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The incoming-window 
field cannot be omitted");
+        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The incoming-window 
field cannot be omitted from the Flow");
     }
 
     @Test
@@ -170,7 +170,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x13, (byte) 0xC0, // Described-type, ulong type, Flow 
descriptor, list8.
             0x03, 0x01, 0x43 }; // size (3), count (1), next-incoming-id 
(uint0).
 
-        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The incoming-window 
field cannot be omitted");
+        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The incoming-window 
field cannot be omitted from the Flow");
     }
 
     @Test
@@ -182,7 +182,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x13, (byte) 0xC0, // Described-type, ulong type, Flow 
descriptor, list8.
             0x05, 0x03, 0x43, 0x43, 0x43 }; // size (5), count (3), 
next-incoming-id (0), incoming-window (uint0), next-outgoing-id (uint0).
 
-        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted");
+        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted from the Flow");
     }
 
     @Test
@@ -194,7 +194,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x13, (byte) 0xC0, // Described-type, ulong type, Flow 
descriptor, list8.
             0x06, 0x04, 0x43, 0x43, 0x43, 0x40 }; // size (5), count (4), 
next-incoming-id (0), incoming-window (uint0), next-outgoing-id (uint0), 
outgoing-window (null).
 
-        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted");
+        doInvalidFlowProvokesDecodeErrorTestImpl(bytes, "The outgoing-window 
field cannot be omitted from the Flow");
     }
 
     private void doInvalidFlowProvokesDecodeErrorTestImpl(byte[] bytes, String 
errorDescription) throws Exception {
@@ -238,7 +238,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x14, (byte) 0xC0, // Described-type, ulong type, 
Transfer descriptor, list8.
             0x03, 0x01, 0x40 }; // size (3), count (1), handle (null / 
not-present).
 
-        doInvalidTransferProvokesDecodeErrorTestImpl(bytes, "The handle field 
cannot be omitted");
+        doInvalidTransferProvokesDecodeErrorTestImpl(bytes, "The handle field 
cannot be omitted from the Transfer");
     }
 
 
@@ -288,7 +288,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x02, 0x00, 0x00, 0x00, // DOFF, TYPE, 2x CHANNEL
             0x00, 0x53, 0x15, 0x45};// Described-type, ulong type, Disposition 
descriptor, list0.
 
-        doInvalidDispositionProvokesDecodeErrorTestImpl(bytes, "The role field 
cannot be omitted");
+        doInvalidDispositionProvokesDecodeErrorTestImpl(bytes, "The role field 
cannot be omitted from the Disposition");
     }
 
     @Test
@@ -300,7 +300,7 @@ public class ProtonDecodeErrorTest extends 
ProtonEngineTestSupport {
             0x00, 0x53, 0x15, (byte) 0xC0, // Described-type, ulong type, 
Disposition descriptor, list8.
             0x04, 0x02, 0x41, 0x40 }; // size (4), count (2), role (receiver - 
the peers perspective), first ( null / not-present)
 
-        doInvalidDispositionProvokesDecodeErrorTestImpl(bytes, "The first 
field cannot be omitted");
+        doInvalidDispositionProvokesDecodeErrorTestImpl(bytes, "The first 
field cannot be omitted from the Disposition");
     }
 
     private void doInvalidDispositionProvokesDecodeErrorTestImpl(byte[] bytes, 
String errorDescription) throws Exception {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to