From 402dd2db9e4e5ce52ea2dd1cc54dccc8a00f2ffb Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 16 Mar 2024 10:09:48 -0400 Subject: [PATCH] Fix #5417: remove "optimization" when composite attribute default is literal instead of VE, this will fail when the final value itself is VE --- .../applicationimpl/InstanceFactory.java | 49 ++++--------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java index 7617eec378..fc19300977 100644 --- a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java +++ b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java @@ -27,7 +27,6 @@ import static jakarta.faces.component.UIComponent.ATTRS_WITH_DECLARED_DEFAULT_VALUES; import static jakarta.faces.component.UIComponent.BEANINFO_KEY; import static jakarta.faces.component.UIComponent.COMPOSITE_COMPONENT_TYPE_KEY; -import static java.beans.Introspector.getBeanInfo; import static java.beans.PropertyEditorManager.findEditor; import static java.text.MessageFormat.format; import static java.util.Collections.unmodifiableMap; @@ -37,7 +36,6 @@ import java.beans.BeanDescriptor; import java.beans.BeanInfo; -import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; @@ -57,16 +55,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.sun.faces.application.ApplicationAssociate; -import com.sun.faces.application.ConverterPropertyEditorFactory; -import com.sun.faces.application.ViewMemberInstanceFactoryMetadataMap; -import com.sun.faces.cdi.CdiUtils; -import com.sun.faces.config.WebConfiguration; -import com.sun.faces.util.FacesLogger; -import com.sun.faces.util.MessageUtils; -import com.sun.faces.util.ReflectionUtils; -import com.sun.faces.util.Util; - import jakarta.el.ExpressionFactory; import jakarta.el.ValueExpression; import jakarta.enterprise.inject.spi.BeanManager; @@ -83,6 +71,16 @@ import jakarta.faces.validator.Validator; import jakarta.faces.view.ViewDeclarationLanguage; +import com.sun.faces.application.ApplicationAssociate; +import com.sun.faces.application.ConverterPropertyEditorFactory; +import com.sun.faces.application.ViewMemberInstanceFactoryMetadataMap; +import com.sun.faces.cdi.CdiUtils; +import com.sun.faces.config.WebConfiguration; +import com.sun.faces.util.FacesLogger; +import com.sun.faces.util.MessageUtils; +import com.sun.faces.util.ReflectionUtils; +import com.sun.faces.util.Util; + public class InstanceFactory { // Log instance for this class @@ -805,21 +803,12 @@ private void pushDeclaredDefaultValuesToAttributesMap(FacesContext context, Bean ExpressionFactory expressionFactory) { Collection attributesWithDeclaredDefaultValues = null; - PropertyDescriptor[] propertyDescriptors = null; for (PropertyDescriptor propertyDescriptor : componentMetadata.getPropertyDescriptors()) { Object defaultValue = propertyDescriptor.getValue("default"); if (defaultValue != null) { String key = propertyDescriptor.getName(); - boolean isLiteralText = false; - - if (defaultValue instanceof ValueExpression) { - isLiteralText = ((ValueExpression) defaultValue).isLiteralText(); - if (isLiteralText) { - defaultValue = ((ValueExpression) defaultValue).getValue(context.getELContext()); - } - } // Ensure this attribute is not a method-signature. method-signature // declared default values are handled in retargetMethodExpressions. @@ -834,24 +823,6 @@ private void pushDeclaredDefaultValuesToAttributesMap(FacesContext context, Bean } } attributesWithDeclaredDefaultValues.add(key); - - // Only store the attribute if it is literal text. If it - // is a ValueExpression, it will be handled explicitly in - // CompositeComponentAttributesELResolver.ExpressionEvalMap.get(). - // If it is a MethodExpression, it will be dealt with in - // retargetMethodExpressions. - if (isLiteralText) { - try { - if (propertyDescriptors == null) { - propertyDescriptors = getBeanInfo(component.getClass()).getPropertyDescriptors(); - } - } catch (IntrospectionException e) { - throw new FacesException(e); - } - - defaultValue = convertValueToTypeIfNecessary(key, defaultValue, propertyDescriptors, expressionFactory); - attrs.put(key, defaultValue); - } } } }