Skip to main content
Known Participant
January 21, 2019
Question

Issue with implicit accessors

  • January 21, 2019
  • 2 replies
  • 2483 views

Our development team recently discovered that we are getting multiple errors when using implicit get accessor (person.firstName) instead of generated get accessor (person.getFirstName()). Here are instructions of how to reproduce the error:

1. Create a new ColdFusion application with the following files:

Application.cfc:

<cfcomponent output="false">

    <cfset this.invokeImplicitAccessor = true />

</cfcomponent>

Person.cfc:

component accessors=true {

    property firstName;

}

index.cfm:

<cfscript>

    local.person = new Person();

    local.person.firstName = "Zachary";

    for( local.i = 0; local.i < 1000; local.i++ ) {

        local j = local.person.firstName;

    }

</cfscript>

index2.cfm:

<cfscript>

    local.person = new Person();

    local.person.firstName = "Zachary";

    for( local.i = 0; local.i < 1000; local.i++ ) {

        local j = local.person.firstName;

    }

</cfscript>

2. Test the index.cfm with JMeter, use 2000 threads, 10s Ram-Up Period and Loop count 1 (test plan: https://pastebin.com/nBtpL4zP)

3. In our tests the page always fails with the same error message:

Element PERSON.FIRSTNAME is undefined in LOCAL.

4. The error % we are getting with the above settings usually falls somewhere between 8 to 10 %, meaning that 160 to 200 requests out of >2000 requests fails.

5. When index2.cfm gets tested with the same settings, we don't get any errors

Here are some details about the test environment:

OS: Windows Server 2016 Standard

ColdFusion: Adobe ColdFusion 2018 Release

JMeter 5.0 (https://jmeter.apache.org/download_jmeter.cgi)

Does anyone have any idea why this is happening? Is there some ColdFusion settings we could tweak? The above example application is >very minimal, and we are not doing anything special, so I don't see any reasons why implicit accessors should fail, especially when >generated accessors seems to pass the same test without any issues.

We appreciate any help or suggestions of what to try to get the >implicit accessors working.

br,

Antti Koskenalho

This topic has been closed for replies.

2 replies

soltigerAuthor
Known Participant
February 1, 2019

Plese find the bug report I just created from here: Tracker https://tracker.adobe.com/#/view/CF-4203997

andmayfi
Participant
July 19, 2024

I know this post is from 2019 but I am experiencing the same random failures on version 2021,0,08,330144. I see your bug tracker is closed as cannot reproduce so I thought I would ask if there was a solution that worked for you. I have attached my reproducible test case, fails randomly and way more often on prod than dev or local even with prod and dev being identical.

Since I cant seem to upload zips to keep it all neat here is the code. 

 

index.cfm

<cftry>
    <cfset uniqueNameToRuleOutCachingIssuesObject = new test.orders.uniqueNameToRuleOutCachingIssues()>
    <cfset uniqueNameToRuleOutCachingIssuesObject.loadInfo()>

    <cfdump var="#getMetadata(uniqueNameToRuleOutCachingIssuesObject)#" expand="false">
    <cfdump var="#uniqueNameToRuleOutCachingIssuesObject#" label="uniqueNameToRuleOutCachingIssuesObject" expand="false">

    <div>
        <cfoutput>
        <p>uniqueNameToRuleOutCachingIssuesObject.testValue : #uniqueNameToRuleOutCachingIssuesObject.testValue#</p>
        </cfoutput>
    </div>

    <cfcatch>
        <br>
        <h4>Exception Thrown:</h4>
        <cfdump var="#uniqueNameToRuleOutCachingIssuesObject#" label="uniqueNameToRuleOutCachingIssues" expand="false">
        <cfdump var="#cfcatch#">
    </cfcatch>
</cftry>

uniqueNameToRuleOutCachingIssues.cfc

component
  invokeImplicitAccessor = true
  accessors = true
  name = 'uniqueNameToRuleOutCachingIssues'
{

  property integer testValue;


  public uniqueNameToRuleOutCachingIssues function init()
  {
    return this;
  }

  public uniqueNameToRuleOutCachingIssues function loadInfo()
  {
    variables.testValue = 1;

    return this;
  }

	public struct function variablesScope()
	{
		return variables;
	}
}

 

As you can see the value exists in the dumb before the value is access and in the dump in the error after it fails to access the value.  

BKBK
Community Expert
Community Expert
July 20, 2024

@andmayfi , as you yourself say this thread is a number of years old. ColdFusion has moved on.

I would suggest you start a new thread of your own.

BKBK
Community Expert
Community Expert
January 21, 2019

You may need to do some corrections before we go any further:

1) Replace "local j = local.person.firstName;" with "local.j = local.person.firstName;".

2) Differentiate the code in index.cfm and index2.cfm. They are the same at the moment.

soltigerAuthor
Known Participant
January 22, 2019

You are right, it should be local.j = local.person.firstName;

and here is the correct implementation for index2.cfm:

<cfscript>

    local.person = new Person();

    local.person.firstName = "Zachary";

    for( local.i = 0; local.i < 1000; local.i++ ) {

        local j = local.person.getFirstName();

    }

</cfscript>

BKBK
Community Expert
Community Expert
January 22, 2019

soltiger  wrote

        local j = local.person.getFirstName(); 

Shouldn't you change that too to local.j ?