Fix NPE in RoomInfo when subject has not value

Description

When muc#roominfo_subject contains no value then Smack will fail with a NPE.

Environment

None

Activity

Show:

Robin Collier March 29, 2011 at 12:46 AM

All three form fields accessed had the same issue and are now fixed.

Walter Ebeling March 27, 2011 at 7:16 AM

Can you take a look into it and review, if we need that for 2.6.0 RC2 or 2.6.0 final?

Walter Ebeling January 28, 2011 at 8:29 AM

According to a community report this has to reopen

http://community.igniterealtime.org/message/208940#208940

Brent Easton December 9, 2009 at 8:05 AM

This issue is not fixed, the patch does not work correctly.

This is still an issue in v3.1.0. RoomInfo ctor throws an NPE when connecting to an ejabberd server.

The code was changed from

this.subject = form.getField("muc#roominfo_subject").getValues().next();

to

Iterator<String> values = form.getField("muc#roominfo_subject").getValues();
if (values.hasNext()) {
this.subject = values.next();
}
else {
this.subject = "";
}

The correct fix is:

final FormField subjField = form.getField("muc#roominfo_subject");
this.subject = subjField == null ? "" : subjField.getValues().next();

Note that description has potentially the same problem.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created August 3, 2006 at 5:32 AM
Updated October 7, 2013 at 2:35 AM
Resolved March 29, 2011 at 12:46 AM