Title:
Setting invalid value for a component's property using implicit setter causes unexpected behaviour
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Sathish Kumar / Sathish Kumar (Sathish Kumar)
Created: 05/07/2013
Components: Language, CF Component
Versions: 10.0
Failure Type: Data Loss
Found In Build/Fixed In Build: Final / 286343
Priority/Frequency: Critical / All users will encounter
Locale/System: English / Windows 7 SP1 64-bit
Vote Count: 1
Problem Description:
If you have enabled the implicit setter/getters for your application in the application.cfc using the following line
<cfset this.invokeImplicitAccessor = true>
you can then create instances of your cfc and use the implicit setter notation such as instance.property = value where instance is an instance of a CFC that has a property defined using <CFPROPERTY> tag. The problem will become evident only if you set the validation rules on a property and try to set an invalid value to the property. Although setting an invalid value to the property of a component using the Setter method for the property throws an exception of type "coldfusion.tagext.validation.CFStringValidator$StringLowerBoundException", the same does not happen when you use the implicit setter notation. This was found in CF developer edition version( 10,0,9,284568).
Steps to Reproduce:
Step 1: Create a CFC with name such as "mycomponent" in mycomponent.cfc with a property called "name" as below
<cfcomponent accessors="true" >
<cfproperty name="Name" type="string" validate="string" validateparams="{minlength=5,maxlength=100}">
</cfcomponent>
Step 2: Ensure that the Application.cfc contains the following setting
<cfset this.invokeImplicitAccessor = true>
Step 3: Create a test page with an instance of the component and try to assign an empty vaue for the name property as below
<cftry>
<cfset instance = new mycomponent()>
<cfdump var="#instance#" label="instance before setting name using implicit setter notation">
<cfset instance.name = "" >
<cfdump var="#instance#" label="instance after trying to set name using implicit setter notation empty string">
<cfcatch type="any" >
<cfdump var="#cfcatch#" label="error when setting invalid name using implicit setter on instance">
<cfdump var="#instance#" label="instance when error happened in setting invalid name using implicit setter">
</cfcatch>
</cftry>
Actual Result:
The system would throw an error "Expression" with message "Element NAME is undefined in a Java object of type class coldfusion.runtime.TemplateProxy." will be throw.
Expected Result:
The system must throw an exception of type "coldfusion.tagext.validation.CFStringValidator$StringLowerBoundException" with the message such as "The length of the string, 0 character(s), must be greater than or equal to 5 character(s)."
Any Workarounds:
Yes, you must use the explicit setter method invocation such as instance.SetName("") to ensure that the above exception is thrown and could be caught successfully and handled as required by the business logic.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3555895
Deployment Phase: Release Candidate
External Customer Info:
External Company:
External Customer Name: Carboncubes.Tech
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: