You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Pradeep Choudhary (Jira)" <ji...@apache.org> on 2020/09/26 10:24:00 UTC

[jira] [Commented] (OFBIZ-10512) Change order of parameters in runSyncIgnore

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

Pradeep Choudhary commented on OFBIZ-10512:
-------------------------------------------

Here,


{code:java}
void runSyncIgnore(String serviceName, int transactionTimeout, boolean requireNewTransaction, Object... context) throws ServiceAuthException, ServiceValidationException, GenericServiceException; {code}

'context' parameter is used as var args (variable argument) in this method ie. This argument can accept variable number of values.

As per the java conventions, it should be always at the last of the list. If we try to move it, java shows the following error: "Vararg parameter must be the last in the list".

We can also check the reference for this it
{code:java}
@Override
public void runSyncIgnore(String serviceName, int transactionTimeout, boolean requireNewTransaction, Object... context)
 throws ServiceAuthException, ServiceValidationException, GenericServiceException {
 runSyncIgnore(serviceName, ServiceUtil.makeContext(context), transactionTimeout, requireNewTransaction);
}{code}
GenericDispatcherFactory.java [141]

I this above example, same method calls the override method to place the 'context' param at 2nd place.

We can't change the position of context parameter in runSyncIgnore method due to java limitation for using varargs.

> Change order of parameters in runSyncIgnore
> -------------------------------------------
>
>                 Key: OFBIZ-10512
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10512
>             Project: OFBiz
>          Issue Type: Wish
>            Reporter: Niklas Fallik
>            Priority: Minor
>
> It is confusing that the order of the arguments passed to LocalDispatcher.runSyncIgnore() is not the same in all overloaded methods.
> cf.
> {code:java}
> void runSyncIgnore(String serviceName, Map<String, ? extends Object> context, int transactionTimeout, boolean requireNewTransaction) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
> {code}
>  
> {code:java}
> void runSyncIgnore(String serviceName, int transactionTimeout, boolean requireNewTransaction, Object... context) throws ServiceAuthException, ServiceValidationException, GenericServiceException; {code}
> cf.
> LocalDispatcher.java[101 + 102]
>  
> The context parameter could be passed as second or as fourth argument, no matter if it is a Map or an Object.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)