iotaledger/iota-java

ApiBuilder host checking might cause trouble on Android

remmerw opened this issue · 3 comments

The checking if the host is valid does not make sense (at least not for me),
because when it fails, it is just catched

Moreover, this causes lots of touble (esp. when connection is slow, the
command takes ages to complete, besides on Android the creation of an API
has now to be done on a worker thread, because of network access)

 ApiBuilder 
 public T host(String host) {
    try {
        // Throws exception if invalid
        InetAddress.getByName(host);   -> I guess this is a mistake ( the exception is just catched)
        this.host = host;
    } catch (UnknownHostException e) {
        e.printStackTrace();                     
    }
    
    return (T) this;
}

Hey @remmerw,
Makes sense, i will add one setter without verification, and actually make use of the error ;)

@remmerw Unfortunately forgot to add this to the last release, i'm very sorry!
I shall make the PR tomorrow and make some other smaller additions, and release a new version Friday the 12th

Im an idiot, its done now! @remmerw
Since you are also able to define nodes through a different manner, it is possible to recover from a fail. That is why we just log. It will fail at another place if no usable node is found