The MasterSlaveTopologyProvider has a regular expression for matching the master host, which is:
^master_host\:([a-zA-Z\,\=\d\.\:]+)$
Unfortunately, this regex doesn't actually match all valid host names, since hostnames may contain hyphens. This won't be an issue when connecting to a master (since slaves are reported as resolved IP addresses), but it is an issue when connecting to an intermediate node (i.e. an instance which itself has a slave, but is also slaved to a master).
In that case, the slave retains the hostname of the master (rather than the IP), which causes the topology provider to throw an exception. I believe this is fixed by changing the regex to be:
^master_host\:([a-zA-Z\,\=\d\.\:\-]+)$