]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added a comment that hopefully explains the NULL_OBJECT #12509
authorJonatan Kronqvist <jonatan@vaadin.com>
Mon, 9 Sep 2013 11:14:49 +0000 (14:14 +0300)
committerJonatan Kronqvist <jonatan@vaadin.com>
Mon, 9 Sep 2013 11:14:49 +0000 (14:14 +0300)
Change-Id: I99ea86d8842324884dda3a5c392f37e8d4a7acf6

server/src/com/vaadin/util/CurrentInstance.java

index 39c2a60a5c8c7da07a55c4bd4e4ef3a1a59c328d..4c62ef49be944d33a8be47bd90cb1c6fff9c6611 100644 (file)
@@ -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);