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

Pranav commented on CASSANDRA-20603:
------------------------------------

Hi [~dcapwell] ,
To prevent a potential {{NullPointerException}}  ,can't we add a null check for 
the endpoint before accessing its heartbeat state. If the endpoint is unknown, 
we can simply log a debug message and safely return early. Here's the suggested 
change:

EndpointState endpointState = 
Gossiper.instance.getEndpointStateForEndpoint(message.from());
if (endpointState == null)
{

logger.debug("Ignoring shutdown message from {} because endpoint state is 
unknown", message.from());

return;
}
HeartBeatState previous = endpointState.getHeartBeatState();

> NPE when a node sees gossip shutdown from unknown peer
> ------------------------------------------------------
>
>                 Key: CASSANDRA-20603
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-20603
>             Project: Apache Cassandra
>          Issue Type: Bug
>          Components: Cluster/Gossip
>            Reporter: David Capwell
>            Assignee: David Capwell
>            Priority: Normal
>             Fix For: 5.0.x
>
>
> {code}
> java.lang.NullPointerException
>     at 
> org.apache.cassandra.gms.GossipShutdownVerbHandler.doVerb(GossipShutdownVerbHandler.java:52)
> {code}
> This is due to
> {code}
> Gossiper.instance.getEndpointStateForEndpoint(message.from()).getHeartBeatState();
> {code}
> The endpoint isn’t known so getHeartBeatState can’t be called



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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to