Fix NPE in eval() function
@@ -22,6 +22,7 @@ package com.orientechnologies.orient.core.sql.functions.math;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
+import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.filter.OSQLPredicate;
import java.util.List;
@@ -46,7 +47,10 @@ public class OSQLFunctionEval extends OSQLFunctionMathAbstract {
final Object iCurrentResult,
final Object[] iParams,
OCommandContext iContext) {
- if (predicate == null) predicate = new OSQLPredicate((String) iParams[0].toString());
+ if (iParams.length < 1) {
+ throw new OCommandExecutionException("invalid ");
+ }
+ if (predicate == null) predicate = new OSQLPredicate(String.valueOf(iParams[0]));
final ODocument currentResult =
iCurrentResult instanceof ODocument ? (ODocument) iCurrentResult : null;
