Bug 62082 - __groovy function seems to have useless synchronized in execute
Summary: __groovy function seems to have useless synchronized in execute
Status: NEW
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 3.3
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-06 20:09 UTC by Philippe Mouawad
Modified: 2018-03-11 20:10 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2018-02-06 20:09:07 UTC
Following same analysis of Bug 57114 and as per understanding of this:

- https://stackoverflow.com/questions/48644849/is-groovy-scriptingengine-thread-safe

Groovy ScriptEngine "THREADING" is equal to MULTITHREADED:
- https://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngineFactory.html#getParameter-java.lang.String-

It seems we could avoid the synchronized block.

Thoughts ?
Thanks
Comment 1 Vladimir Sitnikov 2018-02-06 20:32:53 UTC
It does look like the synchronization there is not needed.
Comment 2 Philippe Mouawad 2018-02-06 20:41:44 UTC
(In reply to Vladimir Sitnikov from comment #1)
> It does look like the synchronization there is not needed.

Hi Vladimir,
Would you say that this answer is correct :

- https://stackoverflow.com/q/48648931/460802

IMO, it is.
If we remove the synchronization, my understanding is that:
- there is a risk if Groovy script uses global variables, there is no reason to do that
- I am not sure about the risk on GroovyClassLoader. I don't think there is as per what is described here:
 http://docs.groovy-lang.org/latest/html/documentation/guide-integrating.html#groovyclassloader


Is my understanding correct ?
Thanks
Comment 3 Vladimir Sitnikov 2018-03-10 19:54:50 UTC
>- https://stackoverflow.com/q/48648931/460802

The link seems to not related to Groovy.

>- there is a risk if Groovy script uses global variables, there is no reason to do that

I agree, there's a little reason to do that. We might want to document how to avoid global variables.

>- I am not sure about the risk on GroovyClassLoader. I don't think there is as per what is described here:

As far as I can understand, it means "use of Apache JMeter string interpolation inside Groovy scripts would result in OutOfMemoryError". In other words, the best practice is to keep script string constant and pass all the params via parameters and/or Apache JMeter variables.
Comment 4 Philippe Mouawad 2018-03-11 20:10:50 UTC
The correct link is:

https://stackoverflow.com/questions/48644849/is-groovy-scriptingengine-thread-safe