Getting Null Pointer Exception when using testExec in the JSON VSI response

Document ID : KB000095615
Last Modified Date : 15/05/2018
Show Technical Document Details
Issue:
To manipulate the VSI Response being sent to the client application, the testExec is being used as the example below:
{{=testExec.getStateValue("request_identification").substring(0, 3)}}

The Virtual Service works fine during playback, but a Null Pointer Exception is being logged in the VSE log files when a request is sent to the VSM:
ERROR com.itko.lisa.test.ParseInState - Could not evaluate expression '=testExec.getStateValue("request_identification").substring(0, 3)' 
java.lang.RuntimeException: bsh.TargetError: Sourced file: inline evaluation of: ``testExec.getStateValue("request_identification").substring(0, 3);'' : at Line: 1 : in file: inline evaluation of: ``testExec.getStateValue("request_identification").substring(0, 3);'' : .substring ( 0 , 3 ) 
Target exception: java.lang.NullPointerException: Attempt to invoke method substring on null value 
at com.itko.lisa.test.ScriptExecHandler.execExpression(ScriptExecHandler.java:286) 
at com.itko.lisa.test.ParseInState$Hit.doScriptEval(ParseInState.java:425) 
at com.itko.lisa.test.ParseInState$Hit.evaluate(ParseInState.java:415) 
at com.itko.lisa.test.ParseInState.parseInState(ParseInState.java:279) 
at com.itko.lisa.test.TestExec.parseInState(TestExec.java:1966) 
at com.itko.lisa.test.TestExec.parseInState(TestExec.java:1948) 
at com.itko.lisa.test.TestExec.parseInState(TestExec.java:1944) 
at com.itko.lisa.asset.payload.generic.JSONPayload.looksLikeJSON(JSONPayload.java:182)
at com.itko.lisa.vse.stateful.protocol.http.HttpRespondStep.setupResponseInfoHeaderAndContent(HttpRespondStep.java:205) 
at com.itko.lisa.vse.stateful.protocol.http.HttpRespondStep.respond(HttpRespondStep.java:127)
at com.itko.lisa.vse.stateful.BaseRespondStep.execute(BaseRespondStep.java:231) 
at com.itko.lisa.test.TestNode.executeNode(TestNode.java:984) 
at com.itko.lisa.test.TestCase.execute(TestCase.java:1297) 
at com.itko.lisa.test.TestCase.execute(TestCase.java:1198) 
at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1183) 
at com.itko.lisa.test.TestCase.executeTest(TestCase.java:1124) 
at com.itko.lisa.coordinator.Instance.run(Instance.java:208) 
Caused by: bsh.TargetError: Sourced file: inline evaluation of: ``testExec.getStateValue("request_identification").substring(0, 3);'' : at Line: 1 : in file: inline evaluation of: ``testExec.getStateValue("request_identification").substring(0, 3);'' : .substring ( 0 , 3 ) 
Environment:
DevTest on release 10.2.
Cause:
There is a routine that checks to see if the response is JSON so that it can put application/json in the HTTP response header. There was an issue how this routine was being executed when textExec was in use to manipulate the JSON responses.
Resolution:
We may have a patch to address this issue.
If you are facing this behavior, please open a support ticket and reference DE360219.
We will be happy to provide you the fix if it matches your issue.