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
Bug59945_DefaultGroovyEngineToJSR223ElementsV2 #223
Bug59945_DefaultGroovyEngineToJSR223ElementsV2 #223
Conversation
Hi, If the script language has not been chosen on the GUI, I propose to add a WARN message into the log to inform that the script will be interpreted as a groovy script It's avoid message like "ERROR - jmeter.protocol.java.sampler.JSR223Sampler: Problem in JSR223 script Echantillon JSR223, message:javax.script.ScriptException: Cannot find engine named: '', ensure you set language field in JSR223 Test Element:Echantillon JSR223" and allow to execute the script Antonio
@@ -36,6 +36,8 @@ | |||
private String script = ""; // script (if file not provided) | |||
|
|||
protected String scriptLanguage = ""; // BSF/JSR223 language to use | |||
|
|||
protected String defaultScriptLanguage = "groovy"; // if no language is chosen in GUI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be final static
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
Do you think a test should be added to cover the change? |
if (lang.isEmpty()) { | ||
lang = defaultScriptLanguage; | ||
log.warn("Script language has not been chosen on the UI, the script will be interpreted as a groovy script"); | ||
} | ||
|
||
ScriptEngine scriptEngine = getInstance().getEngineByName(lang); | ||
if (scriptEngine == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scriptEngine will be never null if groovy become the default language. This (if and exception below) must be changes.
Perhaps put here the test (if lang is undefine then log warn "interpret as groovy script")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Milamber,
I have keep the exception because I am not sure that getInstance().getEngineByName("groovy") will always return something.
For example if the groovy jar are missing
Antonio
The manual must be updated too for indicate this new behavior (if no language, then groovy script) |
Hi, New patch with better warn message and changes.xml I am waiting your advices for a better patch Antonio |
Seems better. Fon't forget to update the docs (manual) |
-1 for logging a warning on each sampler execution. |
Hi vladimir, Can you give me more details to avoid logging a warning on each sampler execution? Thanks |
@@ -36,6 +36,8 @@ | |||
private String script = ""; // script (if file not provided) | |||
|
|||
protected String scriptLanguage = ""; // BSF/JSR223 language to use | |||
|
|||
protected final static String defaultScriptLanguage = "groovy"; // if no language is chosen in GUI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final static should be written in capital letters
For instance, a boolean flag that is cleared after the fist warning is printed. |
Hello,
`if (StringUtils.isEmpty(lang)) {
` Regards |
Hi ubikloadpack, Your solution seem good I will implement it |
It's don't work :-(
|
Hello, Thanks |
Hi all, I have check in JMeter source code if this "problem" (take a default solution if nothing is setted in GUI) and I have find "CSS/JQuery Extractor" element If you check the documentation (https://jmeter.apache.org/usermanual/component_reference.html#CSS/JQuery_Extractor), we can read "If selector is set to empty, default implementation(JSoup) will be used" I have check the source code and make a test and when selector is set to empty, there is no log written. I propose to make the same thing to this PR (remove log to avoid performance problem + have a clear documentation) Are you ok? Antonio |
+1 Technically speaking, I would prefer to set the language to "groovy" if it was not specified. That would make the UI clear (user will see what the language is), and that would setup proper syntax highlight mode (much easier to program). |
OK for me too. |
PR commited |
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1762082 13f79535-47bb-0310-9956-ffa450edef68
Hi,
If the script language has not been chosen on the GUI, I propose to add
a WARN message into the log to inform that the script will be
interpreted as a groovy script
It's avoid message like "ERROR -
jmeter.protocol.java.sampler.JSR223Sampler: Problem in JSR223 script
Echantillon JSR223, message:javax.script.ScriptException: Cannot find
engine named: '', ensure you set language field in JSR223 Test
Element:Echantillon JSR223" and allow to execute the script
Antonio