You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Brandon Williams (Jira)" <ji...@apache.org> on 2023/06/23 11:05:00 UTC

[jira] [Updated] (CASSANDRA-18622) StorageService throws inconsistent exceptions for unknown hosts

     [ https://issues.apache.org/jira/browse/CASSANDRA-18622?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brandon Williams updated CASSANDRA-18622:
-----------------------------------------
     Bug Category: Parent values: Correctness(12982)Level 1 values: API / Semantic Implementation(12988)
       Complexity: Normal
      Component/s: Legacy/Core
    Discovered By: User Report
    Fix Version/s: 5.x
         Severity: Normal
           Status: Open  (was: Triage Needed)

> StorageService throws inconsistent exceptions for unknown hosts
> ---------------------------------------------------------------
>
>                 Key: CASSANDRA-18622
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18622
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Legacy/Core
>            Reporter: Hao Zhong
>            Priority: Normal
>             Fix For: 5.x
>
>
> When hosts are unknown, StorageService throws two types of exceptions. The following methods throw RuntimeException:
>  
> {code:java}
>  public String getNativeaddress(InetAddressAndPort endpoint, boolean withPort){
>   ...
>   try{                
>     InetAddressAndPort address =   InetAddressAndPort.getByName(Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.NATIVE_ADDRESS_AND_PORT).value);                
>     return address.getHostAddress(withPort);            
> }catch (UnknownHostException e) {
>       throw new RuntimeException(e);            
>  }
> }{code}
> {code:java}
> public void onChange(InetAddressAndPort endpoint, ApplicationState state, VersionedValue value){
> ...
> try { 
>   InetAddressAndPort address = InetAddressAndPort.getByName(value.value);   SystemKeyspace.updatePeerNativeAddress(endpoint, address); 
> } catch (UnknownHostException e) 
> { 
>     throw new RuntimeException(e); 
> }
> ...
> }
> {code}
> A method throws IllegalArgumentException
> {code:java}
>  public void rebuild(String sourceDc, String keyspace, String tokens, String specificSources, boolean excludeLocalDatacenterNodes){
>   ...
>   try                        {                            InetAddressAndPort endpoint = InetAddressAndPort.getByName(stringHost);                            if (FBUtilities.getBroadcastAddressAndPort().equals(endpoint))                            {                                throw new IllegalArgumentException("This host was specified as a source for rebuilding. Sources for a rebuild can only be other nodes in the cluster.");                            }                            sources.add(endpoint);                        }                        catch (UnknownHostException ex)                        {                            throw new IllegalArgumentException("Unknown host specified " + stringHost, ex);                        }
> } {code}
> A method throws no exceptions:
> {code:java}
> private void handleStateBootreplacing(InetAddressAndPort newNode, String[] pieces){
>  ...
> try {
>       oldNode = InetAddressAndPort.getByName(pieces[1]);        
> } catch (Exception e) {            
>    logger.error("Node {} tried to replace malformed endpoint {}.", newNode, pieces[1], e);            
>    return;        
> }
> ...
> } {code}
> A method does not rethrow exceptions and throws 
> {color:#000000}UnknownHostException{color}
> {code:java}
>  public List<String> getTokens(String endpoint) throws UnknownHostException    {        return getTokens(InetAddressAndPort.getByName(endpoint));    } {code}
> {color:#000000}The treatments look random. {color}



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

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