public static void writeByteArray(byte[] array, int len, DataOutput out) throws IOException {

    int length = len; // to avoid warnings about parameter assignment

    if (array == null) {
      length = -1;
    } else {
      if (length > array.length) {
        length = array.length;
      }
    }
    writeArrayLength(length, out);
    if (length > 0) {
      out.write(array, 0, length);
    }
  }
array len encoded as unsigned short in next 2 bytes

@since GemFire 5.7
geode-serialization/src/main/java/org/apache/geode/internal/serialization/StaticSerialization.java