RoomInfo(DiscoverInfo info) {
super();
this.room = info.getFrom();
// Get the information based on the discovered features
this.membersOnly = info.containsFeature(“muc_membersonly”);
this.moderated = info.containsFeature(“muc_moderated”);
this.nonanonymous = info.containsFeature(“muc_nonanonymous”);
this.passwordProtected = info.containsFeature(“muc_passwordprotected”);
this.persistent = info.containsFeature(“muc_persistent”);
// Get the information based on the discovered extended information
Form form = Form.getFormFrom(info);
if (form != null) {
this.description =
form.getField(“muc#roominfo_description”).getValues().next();
Iterator values = form.getField(“muc#roominfo_subject”).getValues();
if (values.hasNext()) {
this.subject = values.next();
}
else {
this.subject = “”;
}
this.occupantsCount =
Integer.parseInt(form.getField(“muc#roominfo_occupants”).getValues()
.next());
}
}
We have been testing our Smack-based client which works fine with OF 3.6.4 against OF 3.7.0b. Something must have been modified in OF that causes NPEs. The client discovers the roomInfo without joining (see smackx/muc/RoomInfo.java). Since there is no ‘roominfo_subject’ in the disco#info reply Smack throws an exception which is what we see in the message debug.
This bug has been reported as SMACK-163 . It shows up as fixed but it is not. When looking at the code, the original comment and proposed fix still applies.
Here is where it happens:
// Get the information based on the discovered extended information
Form form = Form.getFormFrom(info);
if (form != null) {
this.description =
form.getField("muc#roominfo_description").getValues().next();
Iterator<String> values = form.getField("muc#roominfo_subject").getValues();
if (values.hasNext()) { this.subject = values.next();
}
else {
this.subject = "";
}
this.occupantsCount =
Integer.parseInt(form.getField("muc#roominfo_occupants").getValues()
.next());
}
The solution is described in the comments of OF 163 (see http://issues.igniterealtime.org/browse/SMACK-163) as following:
final FormField subjField = form.getField("muc#roominfo_subject"); this.subject = subjField == null ? "" : subjField.getValues().next();
PS: I have just noticed, that this has already been reported in multiple other threads (http://community.igniterealtime.org/message/192428#192428 , http://community.igniterealtime.org/message/198667#198667 …)
The OF bug must be in the XEP-128 support of OF http://xmpp.org/extensions/xep-0128.html
In the IQ response below I find a malformed XML which is the problem:
<field label="Number of occupants" var="muc#roominfo_occupants" > <value>test</value> <value>0</value> </field> <field/>
I could not find anything strange in the OF code:
<iq from="test@conference.localhost" type="result" id="aac9a" to="admin@localhost/Michael-Laukners-MacBook-Pro" >
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="conference" type="text" name="test" />
<feature var="http://jabber.org/protocol/muc" />
<feature var="muc_public" />
<feature var="muc_open" />
<feature var="muc_unmoderated" />
<feature var="muc_semianonymous" />
<feature var="muc_unsecured" />
<feature var="muc_persistent" />
<feature var="http://jabber.org/protocol/disco#info" />
<x xmlns="jabber:x:data" type="result" >
<field type="hidden" var="FORM_TYPE" > <value>http://jabber.org/protocol/muc#roominfo</value>
</field>
<field label="Description" var="muc#roominfo_description" > <value>test</value>
</field>
<field label="Number of occupants" var="muc#roominfo_occupants" > <value>test</value> <value>0</value> </field> <field/>
<field label="Creation date" var="x-muc#roominfo_creationdate" > <value>20101023T12:33:33</value>
</field>
</x>
</query>
</iq>