Subsequent calls to Packet.toString() after modification of contained Element doesn't return correct result due to string representation not being recalculated.
This is not a bug. This is intentional. In Tigase, Element and in fact Packet objects are immutable, even they are immutable by convention only but still should never be modified. Packet class has an API and several method to create a copy of Element object or a copy of the whole Packet object including Element inside with some modifications.
The main motivation behind treating Element/Packet as immutable is that Packet object may be processed concurrently by different processors/threads at the same time or semi-concurrently, that is even if not at the same exact time, the same Packet object goes through several processing phases (chain of responsibility* design pattern. Therefore modifications to the object is dangerous and may lead to unpredictable results.
Element or Packet is not immutable to technically it can be modified but special caution and consideration is required. Then, Packet.initVars() must be called to force recalculation of the String representation.
Subsequent calls to Packet.toString() after modification of contained Element doesn't return correct result due to string representation not being recalculated.
Related rev. 81987810