mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
Make connectUsingConfiguration more robust
If 'return' is not reached, then always throw a ConnectionException. Also make it clear that populateHostAddresses adds at least one address.
This commit is contained in:
parent
e6045c6593
commit
d9c97fabfb
2 changed files with 25 additions and 20 deletions
|
@ -570,7 +570,11 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
protected List<HostAddress> hostAddresses;
|
||||
|
||||
protected void populateHostAddresses() throws Exception {
|
||||
/**
|
||||
* Populates {@link #hostAddresses} with at least one host address.
|
||||
*
|
||||
*/
|
||||
protected void populateHostAddresses() {
|
||||
// N.B.: Important to use config.serviceName and not AbstractXMPPConnection.serviceName
|
||||
if (config.host != null) {
|
||||
hostAddresses = new ArrayList<HostAddress>(1);
|
||||
|
@ -580,6 +584,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
} else {
|
||||
hostAddresses = DNSUtil.resolveXMPPDomain(config.serviceName);
|
||||
}
|
||||
// If we reach this, then hostAddresses *must not* be empty, i.e. there is at least one host added, either the
|
||||
// config.host one or the host representing the service name by DNSUtil
|
||||
assert(!hostAddresses.isEmpty());
|
||||
}
|
||||
|
||||
protected Lock getConnectionLock() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue