You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Daniel Watford (Jira)" <ji...@apache.org> on 2023/04/14 12:27:00 UTC

[jira] [Commented] (OFBIZ-12801) Error at CommunicationEventServices.groovy:489 due to OFBIZ-11167

    [ https://issues.apache.org/jira/browse/OFBIZ-12801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17712362#comment-17712362 ] 

Daniel Watford commented on OFBIZ-12801:
----------------------------------------

Line 489 of CommunicationEventServices.groovy - i.e. the last expression to be evaluated in the function - is communicationEvents.each \{ <closure> }

In this case communciationEvents.each() will return a List<GenericValue>. Since this is the last expression in the function it will be returned, meaning this function's signature is really:
{code:java}
List<GenericValue> sendEmailDated(){code}
 

I imagine this was not the original intent of the function since there is a call to `return success` inside the closure passed to communicationEvents.each.

The service definition does not define any outputs...
{code:java}
<service name="sendEmailDated" engine="groovy" use-transaction="false"
location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="sendEmailDated" auth="true">
<description>Checks for email communication events with the status COM_IN_PROGRESS and a startdate which is expired, then send the email</description>
</service>{code}
... but since it is a service I imagine it should return a map containing responseMessage entry with a value of success, fail or error. (See ModelService#returnSuccess, etc).

The function should probably be modified to return a 'success' map unless any non-success results were found when executing the closure by communicationEvents.each().

 

Side note: We should probably take a look at GroovyBaseScript#success and ensure it really does return a Map.  The current implementation can return either a Map or a String.

> Error at  CommunicationEventServices.groovy:489 due to OFBIZ-11167
> ------------------------------------------------------------------
>
>                 Key: OFBIZ-12801
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-12801
>             Project: OFBiz
>          Issue Type: Bug
>          Components: projectmgr
>    Affects Versions: Upcoming Branch
>         Environment: 
>            Reporter: Jacques Le Roux
>            Assignee: Jacques Le Roux
>            Priority: Major
>             Fix For: Upcoming Branch
>
>
> I get this error locally:
> The Following Errors Occurred:
> Service dispatcher threw an exception:Error running Groovy method [sendEmailDated] in Groovy file [component://party/groovyScripts/communication/CommunicationEventServices.groovy]: (Cannot cast object '[]' with class 'java.util.ArrayList' to class 'java.util.Map' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.Map())
> When I replace 
> Map sendEmailDated() {
> by
> def sendEmailDated() {
> The error disappears
> I guess something better can be done, but I have not yet found what :)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)