[
https://issues.apache.org/jira/browse/GEODE-6293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16757014#comment-16757014
]
ASF subversion and git services commented on GEODE-6293:
--------------------------------------------------------
Commit 9fa4dc25c3f1dd9e470729eb707b3fe81fd7fc7e in geode's branch
refs/heads/develop from Juan José Ramos
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=9fa4dc2 ]
GEODE-6293: Fix fire & forget functions in gfsh (#3138)
* GEODE-6293: Fix fire & forget functions in gfsh
- Fixed minor warnings.
- Refactored class `UserFunctionExecution`.
- Added unit tests for class `UserFunctionExecution`.
- Class `UserFunctionExecution` now supports the execution of functions
that don't return any results.
> 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
> Assignee: Juan José Ramos Cassella
> Priority: Major
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> 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)