Class SafeSerializationUtils

java.lang.Object
google.registry.util.SafeSerializationUtils

public final class SafeSerializationUtils extends Object
Helpers for using SafeObjectInputStream.

Please refer to SafeObjectInputStream for more information.

  • Field Details

    • MAX_COLLECTION_SIZE

      public static final int MAX_COLLECTION_SIZE
      Maximum number of elements allowed in a serialized collection.

      This value is sufficient for parameters embedded in a URL to typical cloud services. E.g., as of Fall 2023, AWS limits request line size to 16KB and GCP limits total header size to 64KB.

      See Also:
  • Method Details

    • serializeCollection

      public static byte[] serializeCollection(Collection<?> collection)
      Serializes a collection of objects that can be safely deserialized using safeDeserializeCollection(java.lang.Class<T>, byte[]).

      If any element of the collection cannot be safely-deserialized, deserialization will fail.

    • safeDeserialize

      @Nullable public static Serializable safeDeserialize(@Nullable byte[] bytes)
      Safely deserializes an object using SafeObjectInputStream.
    • safeDeserializeCollection

      public static <T> com.google.common.collect.ImmutableList<T> safeDeserializeCollection(Class<T> elementType, byte[] bytes)
      Safely deserializes a collection of objects previously serialized with serializeCollection(java.util.Collection<?>).