powered by Jive Software

Type-o in Packet.getError()

been doing some development with the org.xmpp.packet stuff and noticed that Packet.setError and Packet.getError do not work consistant.

the setError() adds an xml fragment to the packet root element and the getError() returns a new instance of PacketError based on the “root” element and not the error element.

so i think

public PacketError getError() {

Element error = element.element(“error”);

if (error != null) {

return new PacketError(element);

}

return null;

}

should be

public PacketError getError() {

Element error = element.element(“error”);

if (error != null) {

return new PacketError(error);

}

return null;

}

anyway, testcase that fails:

import junit.framework.TestCase;

import org.xmpp.packet.Presence;

import org.xmpp.packet.PacketError;

public class TestError extends TestCase {

public void testCondition() {

Presence presence = new Presence(Presence.Type.error);

PacketError.Condition condition = PacketError.Condition.jid_malformed;

PacketError packetError = new PacketError(condition);

presence.setError(packetError);

System.err.println(presence);

PacketError readError = presence.getError();

PacketError.Condition readCondition = readError.getCondition();

assertEquals(readError, packetError);

assertEquals(condition , readCondition);

}

}

Thanks for the bug report! I entered the issue as JM-372 and am checking in a fix now.

-Matt