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

ASF GitHub Bot commented on IGNITE-9160:
----------------------------------------

GitHub user zzzadruga opened a pull request:

    https://github.com/apache/ignite/pull/4478

    IGNITE-9160 Fix equals() methods

    

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

    $ git pull https://github.com/zzzadruga/ignite IGINTE-9160

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

    https://github.com/apache/ignite/pull/4478.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 #4478
    
----
commit 04d85b874f3626739cab02e501db58e2cbe39fce
Author: zzzadruga <zzzadruga@...>
Date:   2018-08-02T15:25:49Z

    IGNITE-9160 Fix equals() methods

----


> FindBugs: NPE and CCE on equals() methods
> -----------------------------------------
>
>                 Key: IGNITE-9160
>                 URL: https://issues.apache.org/jira/browse/IGNITE-9160
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 2.6
>            Reporter: Nikolai Kulagin
>            Assignee: Nikolai Kulagin
>            Priority: Minor
>              Labels: newbie
>             Fix For: 2.7
>
>
> Some classes have Incorrect equals() method:
> {code:java}
> // GridDhtPartitionMap.java
> @Override public boolean equals(Object o) {
>     if (this == o)
>         return true;
>     GridDhtPartitionMap other = (GridDhtPartitionMap)o;
>     return other.nodeId.equals(nodeId) && other.updateSeq == updateSeq;
> }{code}
> In this case, we can get CCE  
> {code:java}
> GridDhtPartitionMap gridDhtPartMap = new GridDhtPartitionMap();
> gridDhtPartMap.equals(new Object());
> --------------------------------------------------------------
> Exception in thread "main" java.lang.ClassCastException: java.lang.Object 
> cannot be cast to 
> org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap
> at 
> org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap.equals(GridDhtPartitionMap.java:319)
> at ru.zzzadruga.Ignite.main(Ignite.java:9){code}
>  Or NPE 
> {code:java}
> GridDhtPartitionMap gridDhtPartMap = new GridDhtPartitionMap();
> gridDhtPartMap.equals(null);
> --------------------------------------------------------------
> Exception in thread "main" java.lang.NullPointerException
> at 
> org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap.equals(GridDhtPartitionMap.java:321)
> at ru.zzzadruga.Ignite.main(Ignite.java:9){code}
>  The following code will prevent this
> {code:java}
> if (o == null || getClass() != o.getClass())
>     return false;{code}
> + List of classes with similar problems: +
>  * *GridTopic$T1-T8* - NPE
>  * *GridCachePreloadLifecycleAbstractTest -* NPE
>  * *GridDhtPartitionFullMap -* NPE and CCE
>  * *GridDhtPartitionMap -* NPE and CCE
>  * *OptimizedMarshallerSelfTest -* NPE and CCE
>  * *GatewayProtectedCacheProxy -* NPE and CCE
>  * *GridNearOptimisticTxPrepareFuture -* NPE and CCE
>  * *GridCacheDistributedQueryManager -* NPE and CCE
>  * *GridServiceMethodReflectKey -* NPE and CCE
>  *  *GridListSetSelfTest -* NPE and CCE
>  * *GridTestKey -* NPE and CCE
>  * *GridCacheMvccCandidate -* CCE
>  * *GridDhtPartitionExchangeId -* CCE
>  * *GridTuple6 -* CCE



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

Reply via email to