You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org> on 2010/05/10 21:28:32 UTC

[jira] Updated: (TAP5-1141) TypeCoercion from arbitrary object to Boolean will NPE when the value is null (should coerce to false)

     [ https://issues.apache.org/jira/browse/TAP5-1141?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship updated TAP5-1141:
---------------------------------------

    Assignee: Howard M. Lewis Ship
    Priority: Critical  (was: Major)

        add(configuration, String.class, Boolean.class, new Coercion<String, Boolean>()
        {
            public Boolean coerce(String input)
            {
                String trimmed = input.trim();

                if (trimmed.equalsIgnoreCase("false") || trimmed.length() == 0) return false;

                // Any non-blank string but "false"

                return true;
            }
        });


This code assumes input is not null.

> TypeCoercion from arbitrary object to Boolean will NPE when the value is null (should coerce to false)
> ------------------------------------------------------------------------------------------------------
>
>                 Key: TAP5-1141
>                 URL: https://issues.apache.org/jira/browse/TAP5-1141
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-ioc
>    Affects Versions: 5.2.0
>            Reporter: Howard M. Lewis Ship
>            Assignee: Howard M. Lewis Ship
>            Priority: Critical
>
>             <div t:type="if" test="user.homePhoneNumber"> Home: ${user.homePhoneNumber}</div>
> Results in:
> Render queue error in BeginRender[PersonalDetails:if_1]: Failure reading parameter 'test' of component PersonalDetails:if_1: Coercion of null to type java.lang.Boolean (via Object --> String, String --> Boolean) failed: java.lang.NullPointerException
> org.apache.tapestry5.ioc.services.TapestryIOCModule$15.coerce(TapestryIOCModule.java:255)
> org.apache.tapestry5.ioc.services.TapestryIOCModule$15.coerce(TapestryIOCModule.java:252)
> org.apache.tapestry5.ioc.services.CoercionTuple$CoercionWrapper.coerce(CoercionTuple.java:51)
> org.apache.tapestry5.ioc.internal.services.CompoundCoercion.coerce(CompoundCoercion.java:45)
> org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.coerce(TypeCoercerImpl.java:72)
> org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.coerce(TypeCoercerImpl.java:137)
> org.apache.tapestry5.internal.transform.ParameterWorker$2$1.readFromBinding(ParameterWorker.java:282)
> org.apache.tapestry5.internal.transform.ParameterWorker$2$1.get(ParameterWorker.java:381)
> org.apache.tapestry5.corelib.components.If.test(If.java:45)
> org.apache.tapestry5.corelib.base.AbstractConditional.beginRender(AbstractConditional.java:59)
> org.apache.tapestry5.internal.transform.RenderPhaseMethodWorker$Invoker.invoke(RenderPhaseMethodWorker.java:117)
> I think the special case of null -> String needs to allow for a null object coerced to a (null) String.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.