Skip to content

Instantly share code, notes, and snippets.

@cantremember
Created March 23, 2012 05:14
Show Gist options
  • Save cantremember/2167130 to your computer and use it in GitHub Desktop.
Save cantremember/2167130 to your computer and use it in GitHub Desktop.
trivial InetAddress.getByName() in Java
try {
if (getLog().isTraceEnabled())
getLog().trace("lookup : " + hostname);
// oh, lookup!
InetAddress ipAddress = InetAddress.getByName(hostname);
// NOTE: this is where it went bad on the AWS image
// *sigh*
return ipAddress.getHostAddress();
}
catch (UnknownHostException e) { }
catch (Exception e) {
getLog().warn("failed to lookup " + hostname, e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment