diff options
author | Matthieu Casanova <kpouer@java.net> | 2010-08-11 08:36:52 +0000 |
---|---|---|
committer | Matthieu Casanova <kpouer@java.net> | 2010-08-11 08:36:52 +0000 |
commit | 70f6d9dd8d8557816697ba89ea7494fdeb8b83f1 (patch) | |
tree | b229759222b4811dc6a781cd8d74667261bd17c7 /src/net/java/sip/communicator/impl/netaddr | |
parent | 3087aaac8a96f7e45867a82e070a9c390b929f53 (diff) | |
download | jitsi-70f6d9dd8d8557816697ba89ea7494fdeb8b83f1.zip jitsi-70f6d9dd8d8557816697ba89ea7494fdeb8b83f1.tar.gz jitsi-70f6d9dd8d8557816697ba89ea7494fdeb8b83f1.tar.bz2 |
fixed a NPE when localHost was not retrieved
Diffstat (limited to 'src/net/java/sip/communicator/impl/netaddr')
-rw-r--r-- | src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java index 260ddff..55893a5 100644 --- a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java +++ b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java @@ -300,6 +300,18 @@ public class NetworkAddressManagerServiceImpl //windows socket implementations return the any address so we need to //find something else here ... InetAddress.getLocalHost seems to work //better on windows so lets hope it'll do the trick. + + if (localHost == null) + { + try + { + localHost = InetAddress.getLocalHost(); + } + catch (UnknownHostException e) + { + logger.warn("Failed to get localhost ", e); + } + } if( localHost.isAnyLocalAddress()) { if (logger.isTraceEnabled()) @@ -491,7 +503,7 @@ public class NetworkAddressManagerServiceImpl return new InetSocketAddress(getLocalHost(dst), port); } StunAddress mappedAddress = queryStunServer(port); - InetSocketAddress result = null; + InetSocketAddress result; if (mappedAddress != null) result = mappedAddress.getSocketAddress(); else @@ -657,7 +669,6 @@ public class NetworkAddressManagerServiceImpl { logger.fatal("An exception occurred while trying to create" + "a local host discovery socket.", exc); - resultSocket = null; return null; } //port seems to be taken. try another one. |