Bug 60032

Summary: EL function resolve varargs values but not send it to function call
Product: Tomcat 8 Reporter: d02bernard
Component: ELAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.0.33   
Target Milestone: ----   
Hardware: PC   
OS: All   

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