Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #49 from bryanck/fix/tephra-86
Browse files Browse the repository at this point in the history
tephra-86 resolve hostname for address 0.0.0.0
  • Loading branch information
nitinmotgi committed May 22, 2015
2 parents 8615f0d + 230d46c commit 36c42c1
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand All @@ -59,6 +61,14 @@ public TransactionService(Configuration conf,

@Override
protected InetSocketAddress getAddress() {
if (address.equals("0.0.0.0")) {
// resolve hostname
try {
return new InetSocketAddress(InetAddress.getLocalHost().getHostName(), server.getBindAddress().getPort());
} catch (UnknownHostException x) {
LOG.error("Cannot resolve hostname for 0.0.0.0", x);
}
}
return server.getBindAddress();
}

Expand Down

0 comments on commit 36c42c1

Please sign in to comment.