Hi Deniz,

You could declare UUIDGenerator as a transient field and instanciate it in
the open
function

Ot if you want to inject any UUIDGenerator you could provide a supplier of
UUIDGenerator that should implement Serializable and invoke it in the open
function.




On Tue, Feb 1, 2022, 10:01 PM Deniz Koçak <lend...@gmail.com> wrote:

> Hi All,
>
> We have a function extending `KeyedCoProcessFunction` and within that
> function implementation. I wanted to keep a class object as a field
> which is simply responsible for generating a UUID.
>
> We disabled Kyro fallback for generic types via
> `env.getConfig().disableGenericTypes()`.
> I am receiving the error below when I pass an instance of
> `UUIDGenerator` to the `KeyedCoProcessFunction` and try to run the
> job.
>
>
> ***********************************************************************************
> Exception in thread "main" java.lang.UnsupportedOperationException:
> Generic types have been disabled in the ExecutionConfig and type
> java.util.UUID is treated as a generic type.
>
> ***********************************************************************************
>
> At that point I wonder how can/should I do to pass an instance of
> `UUIDGenerator` to `PrebetModelRequestProcessor` function.
>
>
> ModelRequestProcessor Class:
> ========================================================
> public class ModelRequestProcessor extends
> KeyedCoProcessFunction<String, CustomerInformation, CustomerRisk,
> ModelRequest> {
>
>     protected final UUIDGenerator uuidGenerator;
>
>     public PrebetModelRequestProcessor(UUIDGenerator generator) {
>         this.uuidGenerator = generator;
>     }
> }
> ========================================================
>
> UUIDGenerator Class:
> ========================================================
> public class UUIDGenerator implements Serializable {
>
>     private static final long serialVersionUID = 42L;
>
>     public java.util.UUID generate() {
>         return java.util.UUID.randomUUID();
>     }
> }
> ========================================================
>

Reply via email to