powered by Jive Software

XMPPConnection crashing with NullpointerException

From what I’ve found through google, and through my own usage of Smack,

for some time XMPPConnections login method (using username and password)

results in a NullpointerException, when Smack is used to connect to other servers but Openfire.

This is what the Stacktrace looks like:

java.lang.NullPointerException     at org.jivesoftware.smack.util.Base64.encodeBytes(Base64.java:638)     at org.jivesoftware.smack.sasl.SASLMechanism.challengeReceived(SASLMechanism.java:152)     at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication.java:492)     at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:338)     at org.jivesoftware.smack.PacketReader.access$0(PacketReader.java:266)     at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

From what I could figure out, the point is, that Base64.encodeBytes needs a byte[] passed,

but gets null from SASLMechanism.challengeReceived.

This Problem is easily fixed by adding the following small check into line 634 org.jivesoftware.smack.util.Base64.encodeBytes(byte[] source, int options) :

public static String encodeBytes( byte[] source, int options )
         if(source == null)
              source = new byte[0];
        return encodeBytes( source, 0, source.length, options );
    }   // end encodeBytes

I was just wondering if there is a particular reason for this issue being open for some time now,

and how or if I can help fixing it; For I believe it bothers some people.

Thanks for your time