Projects tigase _server server-core Issues #309
Packet.toString() returns wrong result (#309)
Won't Fix
wojciech.kapcia@tigase.net opened 1 decade ago

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

Artur Hefczyc commented 1 decade ago

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.

Referenced from commit 11 months ago
issue 1 of 1
Type
Bug
Priority
Normal
Assignee
RedmineID
1895
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#309
Please wait...
Page is in error, reload to recover