I have a custom connector where I execute queries and retrieve information from a database
When i execute a query say like select name where name like ‘bonita’, if there is any result, then i get a response and store it in a variable without any problem
If the response is null, i use an if else condition to return something. But i get the following error if the response is null.
if else condition is as follows:
try{
if(response.get(0).get(0)==null)){
return "No result";
}
else return response.get(0).get(0) ;
}
catch(Exception e){
return false;
}
Error:
Caused by: java.util.concurrent.ExecutionException: java.lang.ClassCastException: com.google.gson.JsonNull cannot be cast to com.google.gson.JsonObject
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262)
at java.util.concurrent.FutureTask.get(FutureTask.java:119)
at com.bonitasoft.engine.connector.impl.ConnectorExecutorTimedOut.getValue(ConnectorExecutorTimedOut.java:54)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.execute(ConnectorExecutorImpl.java:122)
… 13 more
Caused by: java.lang.ClassCastException: com.google.gson.JsonNull cannot be cast to com.google.gson.JsonObject
at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:186)
at be.bonita7.connector.TestImpl.executeBusinessLogic(TestImpl.java:119)
at org.bonitasoft.engine.connector.AbstractConnector.execute(AbstractConnector.java:77)
at org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:69)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:208)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:179)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
… 3 more
Any help would be really appreciated.
Regards,
A.