Roster.setRosterLoadedAtLogin(false) doesn't work

Hi all,

I want to remove roster processing from my client as I do not need a roster. I tried setting Roster.setRosterLoadedAtLogin(false) but this is not taken into account, I still have the roster being processed. Other than me not needing the roster, it has a bug that causes a NPE. It receives an XMPP error stanza (feature-not-implemented - cancel) that has no “from”, this causes an exception when XmppStringUtils.parsePrsource(from) on line 1280 (v4.1.3) because “from” is null. I upgraded from 4.0.x and my code worked fine before (Server is Tigase 7.x) BTW.

I then though that since Roster.setRosterLoadedAtLogin(false) does not work, I could remove the listeners, but I cannot since I have no accessible references to them…

So basically:

  1. I want to no longer have any roster managment
  2. You should fix the NPE described above

Thank you,

Gabriel

Just to add some info, I have the roster and presence deactivated on the server so this is really just a client issue.

Please show the full stacktrace of the NPE, as otherwise it’s hard to tell which method is invoking parseResource().

I still have the roster being processed.
Could you elaborate on that? I assume you call setRosterLoadedAtLogin before login()?

Yes, of course before the login…

Here is the order:

xmppConnection = new XMPPTCPConnection(configBuilder.build());

roster = Roster.getInstanceFor(xmppConnection);

roster.setRosterLoadedAtLogin(false);

xmppConnection.connect();

xmppConnection.login(username, password, resource);

I setup the server to not manage presence nor roseters (I disabled the plugins), when I had 4.0.x it worked as expected (or at lease I didn’t realize anything was wrong since no exceptions were thrown). When I switched to 4.1 I started getting this:

sept. 04, 2015 2:05:42 PM org.jivesoftware.smack.roster.Roster$PresencePacketListener processPacket

WARNING: Roster not loaded while processing presence stanza

sept. 04, 2015 2:05:42 PM org.jivesoftware.smack.AbstractXMPPConnection$4 run

SEVERE: Exception in packet listener

java.lang.NullPointerException

at org.jxmpp.util.XmppStringUtils.parseResource(XmppStringUtils.java:84)

at org.jivesoftware.smack.roster.Roster$PresencePacketListener.processPacket(Roste r.java:1280)

at org.jivesoftware.smack.AbstractXMPPConnection$4.run(AbstractXMPPConnection.java :1131)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:744)

I would expect it not to request/parse the presence/roster msgs if it is disabled and to just ignore them if any are recieved (in this case itseems like it sent a request and got a reply).

Here is the presence msg it is having an issue with, it is an error reply since the server has it disabled:

Feature not supported yet.

Thanks

sept. 04, 2015 2:05:42 PM org.jivesoftware.smack.roster.Roster$PresencePacketListener processPacket

WARNING: Roster not loaded while processing presence stanza

Ignore that for now. I’ll omit the warning in 4.1.4 if the roster is not loaded on login.

sept. 04, 2015 2:05:42 PM org.jivesoftware.smack.AbstractXMPPConnection$4 run

SEVERE: Exception in packet listener

java.lang.NullPointerException

at org.jxmpp.util.XmppStringUtils.parseResource(XmppStringUtils.java:84)

at org.jivesoftware.smack.roster.Roster$PresencePacketListener.processPacket(Roste r.java:1280)

That’s fixed with SMACK-687, please try 4.1.4-SNAPSHOT.

Here is the presence msg it is having an issue with, it is an error reply since the server has it disabled.

Sending the initial presence is unrelated to the roster being loaded or not. You likely want to set ConnectionConfiguration.Builder (Smack 4.1.3 API) to false.

Ok, thanks. Where can I get it? Do I just grap a nightly build (such as smack-SNAPSHOT-2015-08-20.zip)?

Smack snapshosts artifacts are available on the Maven Central (OSS Sonatype) snapshot repository.

Thanks, all good.