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

Pavel Tupitsyn commented on IGNITE-12823:
-----------------------------------------

[~zzzadruga] In my understanding, we don't need to change сore serialization 
logic to fix this issue.
The problem boils down to this: in PlatformServices.invoke all arrays are 
Object[], but service method may have a different array type T[]. All we have 
to do is convert the array on the go. 

I've made a quick POC that makes the tests pass, replace 
org.apache.ignite.internal.processors.platform.services.PlatformServices.ServiceProxyHolder#invoke
 with the following:

{code}
        public Object invoke(String mthdName, boolean srvKeepBinary, Object[] 
args)
            throws IgniteCheckedException, NoSuchMethodException {
            if (proxy instanceof PlatformService)
                return ((PlatformService)proxy).invokeMethod(mthdName, 
srvKeepBinary, args);
            else {
                assert proxy instanceof GridServiceProxy;

                // Deserialize arguments for Java service when not in binary 
mode
                if (!srvKeepBinary)
                    args = PlatformUtils.unwrapBinariesInArray(args);

                Method mtd = getMethod(serviceClass, mthdName, args);

                for (int i = 0; i < args.length; i++) {
                    Object arg = args[i];

                    if (arg instanceof Object[]) {
                        Class<?> parameterType = mtd.getParameterTypes()[i];

                        if (parameterType.isArray() && parameterType != 
Object[].class) {
                            Object[] arr = (Object[])arg;
                            Object newArg = 
Array.newInstance(parameterType.getComponentType(), arr.length);

                            for (int j = 0; j < arr.length; j++)
                                Array.set(newArg, j, arr[j]);

                            args[i] = newArg;
                        }
                    }
                }

                try {
                    return ((GridServiceProxy)proxy).invokeMethod(mtd, args);
                }
                catch (Throwable t) {
                    throw IgniteUtils.cast(t);
                }
            }
        }
{code}

> .NET: Service method with user type array parameter can't be found
> ------------------------------------------------------------------
>
>                 Key: IGNITE-12823
>                 URL: https://issues.apache.org/jira/browse/IGNITE-12823
>             Project: Ignite
>          Issue Type: Bug
>          Components: platforms
>            Reporter: Alexey Kukushkin
>            Assignee: Nikolai Kulagin
>            Priority: Major
>              Labels: .NET, sbcf
>         Attachments: ignite-12823-vs-2.8.patch
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> *+Setup+*
>  * Ignite Java service with a method having an array of user types as a 
> parameters, for example, caclulate(Parameter[] params)
> *+Actions+*
>  * .NET client calls the Ignite Java service, for example, 
> ignite.GetServices().GetServiceProxy<ICalculator>().calculate(new[] \{new 
> Parameter()});
> *+Expected+*
>  * The service method is called
> *+Actual+*
>  * Exception "Could not find proxy method 'calculate' in class ICalculator"
> *+Workaround+*
>  * Replace array of user types with array of objects in the service methods 
> signatures, for example, caclulate(Object[] params)



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

Reply via email to