Barry Oglesby created GEODE-6293: ------------------------------------ Summary: Gfsh execute function command expects the function to have a result Key: GEODE-6293 URL: https://issues.apache.org/jira/browse/GEODE-6293 Project: Geode Issue Type: Bug Components: gfsh Reporter: Barry Oglesby
Functions with hasResult returning false cause gfsh to log this exception message: {noformat} gfsh>execute function --id=TestNoResultFunction --region=/data Member | Status | Message -------- | ------ | ------------------------------------------------------------------------ server-1 | ERROR | Exception: Cannot return any result as the Function#hasResult() is false {noformat} That message is coming from `UserFunctionExecution.execute` which does: {noformat} List<Object> results = (List<Object>) execution.execute(function.getId()).getResult(); {noformat} Here is the stack where that happens: {noformat} java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1333) at org.apache.geode.internal.cache.execute.NoResult.getResult(NoResult.java:56) at org.apache.geode.management.internal.cli.functions.UserFunctionExecution.execute(UserFunctionExecution.java:156) at org.apache.geode.internal.cache.MemberFunctionStreamingMessage.process(MemberFunctionStreamingMessage.java:193) at org.apache.geode.distributed.internal.DistributionMessage.scheduleAction(DistributionMessage.java:367) at org.apache.geode.distributed.internal.DistributionMessage$1.run(DistributionMessage.java:433) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.geode.distributed.internal.ClusterDistributionManager.runUntilShutdown(ClusterDistributionManager.java:956) at org.apache.geode.distributed.internal.ClusterDistributionManager.doFunctionExecutionThread(ClusterDistributionManager.java:810) at org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121) at java.lang.Thread.run(Thread.java:745) {noformat} Here is a potential fix that addresses the issue: {noformat} List<Object> results = null; ResultCollector rc = execution.execute(function.getId()); if (function.hasResult()) { results = (List<Object>) rc.getResult(); } {noformat} This fix causes gfsh to report an OK result: {noformat} gfsh>execute function --id=TestNoResultFunction --region=/data Member | Status | Message -------- | ------ | ------- server-1 | OK | [] {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)