/**
 * @license
 * Copyright 2019 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.core;

public class ContextAgentRunnable
  implements Runnable
{
  final X            x_;
  final ContextAgent agent_;
  final String       description_;

  public ContextAgentRunnable(X x, ContextAgent agent, String description) {
    x_           = x;
    agent_       = agent;
    description_ = description;
  }

  public String toString() {
    return description_;
  }

  public void run() {
    XLocator.set(x_);
    try {
      agent_.execute(x_);
    } finally {
      XLocator.set(null);
    }
  }
}

@@ -524,24 +524,53 @@
 oid run() %7B%0A
+    X oldX = XLocator.get();%0A
     XLocator
@@ -654,12 +654,12 @@
 set(
-null
+oldX
 );%0A 

Fix ContextAgentRunnable nulling previously set XLocator X.