You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Ran Tao (Jira)" <ji...@apache.org> on 2022/12/01 09:52:00 UTC

[jira] [Commented] (FLINK-30259) Use flink Preconditions Util instead of uncertain Assert keyword to do checking

    [ https://issues.apache.org/jira/browse/FLINK-30259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17641802#comment-17641802 ] 

Ran Tao commented on FLINK-30259:
---------------------------------

Hi, [~martijnvisser] can u take a look for this?  i’m glad to improve it.

> Use flink Preconditions Util instead of uncertain Assert keyword to do checking
> -------------------------------------------------------------------------------
>
>                 Key: FLINK-30259
>                 URL: https://issues.apache.org/jira/browse/FLINK-30259
>             Project: Flink
>          Issue Type: Improvement
>          Components: Deployment / Kubernetes, Formats (JSON, Avro, Parquet, ORC, SequenceFile), Table SQL / Planner
>    Affects Versions: 1.16.0
>            Reporter: Ran Tao
>            Priority: Major
>
> The code of some modules of the current Flink project uses the 'assert' keyword of java to do checking, which actually depends on the enablement of the -enableassertions (-ea) option (default is false), otherwise it may lead to unexpected behavior. In fact, flink already has a mature Preconditions tool, we can use it to replace 'assert' keyword. it is more clean and consistent with flink.
> The following is an example of some patch. (by using idea, we can fix it easily.)
> RowDataPrintFunction
> {code:java}
> @Override
>         public void invoke(RowData value, Context context) {
>             Object data = converter.toExternal(value);
>             assert data != null;
>             writer.write(data.toString());
>         }
> {code}
> KubernetesUtils
> {code:java}
>     public static KubernetesConfigMap checkConfigMaps(
>             List<KubernetesConfigMap> configMaps, String expectedConfigMapName) {
>         assert (configMaps.size() == 1);
>         assert (configMaps.get(0).getName().equals(expectedConfigMapName));
>         return configMaps.get(0);
>     }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)