Podam can’t handle java.nio.ByteBuffer field

  Kiến thức lập trình

I generate some objects using Podam library, but there is a field, podam can’t handle.

private java.nio.ByteBuffer valueBase64;

When I try to create object from the class, it takes very long and most likely end with something like java heap insufficient memory error.

public <T> T createObject(Class<?> clazz) {
    PodamFactory podamFactory = new PodamFactoryImpl();
    podamFactory.getStrategy().addOrReplaceTypeManufacturer(List.class, (strategy, attributeMetadata, genericTypesArgumentsMap) -> Collections.emptyList());
    Object o = podamFactory.manufacturePojo(clazz);
    return (T) o;
}

Printed result looks like this:

, ... "contentDataForTemplate": {"valueBase64": "u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000u0000... etc.

It clearly adds to the buffer until memory runs out.

Is there a way how to tell it to:

  1. Put a concrete value to this particular field
  2. List item java.nio.ByteBuffer type?

I know I could use @PodamExclude annotation over this field, but those classes are AVRO generated, therefore I can’t simply put annotation on anything. All configuration must be done outside. And this exclude only excludes certain attributes, not data types.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT