NullPointer in IQRouter.java

Hi there,

I’'ve found a lot of NullPointers in my logs (on average about 250-300 a day) pointing to IQRouter.java. The problem seems to lie in the sending of an error packet, where the child element is copied to the error packet. If the original packet does not have a child element, a nullpointer exception is thrown.

While an IQ stanza without a child element is odd (especially one that passes through IQ.createResultIQ()), it apparently does happen with some frequency. I’'d like it if the full packet XML were given on route failures.

A stacktrace is given below. The patch would be a simple check for null before attempting to call createCopy() on the childelement.

2006.11.30 14:26:35 org.jivesoftware.wildfire.IQRouter.handle(IQRouter.java:309) Could not route packet

java.lang.NullPointerException

at org.jivesoftware.wildfire.IQRouter.sendErrorPacket(IQRouter.java:327)

at org.jivesoftware.wildfire.IQRouter.handle(IQRouter.java:304)

at org.jivesoftware.wildfire.IQRouter.route(IQRouter.java:96)

at org.jivesoftware.wildfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:67)

at org.jivesoftware.wildfire.net.SocketReader.processIQ(SocketReader.java:250)

at org.jivesoftware.wildfire.net.SocketReader.process(SocketReader.java:216)

at org.jivesoftware.wildfire.net.BlockingReadingMode.readStream(BlockingReadingMod e.java:156)

at org.jivesoftware.wildfire.net.BlockingReadingMode.run(BlockingReadingMode.java: 62)