diff options
author | Alex Clayton <alex.clayton@isode.com> | 2016-07-13 15:42:34 (GMT) |
---|---|---|
committer | Alex Clayton <alex.clayton@isode.com> | 2016-07-15 15:19:04 (GMT) |
commit | 4e70a84a8a792cfeae96bf7a0cb4c9b549e44d29 (patch) | |
tree | af606f030af75a86dcb0187c20d6466b1501b851 /Documentation | |
parent | 8708b7b01cf4f36524bff3dc9aa5a7a6534ce221 (diff) | |
download | stroke-4e70a84a8a792cfeae96bf7a0cb4c9b549e44d29.zip stroke-4e70a84a8a792cfeae96bf7a0cb4c9b549e44d29.tar.bz2 |
Stop HostAddress constructor running DNS lookup.
When running the latest stroke against harrier android a NetworkOnMainThread exception
was encountered. This was traced to the new constructor HostAddress(String) that was
been called by Connector.start() method.
The issue was dues to difference between the java code in stroke and
the c++ code in swiften.
In swiften the equivalent conde calls boost::asio::ip::address::from_string, which
parses a string that may be an ipv4 or ipv6 address into an IP address object. If
the string is not one of these then the object is left invalid.
In the java code InetAddress.getByName(String name) is used instead. If this
is an ipv4 or ipv6 address then it parses it into an InetAddress object. However if
is not one of these it does a DNS lookup on the address. This was what was causing
the error.
To match the C++ the java code should only create an InetAddress if the input is
an IP address, if not it should be left null.
This was done by copying the IPv4 and IPv6 regexes in the Regex class in isode lib.
The input to HostAddress(String) is checked against these if it matches InetAddress.getByName
is called, otherwise address is set to null.
Test-information:
Ran unit tests in stroke they all pass.
Ran code against android harrier, no longer fails.
Ran against MLC (with updates for other changes in stroke api) it still passes.
Change-Id: I1945c7c3cdfece8feb45b9196483131c0d9c4e7c
Diffstat (limited to 'Documentation')
0 files changed, 0 insertions, 0 deletions