Returns null instead of "null" String from getHostAddress. Adds a check for null in toString().
This commit is contained in:
parent
a0f6622934
commit
140de712e7
@ -136,7 +136,13 @@ public class TransportAddress
|
|||||||
*/
|
*/
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder bldr = new StringBuilder(getHostAddress());
|
String hostAddress = getHostAddress();
|
||||||
|
if(hostAddress == null)
|
||||||
|
{
|
||||||
|
hostAddress = getHostName();
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder bldr = new StringBuilder(hostAddress);
|
||||||
|
|
||||||
if(isIPv6())
|
if(isIPv6())
|
||||||
bldr.insert(0, "[").append("]");
|
bldr.insert(0, "[").append("]");
|
||||||
@ -156,7 +162,7 @@ public class TransportAddress
|
|||||||
{
|
{
|
||||||
InetAddress addr = getAddress();
|
InetAddress addr = getAddress();
|
||||||
String addressStr
|
String addressStr
|
||||||
= addr != null ? addr.getHostAddress() : "null";
|
= addr != null ? addr.getHostAddress() : null;
|
||||||
|
|
||||||
if(addr instanceof Inet6Address)
|
if(addr instanceof Inet6Address)
|
||||||
addressStr = NetworkUtils.stripScopeID(addressStr);
|
addressStr = NetworkUtils.stripScopeID(addressStr);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user