Fixes GitHub issue #22: CandidateAttribute.clone() causes NullPointerException.

This commit is contained in:
Lyubomir Marinov 2015-07-28 11:56:35 -05:00
parent 75c2a52f9e
commit 7072173ed3
2 changed files with 15 additions and 14 deletions

View File

@ -28,7 +28,11 @@ public class CandidateAttribute extends AttributeField
/**
* The Candidate that we will be encapsulating.
*/
private final Candidate<?> candidate;
private Candidate<?> candidate;
protected CandidateAttribute()
{
}
/**
* Creates an attribute instance
@ -69,8 +73,6 @@ public class CandidateAttribute extends AttributeField
return true;
}
;
/**
* Returns the value of this attribute.
*
@ -111,10 +113,9 @@ public class CandidateAttribute extends AttributeField
* @throws javax.sdp.SdpException if there's a problem with the <tt>value
* String</tt>.
*/
public void setValue(String value) throws
SdpException
public void setValue(String value)
throws SdpException
{
}
/**
@ -134,7 +135,10 @@ public class CandidateAttribute extends AttributeField
*/
public CandidateAttribute clone()
{
return null;
CandidateAttribute clone = (CandidateAttribute) super.clone();
clone.candidate = candidate;
return clone;
}
/**
@ -149,5 +153,4 @@ public class CandidateAttribute extends AttributeField
sbuff.append(getValue());
return sbuff.append(Separators.NEWLINE).toString();
}
}
}

View File

@ -92,12 +92,10 @@ public class SdpUtils
continue;
Vector<Attribute> attributes = desc.getAttributes(true);
for( Attribute attribute : attributes)
for (Attribute attribute : attributes)
{
if(!attribute.getName().equals(CandidateAttribute.NAME))
continue;
parseCandidate(attribute, stream);
if (attribute.getName().equals(CandidateAttribute.NAME))
parseCandidate(attribute, stream);
}
//set default candidates