Getting timeout when trying to retrieve privacy list of user

I have tested this with Smack 4.3.1 and HEAD version of Openfire repo and (3.9.1).

Getting time out while trying to get defaut or active privacy list.

Please notice that there is list of lists sysouted and it is empty - so getting default or active list causing timeout. Shouldnt it cause item-not-found or at least return NULL?

public static void main(String[] args) throws SmackException, IOException, XMPPException {         Builder b = XMPPTCPConnectionConfiguration.builder()
                .setHost("localhost")
                .setServiceName("sebollsonpc")
                .setSendPresence(true)
                .setDebuggerEnabled(true)
                .setSecurityMode(SecurityMode.disabled);
        System.out.println(SmackConfiguration.getVersion());
        SmackConfiguration.DEBUG=true;
        XMPPTCPConnection conn = new XMPPTCPConnection(b.build());         conn.connect();
        assert conn.isConnected();
                        AccountManager.getInstance(conn).createAccount("seb", "pw");
        conn.login("seb","pw");
        assert conn.isAuthenticated();
                PrivacyListManager privMan = PrivacyListManager.getInstanceFor(conn);
        assert privMan.isSupported();
        System.out.println("Active:"+privMan.getActiveListName());
        System.out.println("Default:"+privMan.getDefaultListName());
        System.out.println("Lists:"+privMan.getPrivacyLists());
                        privMan.getDefaultList(); // error
                AccountManager.getInstance(conn).deleteAccount();

And this is complete console output. Timeout is in line 29 (of pasted code)

4.1.3 (4.1.3 2015-07-15)
12:56:37 AM SENT (0): <stream:stream xmlns='jabber:client' to='sebollsonpc' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
12:56:37 AM RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="sebollsonpc" id="b2d66f18" xml:lang="en" version="1.0"><stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>CRAM-MD5</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/></stream:features>
12:56:37 AM SENT (0): <iq to='sebollsonpc' id='lL5mS-3' type='get'><query xmlns='jabber:iq:register'></query></iq>
12:56:37 AM RECV (0): <iq type="result" id="lL5mS-3" from="sebollsonpc"><query xmlns="jabber:iq:register"><username/><password/><email/><name/><x xmlns="jabber:x:data" type="form"><title>XMPP Client Registration</title><instructions>Please provide the following information</instructions><field var="FORM_TYPE" type="hidden"><value>jabber:iq:register</value></field><field var="username" type="text-single" label="Username"><required/></field><field var="name" type="text-single" label="Full name"/><field var="email" type="text-single" label="Email"/><field var="password" type="text-private" label="Password"><required/></field></x></query></iq>
wrz 04, 2015 12:56:37 AM org.jivesoftware.smackx.iqregister.AccountManager createAccount
WARNING: Creating account over insecure connection. This will throw an exception in future versions of Smack if AccountManager.sensitiveOperationOverInsecureConnection(true) is not set
12:56:37 AM SENT (0): <iq to='sebollsonpc' id='lL5mS-5' type='set'><query xmlns='jabber:iq:register'><password>pw</password><name></name><email></email><username>seb</username></query></iq>
12:56:37 AM RECV (0): <iq type="result" id="lL5mS-5" from="sebollsonpc" to="sebollsonpc/b2d66f18"/>
12:56:37 AM SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='SCRAM-SHA-1'>biwsbj1zZWIscj14akVsajZieChlJjVPX2N2QCFyeG0ySEpZSy5dKStLcw==</auth>
12:56:37 AM RECV (0): <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cj14akVsajZieChlJjVPX2N2QCFyeG0ySEpZSy5dKStLczkyNDJhYjA0LTJmYTctNGI5MC1hODhkLWExNTEzNTFiZjJmNixzPW52eWlMRXJiVUVzdG1aMEtqY25aeStJT3ExQXlFMjFQQmVDS3U0aGxqUmc9LGk9NDA5Ng==</challenge>
12:56:38 AM SENT (0): <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>Yz1iaXdzLHI9eGpFbGo2YngoZSY1T19jdkAhcnhtMkhKWUsuXSkrS3M5MjQyYWIwNC0yZmE3LTRiOTAtYTg4ZC1hMTUxMzUxYmYyZjYscD1oUDh0UUtLZHRRZksvbTFZYnJIcFNsL2dwVnc9</response>
12:56:38 AM RECV (0): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dj15OFp0emp0YzZXREpQcHJCNjgyekoyRjdTc1E9</success>
12:56:38 AM SENT (0): <stream:stream xmlns='jabber:client' to='sebollsonpc' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' id='b2d66f18' xml:lang='en'>
12:56:38 AM RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="sebollsonpc" id="b2d66f18" xml:lang="en" version="1.0"><stream:features><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"><optional/></session><sm xmlns='urn:xmpp:sm:2'/><sm xmlns='urn:xmpp:sm:3'/></stream:features>
12:56:38 AM SENT (0): <iq id='lL5mS-7' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>Smack</resource></bind></iq>
12:56:38 AM RECV (0): <iq type="result" id="lL5mS-7" to="sebollsonpc/b2d66f18"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>seb@sebollsonpc/Smack</jid></bind></iq>
12:56:38 AM User logged (0): seb@sebollsonpc:5222/Smack
12:56:38 AM XMPPConnection authenticated (0)
12:56:38 AM SENT (0): <iq id='lL5mS-9' type='get'><query xmlns='jabber:iq:roster'></query></iq>
12:56:38 AM RECV (0): <iq type="result" id="lL5mS-9" to="seb@sebollsonpc/Smack"><query xmlns="jabber:iq:roster"/></iq>
12:56:38 AM SENT (0): <presence id='lL5mS-10'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>
12:56:38 AM SENT (0): <iq id='lL5mS-11' type='get'><query xmlns='jabber:iq:privacy'></query></iq>
12:56:38 AM RECV (0): <presence id="lL5mS-10" from="seb@sebollsonpc/Smack" to="seb@sebollsonpc/Smack"><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.igniterealtime.org/projects/smack" ver="NfJ3flI83zSdUDzCEICtbypursw="/></presence>
12:56:38 AM RECV (0): <iq type="result" id="lL5mS-11" to="seb@sebollsonpc/Smack"><query xmlns="jabber:iq:privacy"/></iq>
Active:null
12:56:38 AM SENT (0): <iq id='lL5mS-15' type='get'><query xmlns='jabber:iq:privacy'></query></iq>
12:56:38 AM RECV (0): <iq type="result" id="lL5mS-15" to="seb@sebollsonpc/Smack"><query xmlns="jabber:iq:privacy"/></iq>
Default:null
12:56:38 AM SENT (0): <iq id='lL5mS-17' type='get'><query xmlns='jabber:iq:privacy'></query></iq>
12:56:38 AM RECV (0): <iq type="result" id="lL5mS-17" to="seb@sebollsonpc/Smack"><query xmlns="jabber:iq:privacy"/></iq>
Lists:[]
12:56:38 AM SENT (0): <iq id='lL5mS-19' type='get'><query xmlns='jabber:iq:privacy'></query></iq>
12:56:38 AM RECV (0): <iq type="result" id="lL5mS-19" to="seb@sebollsonpc/Smack"><query xmlns="jabber:iq:privacy"/></iq>
Exception in thread "main" org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=lL5mS-21)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (bare): seb@sebollsonpc, FromMatchesFilter (full): sebollsonpc)).
     at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:106)
     at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:90)
     at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:229)
     at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
     at org.jivesoftware.smackx.privacy.PrivacyListManager.getRequest(PrivacyListManager.java:232)
     at org.jivesoftware.smackx.privacy.PrivacyListManager.getPrivacyListItems(PrivacyListManager.java:367)
     at org.jivesoftware.smackx.privacy.PrivacyListManager.getDefaultList(PrivacyListManager.java:312)
     at tests.PrivacyListTest.main(PrivacyListTest.java:49)
wrz 04, 2015 12:56:43 AM org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter shutdown
WARNING: shutdownDone was not marked as successful by the writer thread
org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: No filter used or filter was 'null'.
     at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:106)
     at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:85)
     at org.jivesoftware.smack.SynchronizationPoint.checkForResponse(SynchronizationPoint.java:253)
     at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWait(SynchronizationPoint.java:146)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.shutdown(XMPPTCPConnection.java:1269)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection.shutdown(XMPPTCPConnection.java:494)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection.instantShutdown(XMPPTCPConnection.java:483)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection.notifyConnectionError(XMPPTCPConnection.java:863)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$2700(XMPPTCPConnection.java:139)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.writePackets(XMPPTCPConnection.java:1419)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$2800(XMPPTCPConnection.java:1170)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1218)
     at java.lang.Thread.run(Unknown Source) wrz 04, 2015 12:56:43 AM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener
WARNING: Connection closed with error
java.lang.NullPointerException
     at org.jivesoftware.smack.util.LazyStringBuilder.length(LazyStringBuilder.java:72)
     at org.jivesoftware.smack.util.LazyStringBuilder.toString(LazyStringBuilder.java:100)
     at org.jivesoftware.smack.util.XmlStringBuilder.toString(XmlStringBuilder.java:344)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.writePackets(XMPPTCPConnection.java:1368)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$2800(XMPPTCPConnection.java:1170)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1218)
     at java.lang.Thread.run(Unknown Source) 12:56:43 AM XMPPConnection closed due to an exception (0)
java.lang.NullPointerException
     at org.jivesoftware.smack.util.LazyStringBuilder.length(LazyStringBuilder.java:72)
     at org.jivesoftware.smack.util.LazyStringBuilder.toString(LazyStringBuilder.java:100)
     at org.jivesoftware.smack.util.XmlStringBuilder.toString(XmlStringBuilder.java:344)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.writePackets(XMPPTCPConnection.java:1368)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$2800(XMPPTCPConnection.java:1170)
     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1218)
     at java.lang.Thread.run(Unknown Source)

Could you run the very same code with assertions enabled and show us the result? This will help use determine the cause for the NPE in LazyStringBuilder.

I’ve uploaded 4.1.4-SNAPSHOT which includes Handle cases where no privacy lists are set. · Flowdalic/Smack@aa832ec · GitHub

Could you try and report back if it works for you? The test run with assertions enabled would still be helpful though, just to confirm that what I inferred to be the cause is the actual cause.

Ok I will try that as soon as I’ll get home and try that on given snapshot (as I understand, is is maven-available right?). Also I need to mention that Android Smack has the same issue, but different exception is thrown in packet reader thread.

Also I need to mention that Android Smack has the same issue, but different exception is thrown in packet reader thread.
The code should be identical (if you use the same version of course). Which exception is thrown instead (also full stacktrace pls)?

Okay in general i is working with provided version. However i feel that something is wrong as right now responses are inconsistent. If we query for nonexisting list we will get non-exisiting xmpp error. But when querying for default or active we got null. I would feel right if I would get item-not-found if query for eg active list - whitch is not found indeed.

I will check this situation on android but as I can recall it was something about “unparsedstanza error”. Error occured in packed reader and was complaining something about missing item element (or malformed). Ill check that on monday.

Here is new piece of console output - this time it is aSMACK

these 2 calls gives us the following output:

System.out.println(privacyManager.getDefaultList());
System.out.println(privacyManager.getActiveList());

D/SMACK: SENT (0): <iq id='rQ3R0-15' type='get'><query xmlns='jabber:iq:privacy'></query></iq>
D/SMACK: RECV (0): <iq type="result" id="rQ3R0-15" to="mike@sebollsonpc/Smack"><query xmlns="jabber:iq:privacy"><default name="default"/><list name="default"/></query></iq>
D/SMACK: SENT (0): <iq id='rQ3R0-17' type='get'><query xmlns='jabber:iq:privacy'><list name="default"/></query></iq>
D/SMACK: RECV (0): <iq type="result" id="rQ3R0-17" to="mike@sebollsonpc/Smack"><query xmlns="jabber:iq:privacy"><list name="default"><item action="allow" order="0"><iq/></item></list></query></iq>
Privacy List: default(active:false, default:true)
D/SMACK: SENT (0): <iq id='rQ3R0-19' type='get'><query xmlns='jabber:iq:privacy'></query></iq>
D/SMACK: RECV (0): <iq type="result" id="rQ3R0-19" to="mike@sebollsonpc/Smack"><query xmlns="jabber:iq:privacy"><default name="default"/><list name="default"/></query></iq>
Exception in thread "Smack Packet Writer (0)" java.lang.AssertionError
    at org.jivesoftware.smack.util.XmlStringBuilder.escape(XmlStringBuilder.java:242)
    at org.jivesoftware.smackx.privacy.packet.Privacy.getIQChildElementBuilder(Privacy.java:313)
    at org.jivesoftware.smack.packet.IQ.getChildElementXML(IQ.java:146)
    at org.jivesoftware.smack.packet.IQ.toXML(IQ.java:127)
    at org.jivesoftware.smack.packet.IQ.toXML(IQ.java:42)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.writePackets(XMPPTCPConnection.java:1368)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$2800(XMPPTCPConnection.java:1170)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1218)
    at java.lang.Thread.run(Thread.java:745)