logs: Logs a warning

if a mapping harvester is not configured at harvest time.
This commit is contained in:
Boris Grozev 2016-11-14 15:32:04 -06:00
parent dc4e05e5d9
commit 452af370a5

View File

@ -21,6 +21,7 @@ import org.ice4j.*;
import org.ice4j.ice.*; import org.ice4j.ice.*;
import java.util.*; import java.util.*;
import java.util.logging.*;
/** /**
* Uses a list of addresses as a predefined static mask in order to generate * Uses a list of addresses as a predefined static mask in order to generate
@ -43,6 +44,13 @@ import java.util.*;
public class MappingCandidateHarvester public class MappingCandidateHarvester
extends AbstractCandidateHarvester extends AbstractCandidateHarvester
{ {
/**
* The <tt>Logger</tt> used by the <tt>StunCandidateHarvester</tt> class and
* its instances for logging output.
*/
private static final Logger logger
= Logger.getLogger(StunCandidateHarvester.class.getName());
/** /**
* The addresses that we will use as a mask * The addresses that we will use as a mask
*/ */
@ -77,8 +85,14 @@ public class MappingCandidateHarvester
*/ */
public Collection<LocalCandidate> harvest(Component component) public Collection<LocalCandidate> harvest(Component component)
{ {
if (getMask() == null || getFace() == null) TransportAddress mask = getMask();
TransportAddress face = getFace();
if (face == null || mask == null)
{
logger.warning("Harvester not configured: face=" + face
+ ", mask="+mask);
return null; return null;
}
/* /*
* Report the LocalCandidates gathered by this CandidateHarvester so * Report the LocalCandidates gathered by this CandidateHarvester so
@ -90,15 +104,15 @@ public class MappingCandidateHarvester
{ {
if (!(cand instanceof HostCandidate) if (!(cand instanceof HostCandidate)
|| !cand.getTransportAddress().getHostAddress() || !cand.getTransportAddress().getHostAddress()
.equals(getFace().getHostAddress()) .equals(face.getHostAddress())
|| cand.getTransport() != getFace().getTransport()) || cand.getTransport() != face.getTransport())
{ {
continue; continue;
} }
HostCandidate hostCandidate = (HostCandidate) cand; HostCandidate hostCandidate = (HostCandidate) cand;
TransportAddress mappedAddress = new TransportAddress( TransportAddress mappedAddress = new TransportAddress(
getMask().getHostAddress(), mask.getHostAddress(),
hostCandidate.getHostAddress().getPort(), hostCandidate.getHostAddress().getPort(),
hostCandidate.getHostAddress().getTransport()); hostCandidate.getHostAddress().getTransport());
@ -129,7 +143,7 @@ public class MappingCandidateHarvester
*/ */
public TransportAddress getMask() public TransportAddress getMask()
{ {
return this.mask; return mask;
} }
/** /**
@ -138,6 +152,6 @@ public class MappingCandidateHarvester
*/ */
public TransportAddress getFace() public TransportAddress getFace()
{ {
return this.face; return face;
} }
} }