Repository: amzn/ion-java (java)

Issue:
Implement empty ordered structs as error
The [spec](https://amzn.github.io/ion-docs/binary.html) requires at least one value in the struct for ordered structs in the binary representation (type descriptor 0xD1).

Pull request description:
Empty ordered structs now cause an exception.
Fixes #100. When reading a binary struct that is flagged as having ordered keys, the reader now enforces that the struct cannot be empty.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


Patch:
diff --git a/src/software/amazon/ion/impl/IonReaderBinaryRawX.java b/src/software/amazon/ion/impl/IonReaderBinaryRawX.java
index ae391f7f..92470bb5 100644
--- a/src/software/amazon/ion/impl/IonReaderBinaryRawX.java
+++ b/src/software/amazon/ion/impl/IonReaderBinaryRawX.java
@@ -494,6 +494,9 @@ abstract class IonReaderBinaryRawX
                 // special case of an ordered struct, it gets the
                 // otherwise impossible to have length of 1
                 len = readVarUInt();
+                if (len == 0) {
+                    throwErrorAt("Structs flagged as having ordered keys must contain at least one key/value pair.");
+                }
                 start_of_value = _input.getPosition();
             }
         }


Test patch:
diff --git a/test/software/amazon/ion/TestUtils.java b/test/software/amazon/ion/TestUtils.java
index 187af1a6..44552098 100644
--- a/test/software/amazon/ion/TestUtils.java
+++ b/test/software/amazon/ion/TestUtils.java
@@ -131,7 +131,6 @@ public class TestUtils
         new FileIsNot(
              "bad/clobWithNullCharacter.ion"                // TODO amzn/ion-java#43
             , "bad/clobWithNonAsciiCharacter.ion"           // TODO amzn/ion-java#99
-            , "bad/structOrderedEmpty.10n"                  // TODO amzn/ion-java#100
             , "bad/emptyAnnotatedInt.10n"                   // TODO amzn/ion-java#55
             , "bad/timestamp/timestampNegativeFraction.10n" // TODO amzn/ion-java#102
             , "bad/utf8/surrogate_5.ion"                    // TODO amzn/ion-java#60