Skip to content

Commit

Permalink
[Java][FlexBuffers] throwing exception for untyped fixed vectors (#7507)
Browse files Browse the repository at this point in the history
Untyped fixed vectors are not supported in FlexBuffers. There
was an assert to check for it, but on java, asserts are optional. This
change converts the assertion into a runtime exception.

Fixes #7358

Co-authored-by: Derek Bailey <derekbailey@google.com>
  • Loading branch information
paulovap and dbaileychess committed Sep 2, 2022
1 parent 7f75477 commit 4c95418
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion java/com/google/flatbuffers/FlexBuffersBuilder.java
Expand Up @@ -502,7 +502,9 @@ public ByteBuffer finish() {
* @return Value representing the created vector
*/
private Value createVector(int key, int start, int length, boolean typed, boolean fixed, Value keys) {
assert (!fixed || typed); // typed=false, fixed=true combination is not supported.
if (fixed & !typed)
throw new UnsupportedOperationException("Untyped fixed vector is not supported");

// Figure out smallest bit width we can store this vector with.
int bitWidth = Math.max(WIDTH_8, widthUInBits(length));
int prefixElems = 1;
Expand Down

0 comments on commit 4c95418

Please sign in to comment.