Why does node.getNodeConfiguration() throw an exception?

When I try to figure out what is a node configuration with the following kind of code :

ConfigureForm form = null;

try {

form = node.getNodeConfiguration();

}

catch (NoResponseException ex) {

ex.printStackTrace(); return;

}

I got that :

java.util.NoSuchElementException at java.util.ArrayList$Itr.next(ArrayList.java:834) at

org.jivesoftware.smackx.pubsub.provider.FormNodeProvider.createReturnExtension(F ormNodeProvider.java:40) at org.jivesoftware.smack.provider.EmbeddedExtensionProvider.parseExtension(Embedd edExtensionProvider.java:105) at org.jivesoftware.smack.util.PacketParserUtils.parsePacketExtension(PacketParser Utils.java:813) at org.jivesoftware.smackx.pubsub.provider.PubSubProvider.parseIQ(PubSubProvider.j ava:48) at org.jivesoftware.smack.util.PacketParserUtils.parseIQ(PacketParserUtils.java:44 0) at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:170) at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47) at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81)

org.jivesoftware.smack.SmackException$NoResponseException

Am I missing something ?

Which version are you using? There seem to be two exceptions in your provided output: NoSuchElementException and NoResponseException.

The NoSuchElementException seems to be caused by FormNodeProvider calling “new Form((DataForm)content.iterator().next()” when there is no next element.

I’m not that into the spec right now, to tell if it’s the node not being well formed or the provider making wrong assumptions.

I’m using the latest versions : smack 4.0.1, openfire 3.9.3.

My report was not well formatted. Sorry.

You are right about the exceptions : at the bottom FormNodeProvider() fails to find some kind of element which causes at the top NoResponseException to be thrown.

However it happens that this morning the error is no longer there; I’ve restarted the server just before and it fixed the problem.

Oops !

My diagnostic was wrong. Running my code as a plain user instead as an admin produces the same error and the same trace.

BTW:

Moreover running the code as an admin

List affiliations = pubSubManager.getAffiliations() also fails :

item-not-found

at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:1 82)

at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:1 61)

at org.jivesoftware.smackx.pubsub.PubSubManager.sendPubsubPacket(PubSubManager.jav a:303)

at org.jivesoftware.smackx.pubsub.PubSubManager.sendPubsubPacket(PubSubManager.jav a:298)

at org.jivesoftware.smackx.pubsub.PubSubManager.sendPubsubPacket(PubSubManager.jav a:289)

at org.jivesoftware.smackx.pubsub.PubSubManager.getAffiliations(PubSubManager.java :237)

In my opinion it can be considered normal to have methods not returning results under certain circumstances but they should return something like null or -1 or provide hints about what causes the failure. Wildly throwing not explicit exceptions makes the calling code difficult to write.

One more error handling problem:

Method pubSubManager.discoverNodes(null) fails and throws internal-server-error

at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:1 82)

when there is no root node. It should return null or throw NotSuchElementException.

Please report such suggestions in a new thread. Thank you.