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

Acceptance Test - Entry

None

Activity

Show:
Brent Easton
December 9, 2009, 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.

Walter Ebeling
January 28, 2011, 8:29 AM

According to a community report this has to reopen

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

Walter Ebeling
March 27, 2011, 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?

Robin Collier
March 29, 2011, 12:46 AM

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

Fixed

Assignee

Robin Collier

Reporter

Gaston Dombiak

Labels

None

Expected Effort

None

Ignite Forum URL

None

Components

Fix versions

Affects versions

Priority

Major
Configure