[sip-comm-dev] Exception when no network is available


#1

Hi, if all my network interfaces are disabled, I have the following exception.
It would be possible to do some checks in that method to see if it was
possible to find a network address to avoid this NPE, but the problem
will occur in the callers of that method and should be fixed here.
Or it would be possible to throw an IO exception but the interface
doesn't allow that and should be modified in that case.
What's the best option ?

Matthieu

     [java] java.lang.NullPointerException
     [java] at
net.java.sip.communicator.impl.netaddr.NetworkAddressManagerServiceImpl.getLocalHost(NetworkAddressManagerServiceImpl.java:303)
     [java] at
net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl.getLocalViaHeaders(ProtocolProviderServiceSipImpl.java:967)
     [java] at
net.java.sip.communicator.impl.protocol.sip.SipMessageFactory.createRegisterRequest(SipMessageFactory.java:1046)
     [java] at
net.java.sip.communicator.impl.protocol.sip.SipRegistrarConnection.register(SipRegistrarConnection.java:205)
     [java] at
net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl.register(ProtocolProviderServiceSipImpl.java:309)

···

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#2

Hey Matthieu,

На 09.08.10 16:05, Matthieu Casanova написа:

Hi, if all my network interfaces are disabled, I have the following exception.
It would be possible to do some checks in that method to see if it was
possible to find a network address to avoid this NPE, but the problem
will occur in the callers of that method and should be fixed here.
Or it would be possible to throw an IO exception but the interface
doesn't allow that and should be modified in that case.
What's the best option ?

I believe that if we add a null check in the if condition, we should be
OK and the method would simply return the result of
InetAddress.getLocalHost().

Could you please try that out and let me know what happens?

Thanks,
Emil

···

Matthieu

     [java] java.lang.NullPointerException
     [java] at
net.java.sip.communicator.impl.netaddr.NetworkAddressManagerServiceImpl.getLocalHost(NetworkAddressManagerServiceImpl.java:303)
     [java] at
net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl.getLocalViaHeaders(ProtocolProviderServiceSipImpl.java:967)
     [java] at
net.java.sip.communicator.impl.protocol.sip.SipMessageFactory.createRegisterRequest(SipMessageFactory.java:1046)
     [java] at
net.java.sip.communicator.impl.protocol.sip.SipRegistrarConnection.register(SipRegistrarConnection.java:205)
     [java] at
net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl.register(ProtocolProviderServiceSipImpl.java:309)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org PHONE: +33.1.77.62.43.30
http://sip-communicator.org FAX: +33.1.77.62.47.31

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#3

Hi Emil,

Hey Matthieu,

На 09.08.10 16:05, Matthieu Casanova написа:

Hi, if all my network interfaces are disabled, I have the following exception.
It would be possible to do some checks in that method to see if it was
possible to find a network address to avoid this NPE, but the problem
will occur in the callers of that method and should be fixed here.
Or it would be possible to throw an IO exception but the interface
doesn't allow that and should be modified in that case.
What's the best option ?

I believe that if we add a null check in the if condition, we should be
OK and the method would simply return the result of
InetAddress.getLocalHost().

Could you please try that out and let me know what happens?

I just added that, if localHost is null, I get InetAddress, now it
works fine (as good as possible without network :wink:

Matthieu

···

2010/8/9 Emil Ivov <emcho@sip-communicator.org>:

Thanks,
Emil

Matthieu

 \[java\] java\.lang\.NullPointerException
 \[java\]     at

net.java.sip.communicator.impl.netaddr.NetworkAddressManagerServiceImpl.getLocalHost(NetworkAddressManagerServiceImpl.java:303)
[java] at
net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl.getLocalViaHeaders(ProtocolProviderServiceSipImpl.java:967)
[java] at
net.java.sip.communicator.impl.protocol.sip.SipMessageFactory.createRegisterRequest(SipMessageFactory.java:1046)
[java] at
net.java.sip.communicator.impl.protocol.sip.SipRegistrarConnection.register(SipRegistrarConnection.java:205)
[java] at
net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl.register(ProtocolProviderServiceSipImpl.java:309)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org PHONE: +33.1.77.62.43.30
http://sip-communicator.org FAX: +33.1.77.62.47.31