Null Pointer Exception in JingleManager

While parsing above jingle stanza in JingleManger, null pointer exception being thrown in following function at jin.getAction()

private void initJingleSessionRequestListeners() {

StanzaFilter initRequestFilter = new StanzaFilter() {

// Return true if we accept this packet

public boolean accept(Stanza pin) {

if (pin instanceof IQ) {

IQ iq = (IQ) pin;

if (iq.getType().equals(IQ.Type.set)) {

if (iq instanceof Jingle) {

Jingle jin = (Jingle) pin;

if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) {

return true;

}

}

}

}

return false;

}

};

jingleSessionRequestListeners = new ArrayList();

// Start a packet listener for session initiation requests

connection.addAsyncStanzaListener(new StanzaListener() {

public void processPacket(Stanza packet) {

triggerSessionRequested((Jingle) packet);

}

}, initRequestFilter);

}

According to XEP-166 the action attribute is required (see section 7 and schema).

@Flow- Jingle packet is received correctly and action was not empty in XML stanza, but while parsing to Jingle object action is null.

Also, action should be “session-initiate” instead of “SESSION_INITIATE”, right?

Right. Smack “MUST” also return a bad-request in this case, as per XEP-166 § 7.2.

I think In following function of Jingle class

protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {

if (getInitiator() != null) {

buf.append(" initiator="").append(getInitiator()).append(’"’);

}

if (getResponder() != null) {

buf.append(" responder="").append(getResponder()).append(’"’);

}

if (getAction() != null) {

buf.append(" action="").append(getAction().name()).append(’"’);

}

if (getSid() != null) {

buf.append(" sid="").append(getSid()).append(’"’);

}

buf.append(’>’);

synchronized (contents) {

for (JingleContent content : contents) {

buf.append(content.toXML());

}

}

// and the same for audio jmf info

if (contentInfo != null) {

buf.append(contentInfo.toXML());

}

return buf;

}

Instead of buf.append(" action="").append(getAction().name()).append(’"’), it should be buf.append(" action="").append(getAction().toString()).append(’"’).

Excellent point. I widen this to all IQ requests. SMACK-699.

1 Like

Ahh, I missed that the action attribute was set. Yes, it has the wrong value.

That alone is not sufficient. You also have to replace the underscore. There is a common idiom for value enums that does this.

@Flow- Also, It seems that candidate details are not being added during session-initiate request as per the xep-0166. It is being added in transport-info stanza packet.

as Vijay says, on the first iq there’s no candidate details…looking up the code, the problems seems to be on the method startOutgoing() from the class JingleSession…debugging TransportNegotiator class logs “No Remote Candidate” on method getBestRemoteCandidate…

Trying to make a workaround about this issue I add this line on the startOutgoing() method:

resolver = transportManager.getResolver(this);

//MINE

if(resolver.getCandidateCount()==0) {

resolver.resolve(this);

}

it add a null candidate…it didnt solve the problem