You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Evaluation of different Jsonata instances in the same thread causes issue #93
I've noticed strange behavior evaluating two instances of com.dashjoin.jsonata.Jsonata expressions in the same Thread - if the first expression has some bindings these bindings become part of second one. From the code snippet below, both result1 and result2 are equal to value but for result2 empty string is expected.
Issue comes from com.dashjoin.jsonata.Jsonata#getPerThreadInstance method when it calls by com.dashjoin.jsonata.Jsonata#evaluate(com.dashjoin.jsonata.Parser.Symbol, java.lang.Object, com.dashjoin.jsonata.Jsonata.Frame)
Since ThreadLocal<Jsonata> current updates every time when you call jsonata(expression) for jsonata1.evaluate("", environment) it holds instance of jsonata2 and overrides its environment (line #140)
It's better to remove thread local variable from here, mark this class as not thread safe and let developers create new instances of Jsonata for different threads.
Activity
sergeevik commentedon Feb 26, 2026
same as
#90
in my local version i fix it:
fix: extract mutable evaluation state into EvalContext (fixes dashjoi…
fix: extract mutable evaluation state into EvalContext (fixes dashjoi…
matanzwix commentedon Mar 28, 2026
#103 should fix this
Merge pull request #103 from matanzwix/fix/thread-safety-eval-context