XMPPConnection.getUser() somtimes return NULL

Hello All,

I was heaving a probelm in getting the User ID of the user from XMPPConnection object.

When i get the UserID using getUser() then it sometimes return NULL.

The method getUser(), i have used in my PacketListener.

xmppCon.addPacketListener(new PacketListener()


public void processPacket(Packet pack) {

String strLoginId=xmppCon.getUser();



}, null);

sometimes this print null.

Anybody can replicate this issue with frequently doing login.

I have solve this bug By making the XMPPConnection.isAuthenticated() method as a synchronized method in smack source.

I want this issue to be solved by the jive people, so that it can be resolved in next build. OR If there are no changes required then let me know.



Message was edited by: jchittoda

Sample code

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.PacketListener;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.packet.Packet;

public class BugTest {

private static XMPPConnection con = null;

public static void main(String[] args)throws Exception {

ConnectionConfiguration cc = new ConnectionConfiguration(“localhost”,5222);


con = new XMPPConnection(cc);

con.addPacketListener(new PacketListener(){

public void processPacket(Packet pack) {

String user = con.getUser();

System.out.println("Paket : "+pack.toXML() );

System.out.println("UserName: "+ user);








I want to make sure that this is a bug or not ?

So please answer this question…

Waiting for reply.