Download [#ESBJAVA-3019] Script Mediator

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
[ESBJAVA-3019] Script Mediator - Blank spaces and Decimal points
representation issues Created: 24/Feb/14 Updated: 26/Jan/15 Resolved: 08/Jan/15
Status:
Project:
Component/s:
Affects
Version/s:
Fix Version/s:
Resolved
WSO2 ESB
None
4.8.0
Type:
Reporter:
Resolution:
Labels:
Remaining
Estimate:
Time Spent:
Original
Estimate:
Patch
Susinda Perera
Fixed
None
Not Specified
Attachments:
carbon400_orbit_bsf.diff
Moderate
4.9.0 - M2, 4.9.0 - M5, 4.9.0
Priority:
Assignee:
Votes:
Highest
Malaka Silva
0
Not Specified
Not Specified
synapse_modules_extension.diff
Estimated
Complexity:
Test cases added: Not-applicable
Description
Use following script
<script language="js">payload =
mc.getPayloadJSON();mc.setPayloadJSON(payload);</script>
Test a json payload something like '
{"a" : 5.0}
' which has numbers
Observe the output
Issues
1. unnecessary blank spaces have been introduced in the json payload
2. Some values have been changed for example: 1 to 1.0
3. Some values have been changed for example: 25.0 to 25
Comments
Comment by Susinda Perera [ 25/Feb/14 ]
Please add the attached patched for the mentioned issue.
To test this issue you need to have latest groovy-all jar (2.2.1)
bsf patch - carbon400_orbit_bsf.diff
script-mediator-patch - synapse_modules_extension.diff
Comment by Sivajothy Vanjikumaran [ 21/Mar/14 ]
Hi Susinda,
please send us pull request for https://github.com/wso2-dev/wso2-synapse
Comment by Ananda Manoj Kumara [ 03/Jun/14 ]
created the orbit repo under [1]. Once this is deployed to nexus will add the pull request.
[1] https://github.com/wso2/orbit/tree/master/bsf/3.0.0.wso2v3
Comment by Ananda Manoj Kumara [ 23/Jun/14 ]
Create pull request on synapse,
https://github.com/wso2-dev/wso2-synapse/pull/50
Comment by Sivajothy Vanjikumaran [ 01/Jul/14 ]
https://github.com/wso2-dev/wso2-synapse/pull/50/files
Comment by shafreen anfar [ 11/Dec/14 ]
Hi All,
We need to revisit following part of the fix as it has introduced some regression issue.
if (jsonObject != null) {
+ if(language.equalsIgnoreCase("js")){
+ if(jsEngine instanceof Invocable){
+ try
{ + Object returnObj =((Invocable)jsEngine).invokeMethod(this.jsEngine.eval("JSON"), "stringify", jsonObject
jsonObject = returnObj; + }
catch (NoSuchMethodException e)
{ + //escaping the exception,since we do not block this if the given method is not executable + }
+}
+}
Following is the regression error [1].
[2014-12-10 11:34:31,531] ERROR - ScriptMediator The script engine returned an error executing the inlined js
function mediate
com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "JSON
defined. (<Unknown source>#1) in <Unknown source> at line number 1
at com.sun.phobos.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:184)
at com.sun.phobos.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:198)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at org.apache.synapse.mediators.bsf.ScriptMediator.processJSONPayload(ScriptMediator.java:326)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:285)
at org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:80)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:135)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:16
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at
org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.ja
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:389)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[1] https://wso2.org/jira/browse/ESBJAVA-3423
Comment by Malaka Silva [ 08/Jan/15 ]
Upgraded the rhino to 1.7.0.R4. Also rhino will be deployed from orbit bundle. Earlier it was included with bsf-a
Generated at Fri May 12 04:36:44 IST 2017 using JIRA 7.2.2#72004sha1:9d5132893cc8c728a3601a9034a1f8547ef5c7be.
Related documents