From 0d79a84494b21a3b553d56245c4a1ee09fb022b4 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Mon, 9 Sep 2013 14:14:49 +0300 Subject: [PATCH] Added a comment that hopefully explains the NULL_OBJECT #12509 Change-Id: I99ea86d8842324884dda3a5c392f37e8d4a7acf6 --- server/src/com/vaadin/util/CurrentInstance.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/src/com/vaadin/util/CurrentInstance.java b/server/src/com/vaadin/util/CurrentInstance.java index 39c2a60a5c..4c62ef49be 100644 --- a/server/src/com/vaadin/util/CurrentInstance.java +++ b/server/src/com/vaadin/util/CurrentInstance.java @@ -237,6 +237,22 @@ public class CurrentInstance implements Serializable { if (v == null) { removeStale = true; } else if (v == NULL_OBJECT) { + /* + * NULL_OBJECT is used to identify objects that are null when + * #setCurrent(UI) or #setCurrent(VaadinSession) are called on a + * CurrentInstance. Without this a reference to an already + * collected instance may be left in the CurrentInstance when it + * really should be restored to null. + * + * One example case that this fixes: + * VaadinService.runPendingAccessTasks() clears all current + * instances and then sets everything but the UI. This makes + * UI.accessSynchronously() save these values before calling + * setCurrent(UI), which stores UI=null in the map it returns. + * This map will be restored after UI.accessSync(), which, + * unless it respects null values, will just leave the wrong UI + * instance registered. + */ set(c, null, ci.inheritable); } else { set(c, v, ci.inheritable); -- 2.39.5