You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Flavio Pompermaier <po...@okkam.it> on 2018/07/17 13:48:57 UTC

RequiredParameters in Flink 1.5.1

Hi to all,
I'm trying to migrate a job from Flink 1.3.1 to 1.5.1 but it seems that
RequiredParameters and ParameterTool works differently from before...

My code is the following:

ParameterTool parameters = ParameterTool.fromArgs(args);
RequiredParameters required = new RequiredParameters();
required.add(*getMyBooleanOption*());
required.applyTo(parameters);

where *getMyBooleanOption*() creates an Option 'xxx' with a default value
of "true".

In Flink 1.3.1 parameters.getBoolean(getMyBooleanOption().getName())
returns true while in 1.5.1 throws an exception:

Exception in thread "main" java.lang.RuntimeException: No data for required
key 'xxx'
at
org.apache.flink.api.java.utils.ParameterTool.getRequired(ParameterTool.java:289)
at
org.apache.flink.api.java.utils.ParameterTool.getBoolean(ParameterTool.java:427)

Is this a regression or is the inteded behaviour? This could be simply
fixed using

parameters.getBoolean(*getMyBooleanOption*().getName(),Boolean.valueOf(
*getMyBooleanOption*().getDefaultValue()));

but the previous mechanism was better (IMHO).

Thanks in advance,
Flavio