Skip to content
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
This repository was archived by the owner on Aug 13, 2026. It is now read-only.

No UnknownHostException is thrown when invalid host is used. [JIRA: CLIENTS-401] #518

Description

@calvernaz

Given an invalid host I was excepting an exception has the documentation states.

After a bit of debugging, it seems the excepted exception it's being swallowed
and we should rely on isUnresolved method.

Testing code:

client = RiakClient.newClient(Lists.newArrayList("no_place_like_home.com"));

Riak client handling

bootstrap.handler(new RiakChannelInitializer(this))
     .remoteAddress(new InetSocketAddress(remoteAddress, port));

InetSocketAddress handling

    public InetSocketAddress(String hostname, int port) {
        checkHost(hostname);
        InetAddress addr = null;
        String host = null;
        try {
            addr = InetAddress.getByName(hostname);
        } catch(UnknownHostException e) {
            host = hostname;
        }
        holder = new InetSocketAddressHolder(host, addr, checkPort(port));
    }

I was wondering if we could fix this behaviour or if there is any reason for that, like in a situation of many nodes and just one is not possible to resolve.

Version details:

$ java -version
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
<dependency>
  <groupId>com.basho.riak</groupId>
  <artifactId>riak-client</artifactId>
  <version>2.0.0</version>
</dependency>

Activity

  1. changed the title [-]No UnknownHostException is thrown when invalid host is used.[/-] [+]No UnknownHostException is thrown when invalid host is used. [JIRA: CLIENTS-401][/+] on May 10, 2015
  2. alexmoore commented on Jul 22, 2015

    @alexmoore
    Contributor

    Thanks for the submission!

  3. alexmoore commented on Jul 24, 2015

    @alexmoore
    Contributor

    This was merged on the develop branch, and should be out with the next release (today or next week).

  4. added this to the Java Client v2.0.2 milestone on Jul 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions