Data corruption with Nashorn + Handlebars and concurrent requests

Sebastien Deleuze sdeleuze at pivotal.io
Wed Jul 15 17:02:40 UTC 2015


Hi,

We ended up to use thread-local script engines [1] in Spring 4.2 for
Javascript libraries not designed for concurrency like React or Handlebars.
Based on my initial tests, it works pretty well. The main remaining open
question is about the memory consumption, since it creates one ScriptEngine
instance by thread.
If we see some blocking issues regarding this topic, we may eventually
experiment with a synchronized ScriptEngine pool, but I hope the
thread-local approach will be fine.

Regards,
Sébastien Deleuze

[1] https://jira.spring.io/browse/SPR-13034

On Fri, Jun 5, 2015 at 5:08 PM, Matt Kime <mattk at meetup.com> wrote:

> I'm curious if any progress has been made on isolating whatever isn't
> thread safe about handlebars template execution.
>
> I'm also working on using Handlebars.js inside nashorn however i'm doing a
> number of things different. i'm precompiling my templates using
> https://github.com/gruntjs/grunt-contrib-handlebars and then compile the
> js
> functions into cached bytecode.
>
> I haven't checked for threading issues yet but I'm glad i found this
> discussion so i know that i should.
>


More information about the nashorn-dev mailing list