You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/06/30 06:41:00 UTC

[jira] [Commented] (FLINK-9694) Potentially NPE in CompositeTypeSerializerConfigSnapshot constructor

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

ASF GitHub Bot commented on FLINK-9694:
---------------------------------------

GitHub user yanghua opened a pull request:

    https://github.com/apache/flink/pull/6231

    [FLINK-9694] Potentially NPE in CompositeTypeSerializerConfigSnapshot constructor

    ## What is the purpose of the change
    
    *This pull request fixed a NPE in CompositeTypeSerializerConfigSnapshot constructor*
    
    ## Brief change log
    
      - *Add a non-null check in CompositeTypeSerializerConfigSnapshot constructor*
    
    ## Verifying this change
    
    This change is a trivial rework / code cleanup without any test coverage.
    
    ## Does this pull request potentially affect one of the following parts:
    
      - Dependencies (does it add or upgrade a dependency): (yes / **no**)
      - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
      - The serializers: (yes / **no** / don't know)
      - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
      - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
      - The S3 file system connector: (yes / **no** / don't know)
    
    ## Documentation
    
      - Does this pull request introduce a new feature? (yes / **no**)
      - If yes, how is the feature documented? (not applicable / docs / JavaDocs / **not documented**)


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/yanghua/flink FLINK-9694

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/6231.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #6231
    
----
commit 8d5bb522d3f457db4ccf3a0f1045dec4b431b268
Author: yanghua <ya...@...>
Date:   2018-06-30T06:37:14Z

    [FLINK-9694] Potentially NPE in CompositeTypeSerializerConfigSnapshot constructor

----


> Potentially NPE in CompositeTypeSerializerConfigSnapshot constructor
> --------------------------------------------------------------------
>
>                 Key: FLINK-9694
>                 URL: https://issues.apache.org/jira/browse/FLINK-9694
>             Project: Flink
>          Issue Type: Bug
>          Components: Table API &amp; SQL
>    Affects Versions: 1.5.0
>            Reporter: vinoyang
>            Assignee: vinoyang
>            Priority: Minor
>              Labels: pull-request-available
>
> the partial specific exception stack trace :
> {code:java}
> Caused by: java.lang.NullPointerException
> at org.apache.flink.api.common.typeutils.CompositeTypeSerializerConfigSnapshot.<init>(CompositeTypeSerializerConfigSnapshot.java:53)
> at org.apache.flink.table.runtime.types.CRowSerializer$CRowSerializerConfigSnapshot.<init>(CRowSerializer.scala:120)
> at org.apache.flink.table.runtime.types.CRowSerializer$CRowSerializerConfigSnapshot.<init>(CRowSerializer.scala:123)
> at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> at java.lang.Class.newInstance(Class.java:442)
> at org.apache.flink.util.InstantiationUtil.instantiate(InstantiationUtil.java:319)
> ... 20 more{code}
> related code is : 
> {code:java}
> public CompositeTypeSerializerConfigSnapshot(TypeSerializer<?>... nestedSerializers) {
>    Preconditions.checkNotNull(nestedSerializers);
>    this.nestedSerializersAndConfigs = new ArrayList<>(nestedSerializers.length);
>    for (TypeSerializer<?> nestedSerializer : nestedSerializers) {
>       TypeSerializerConfigSnapshot configSnapshot = nestedSerializer.snapshotConfiguration();
>       this.nestedSerializersAndConfigs.add(
>          new Tuple2<TypeSerializer<?>, TypeSerializerConfigSnapshot>(
>             nestedSerializer.duplicate(),
>             Preconditions.checkNotNull(configSnapshot)));
>    }
> }
> {code}
> exception happens at : 
> {code:java}
> TypeSerializerConfigSnapshot configSnapshot = nestedSerializer.snapshotConfiguration();
> {code}
> the reason is the type of constructor's parameter "..." used "varargs" feature. The  initialize code in *CRowSerializer.scala* is : 
> {code:java}
> def this() = this(null)    // Scala code
> {code}
> when invoked this, actually the the type of CompositeTypeSerializerConfigSnapshot's
> nestedSerializers parameter is :
> {code:java}
> TypeSerializer<?>[] nestedSerializers = new TypeSerializer<?>[] {null};
> {code}
> so the checkNotNull precondition statement :
> {code:java}
> Preconditions.checkNotNull(nestedSerializers);
> {code}
> is always useless.
> So we should check the object reference in _for_ loop to protect NPE. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)