Bug 60032 - EL function resolve varargs values but not send it to function call
Summary: EL function resolve varargs values but not send it to function call
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: EL (show other bugs)
Version: 8.0.33
Hardware: PC All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-23 09:54 UTC by d02bernard
Modified: 2016-08-24 11:34 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description d02bernard 2016-08-23 09:54:12 UTC
In method AstFunction#getValue,  the vargargs values are resolved and added to named varargs variable. The  varargs variables is never added to the parameter list used to call the method.

       if (inputParameterCount > 0) {
            params = new Object[methodParameterCount];
            try {
                for (int i = 0; i < methodParameterCount; i++) {
                    if (m.isVarArgs() && i == methodParameterCount - 1) {
                        if (inputParameterCount < methodParameterCount) {
                            params[i] = null;
                        } else {
                            Object[] varargs =
                                    new Object[inputParameterCount - methodParameterCount + 1];
                            Class<?> target = paramTypes[i].getComponentType();
                            for (int j = i; j < inputParameterCount; j++) {
                                varargs[j-i] = parameters.jjtGetChild(j).getValue(ctx);
                                varargs[j-i] = coerceToType(ctx, varargs[j-i], target);
                            }
                        }
                    } else {
                        params[i] = parameters.jjtGetChild(i).getValue(ctx);
                        params[i] = coerceToType(ctx, params[i], paramTypes[i]);
                    }
                }
            } catch (ELException ele) {
                throw new ELException(MessageFactory.get("error.function", this
                        .getOutputName()), ele);
            }
        }
        try {
            result = m.invoke(null, params);
        } catch (IllegalAccessException iae) {
            throw new ELException(MessageFactory.get("error.function", this
                    .getOutputName()), iae);
        } catch (InvocationTargetException ite) {
            Throwable cause = ite.getCause();
            if (cause instanceof ThreadDeath) {
                throw (ThreadDeath) cause;
            }
            if (cause instanceof VirtualMachineError) {
                throw (VirtualMachineError) cause;
            }
            throw new ELException(MessageFactory.get("error.function", this
                    .getOutputName()), cause);
        }
        return result;
Comment 1 Mark Thomas 2016-08-24 11:34:06 UTC
This has been fixed in the following branches:
- 9.0.x for 9.0.0.M10 onwards
- 8.5.x for 8.5.5 onwards
- 8.0.x for 8.0.37 onwards