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

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

Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4328#discussion_r131107598
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/state/RegisteredOperatorBackendStateMetaInfo.java
 ---
    @@ -175,14 +176,19 @@ public boolean equals(Object obj) {
                                return false;
                        }
     
    +                   if (!(obj instanceof Snapshot)) {
    +                           return false;
    +                   }
    +
    +                   Snapshot snapshot = (Snapshot)obj;
    +
                        // need to check for nulls because serializer and 
config snapshots may be null on restore
    -                   return (obj instanceof Snapshot)
    -                           && name.equals(((Snapshot) obj).getName())
    -                           && assignmentMode.equals(((Snapshot) 
obj).getAssignmentMode())
    -                           && ((partitionStateSerializer == null && 
((Snapshot) obj).getPartitionStateSerializer() == null)
    -                                   || 
partitionStateSerializer.equals(((Snapshot) obj).getPartitionStateSerializer()))
    -                           && ((partitionStateSerializerConfigSnapshot == 
null && ((Snapshot) obj).getPartitionStateSerializerConfigSnapshot() == null)
    -                                   || 
partitionStateSerializerConfigSnapshot.equals(((Snapshot) 
obj).getPartitionStateSerializerConfigSnapshot()));
    +                   return Objects.equals(name, snapshot.getName())
    +                           && Objects.equals(assignmentMode, 
snapshot.getAssignmentMode())
    +                           && ((partitionStateSerializer == null && 
(snapshot.getPartitionStateSerializer() == null)
    +                                   || 
(Objects.equals(partitionStateSerializer, 
snapshot.getPartitionStateSerializer())))
    +                           && ((partitionStateSerializerConfigSnapshot == 
null && (snapshot.getPartitionStateSerializerConfigSnapshot() == null)
    +                                   || 
(Objects.equals(partitionStateSerializerConfigSnapshot, 
snapshot.getPartitionStateSerializerConfigSnapshot())))));
    --- End diff --
    
    Same for these two.


> Ineffective null check in RegisteredOperatorBackendStateMetaInfo#equals()
> -------------------------------------------------------------------------
>
>                 Key: FLINK-6493
>                 URL: https://issues.apache.org/jira/browse/FLINK-6493
>             Project: Flink
>          Issue Type: Bug
>          Components: State Backends, Checkpointing
>            Reporter: Ted Yu
>            Assignee: mingleizhang
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> {code}
>         && ((partitionStateSerializer == null && ((Snapshot) 
> obj).getPartitionStateSerializer() == null)
>           || partitionStateSerializer.equals(((Snapshot) 
> obj).getPartitionStateSerializer()))
>         && ((partitionStateSerializerConfigSnapshot == null && ((Snapshot) 
> obj).getPartitionStateSerializerConfigSnapshot() == null)
>           || partitionStateSerializerConfigSnapshot.equals(((Snapshot) 
> obj).getPartitionStateSerializerConfigSnapshot()));
> {code}
> The null check for partitionStateSerializer / 
> partitionStateSerializerConfigSnapshot is in combination with another clause.
> This may lead to NPE in the partitionStateSerializer.equals() call.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to