From f57ba6870ef00717c215fe0aa35db5667f1f3de5 Mon Sep 17 00:00:00 2001 From: "lubomir.marinov" Date: Tue, 29 Jun 2010 09:45:27 +0000 Subject: [PATCH] Fixes a NullPointerException in the case of relayed candidates. --- src/org/ice4j/ice/FoundationsRegistry.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/org/ice4j/ice/FoundationsRegistry.java b/src/org/ice4j/ice/FoundationsRegistry.java index e0b84f1..f6e0313 100644 --- a/src/org/ice4j/ice/FoundationsRegistry.java +++ b/src/org/ice4j/ice/FoundationsRegistry.java @@ -45,15 +45,23 @@ public class FoundationsRegistry public void assignFoundation(Candidate candidate) { //create the foundation key String - String type = candidate.getType().toString(); + CandidateType candidateType = candidate.getType(); + String type = candidateType.toString(); String base = candidate.getBase().getTransportAddress().getHostAddress(); - String server = null; + String server; - if(candidate.getType() == CandidateType.SERVER_REFLEXIVE_CANDIDATE - || candidate.getType() == CandidateType.RELAYED_CANDIDATE) + switch (candidateType) { + case SERVER_REFLEXIVE_CANDIDATE: server = candidate.getStunServerAddress().getHostAddress(); + break; + case RELAYED_CANDIDATE: + server = candidate.getTurnServerAddress().getHostAddress(); + break; + default: + server = null; + break; } String transport = candidate.getTransport().toString();