Created
February 25, 2014 17:58
-
-
Save purplefox/9214260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Consider this sequence of events (this is what we currently do) | |
1. Construct a map M | |
2. Create a JsonObject J1 that backs the map M | |
3. Send J1 on the event bus | |
4. Vert.x calls copy() which makes a deep copy of J1, called J2 | |
5. J2 is passed to the handler in another verticle | |
6. J2 is mutated in the other verticle (e.g. setString("foo", "bar"); | |
7. That change is not visible to J1 since they do not back the same map | |
Consider this sequence of events - AIUI this is what you have suggested - move the copying of the map into the JsonObject constructor and change copy() so it just returns new JsonObject(map) | |
1. Construct a map M | |
2. Create a JsonObject J1 that backs the map M | |
3. The JsonObject J1 copies the map M, call it M2 and backs itself with that | |
4. Send J1 on the event bus | |
5. Vert.x calls copy() which this time just called new JsonObject(M2) so now J1 and J2 are backing the same map | |
6. J2 is passed to the handler in another verticle | |
7. J2 is mutated in the other verticle (e.g. setString("foo", "bar"); | |
8. This change is now visible to J1 as they are backed by the same map M2 !!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment