New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider Nashorn ScriptEngine instance scope in ScriptTemplateView [SPR-13487] #18065
Comments
Sébastien Deleuze commented Currently |
chanwook park commented I'am afraid that Nashorn is not Thread-safe. So we can not enroll plain Spring beans and share with views. For managing ScriptEngine instance number, could we consider like that (1) pooling ScriptEngine like JDBC ConnectionPool. |
Sébastien Deleuze commented Yes we are already aware of that. Just updating the |
chanwook park commented Yes. you are correct. |
Sébastien Deleuze commented chanwook park Issue fixed by making this field |
Juergen Hoeller commented Hmm, what about different script engines in use? E.g. one Admittedly, this is not a common scenario, so I guess we could simply verify that the Juergen |
Juergen Hoeller commented I'm currently tackling the related #18069, so I can have a look at such an engine validation check as well... Juergen |
Sébastien Deleuze commented Juergen Hoeller Indeed, this is not common but it could occur, thanks for raising this. Another option could be to create a Do you think that make sense or since this is a not common scenario it's not worth to go on that way? |
Sébastien Deleuze commented Reopening this issue after latest Juergen Hoeller feedback. |
chanwook park commented thanks comment Juergen and Sébastien. I've been more test and some understanding for that. I means that below...
By the way, if no concurrency issue, My first and second question is resolved by ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
configurer.setEngine(engine); If no concurrency issue, this code is enough for that. right? Finally when we don't use thanks your working and comments. |
chanwook park commented I'm read in 4.2.2-BUILD-SNAPSHOT guide is already added for concurrency description.(y) |
Juergen Hoeller commented In the course of #18069, I've changed the This allows for configuration-specific Juergen |
chanwook park commented Wow! Real good deal with that. Regards, |
chanwook park opened SPR-13487 and commented
Spring MVC mechanism is create one instance for View (View = URL).
And ScriptViewTemplate has one Nashorn's ScriptEngine (SpringTemplateView#engine), or more ScriptEngine instances because using ThreadLocal (ScriptTemplateView#engineHolder).
For example, app has 1000 view(URL), then create 1000 ScriptTemplateView instance and at the same time create 1000 Nashorn’s ScriptEngine instance(or more +). And one ScriptEngine is loaded only one template HTML.
In my case, I have been used like that caused memory consumption. (I've been used JDK6+Rhino+Dust)
I hope to more careful managing view instance and Nashorn's ScriptEngine instance.
Maybe not consider share and DI to SpringEngine instance?
Of course, aspect of concurrency and resource management.
Thanks.
Affects: 4.2.2
Issue Links:
Referenced from: commits c7fd4cc, cffad9d
The text was updated successfully, but these errors were encountered: