You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "loyi (Jira)" <ji...@apache.org> on 2021/04/28 10:43:00 UTC

[jira] [Created] (KAFKA-12723) Potential NPE in SnapshottableHashTable.java

loyi created KAFKA-12723:
----------------------------

             Summary: Potential NPE in SnapshottableHashTable.java
                 Key: KAFKA-12723
                 URL: https://issues.apache.org/jira/browse/KAFKA-12723
             Project: Kafka
          Issue Type: Bug
    Affects Versions: 2.8.0
            Reporter: loyi


The method mergeFrom of {color:#de350b}HashTier{color} maybe has potential NPE ,  the attribute deltaTable in {color:#de350b}other{color} variable may be null.    Maybe we should add a check. 

 

The following is the method:

public void mergeFrom(long epoch, Delta source) {
    HashTier<T> other = (HashTier<T>) source;
    List<T> list = new ArrayList<>();
    Object[] otherElements = other.deltaTable.baseElements();    // Add a null check 
    ......
}

 

After fix:

public void mergeFrom(long epoch, Delta source) {
    HashTier<T> other = (HashTier<T>) source;
    List<T> list = new ArrayList<>();
    BaseHashTable<T> otherDeltaTable = other.deltaTable;
    if (otherDeltaTable != null) {

        ......
    }
}

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)