Issue with implicit accessors

New Here ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

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

Views

577

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 21, 2019 Jan 21, 2019

Copy link to clipboard

Copied

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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

soltiger  wrote

        local j = local.person.getFirstName(); 

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

soltiger​,

If you made the suggested corrections, you should no longer get any errors. That is:

Person.cfc

component accessors=true {

    property name="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.getFirstName();

    }

</cfscript>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 22, 2019 Jan 22, 2019

Copy link to clipboard

Copied

BKBK,

Thank you for you suggestion, but changing 'property firstName' to 'property name="firstName"' didn't fix the issue, I'm still getting the same error rate when running the JMeter test plan.

And yes, it should be 'local.j', I'm not exactly sure how I lost the dot when I copied the code to this forum.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 23, 2019 Jan 23, 2019

Copy link to clipboard

Copied

soltiger  wrote

Thank you for you suggestion, but changing 'property firstName' to 'property name="firstName"' didn't fix the issue, I'm still getting the same error rate when running the JMeter test plan.

Please share with us all the details of the error.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 23, 2019 Jan 23, 2019

Copy link to clipboard

Copied

Sorry, I probably should had included this into the original post.. here is the full error I'm getting: https://pastebin.com/budqiV1m

Please let me know what other details I could provide.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

soltiger, it would seem there's some race condition, since it only fails for you under load. I don't readily see what's amiss (but someone else may).

But here's something that may help: put a try/catch in place, and in the catch dump local.person, to see what it has (or doesn't have) when the error occurs? (You may want to also dump it at the start, after the assignment of name, to see what it should look like normally.) 


/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

Thanks for the suggestion, I'll try this and see if it leads anywhere.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 26, 2019 Jan 26, 2019

Copy link to clipboard

Copied

soltiger, have you yet tried the try/catch to better understand the problem?


/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

https://forums.adobe.com/people/Charlie+Arehart  kirjoitti

soltiger , have you yet tried the try/catch to better understand the problem?

Here is what I added to the index.cfm:

<cfscript>

local.person = new Person();

local.person.firstName = "Zachary";

writedump( local.person );

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

try {

local.j = local.person.firstName;

}

catch( any e ) {

writeoutput("ERROR:" & e.message );

writedump( local.person );

}

}

</cfscript>

And this is what I got when the error occurred:

implict_accessor_dump.png

The objects looks exactly the same to me. Like you mentioned earlier, I also thing this is some race condition issue. Now I'm wondering could it be that the object is not ready/valid initially when the error occurs, hence the exception, but at the time the catch() block gets executed, the object is ready/in valid state, and the error doesn't occur anymore.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

As I have said, this might just be a bug. In your code, there is no such variable as the "element PERSON.FIRSTNAME".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 30, 2019 Jan 30, 2019

Copy link to clipboard

Copied

soltiger,as for your reporting that the try/catch did not help, I will propose that you answer your own question (if the dump works, does the variable now exist?) by adding that as a dump or writeoutput in the catch. 🙂 And while you're at it, write out what the iteration is (local.i) so you know WHEN it's happening. I did that, with a couple of lines tweaked and shared here (but I still don't get the error you do, so I forced an error to ensure I saw output as I expected):

catch( any e ) {

  writeoutput("<br>ERROR (for iteration #local.i#):" & e.message );

  writedump( local.person );

  writeoutput( local.person.firstName );

Let us know what you see when you do this.

And BK, you keep saying there's a bug in his code, and that there is no element of that name. That's not true. 🙂 Recall how last week (on the 26th) you realized that the confusion was because you didn't realize he was using the invokeimplicitaccessor feature, which is why the variable SHOULD exist. And indeed if you run the code you will see that it DOES exist, except in this odd state soltiger is experiencing.


/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 30, 2019 Jan 30, 2019

Copy link to clipboard

Copied

https://forums.adobe.com/people/Charlie+Arehart  wrote

And BK, you keep saying there's a bug in his code, and that there is no element of that name. That's not true. 🙂 Recall how last week (on the 26th) you realized that the confusion was because you didn't realize he was using the invokeimplicitaccessor feature, which is why the variable SHOULD exist. And indeed if you run the code you will see that it DOES exist, except in this odd state soltiger is experiencing.

My point exactly. If a variable should exist but doesn't in certain cases, then there might be a bug. Especially, as ColdFusion sees the non-existent "element person.firstName".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 30, 2019 Jan 30, 2019

Copy link to clipboard

Copied

OK, but there's a big difference between a bug that causes the variable to SOMETIMES not exist (what we are getting at) and the implication of your previous comment, which was that "this might just be a bug. In your code, there is no such variable as the "element PERSON.FIRSTNAME"."

Again, there IS such a variable name, with implicitaccessors, in all 1000 iterations when I run his code. He's experiencing a problem where it sometimes doesn't exist. But you can't say simply that "there is no such variable as the "element PERSON.FIRSTNAME", as if to assert that it's wrong for him to be trying to access it in his code. It is not.

If you agree with that, then let's let it be and focus on trying to solve the "real" bug that he sometimes hits. 🙂


/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

https://forums.adobe.com/people/Charlie+Arehart  wrote

OK, but there's a big difference between a bug that causes the variable to SOMETIMES not exist (what we are getting at) and the implication of your previous comment, which was that "this might just be a bug. In your code, there is no such variable as the "element PERSON.FIRSTNAME"."

Again, there IS such a variable name, with implicitaccessors, in all 1000 iterations when I run his code. He's experiencing a problem where it sometimes doesn't exist. But you can't say simply that "there is no such variable as the "element PERSON.FIRSTNAME", as if to assert that it's wrong for him to be trying to access it in his code. It is not.

If you agree with that, then let's let it be and focus on trying to solve the "real" bug that he sometimes hits. 🙂

Sorry, Charlie, I see it differently. I do not assert that Soltiger is trying to access the "element person.firstName" in his code. For he isn't.

I assert that it is wrong for ColdFusion to see the "element person.firstName". That element does not exist. The page knows an object local.person. The object local.person in turn contains the property firstName.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 30, 2019 Jan 30, 2019

Copy link to clipboard

Copied

Charlie Arehart​,

I'm sorry, but this error is difficult to reproduce, and happens only when server/computer is under heavy load. Just out of curiosity, did you test the code as it is, or did you test it with JMeter (or some similar tool)? If I run the code as it is, I don't get any errors, but when I run it with JMeter, with 200-2000 simultaneous requests, I'll get multiple hits of that error. But even then every request doesn't fail, only 8 - 10 % of the requests. The number of threads required to reproduce the error depends on the hardware you are testing on. The value of local.i, when the error happens, varies. I should explained this earlier, but the purpose of the loop is to add even more load to the server, so that the error occurs more often.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

soltiger, I understood that. And no, I had not done it in a load test. The point is not whether I can replicate the problem. I accepted that I could not but you could.

And as for asking you to output the iteration value, that was a secondary point. I didn't mean to imply it would be an "aha" moment, like there would be some special number where it would fail. I realize it may even be random. I just was proposing that you display it in case it MAY be something interesting.

But the PRIMARY point was the first one: that you try to output the variable whose access had triggered the catch. You commented that it showed up in the dump in the catch. I was just proposing you make sure that an attempt to specifically reference the variable (in the catch) would or would not work.

I don't have any answers for you (and I don't work for Adobe nor do I have any influence on the CF engineers). I'm just trying to help guide you to clarity in what you might now want to write as a bug report, at tracker.adobe.com.


/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

BK, but what is your point in pressing this?  Solitger has been reporting from the first message that the error was "Element PERSON.FIRSTNAME is undefined in LOCAL."

So they ARE trying to access that firstname element as something that should exist (per implicitaccessors), in the person that is in the local scope. And sometimes (only sometimes), that fails for them.

If you are trying to assert they are doing something wrong, please explain. If you are merely re-asserting your disdain for the concept of implicitaccessors, please make that more clear if you choose to reply. If you are merely agreeing within their assertion that this occasional failure is a bug in CF, fair enough. That's not what it seems you are saying, but if so, you could certainly add a vote or comment to the bug report if/when he creates one.


/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

https://forums.adobe.com/people/Charlie+Arehart  wrote

BK, but what is your point in pressing this?  Solitger has been reporting from the first message that the error was "Element PERSON.FIRSTNAME is undefined in LOCAL."

There is nothing I wish to press. Just saying it is likely a bug for ColdFusion to report "Element PERSON.FIRSTNAME is undefined in LOCAL".

So they ARE trying to access that firstname element as something that should exist (per implicitaccessors), in the person that is in the local scope. And sometimes (only sometimes), that fails for them.

My understanding is that, in this context,

local.person.firstName

does not stand for the element firstName in the person that is in local scope. Instead, per implicitAccessors, it stands implicitly for the accessor

local.person.getFirstName()

If you are trying to assert they are doing something wrong, please explain.

I have said a number of times that Soltiger is doing nothing wrong. ColdFusion, on the other hand, probably is.

If you are merely re-asserting your disdain for the concept of implicitaccessors, please make that more clear if you choose to reply.

I have no disdain for the concept of implicitAccessors. Although I don't use it, I do believe it can be handy. But I would advise using it with care.

If you are merely agreeing within their assertion that this occasional failure is a bug in CF, fair enough. That's not what it seems you are saying, but if so, you could certainly add a vote or comment to the bug report if/when he creates one.

As I have said, this might be a ColdFusion bug.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

Charlie Arehart​,

Charlie, thanks for clearing that up. I'm able to reproduce the error every time, so when you mentioned that you didn't get the error, I though thought there could still be something wrong with the test plan. And no, I didn't expect others to start setting up test environment just for this bug (I know I wouldn't ).

And thank you, you have had good suggestions of how to approach this. I tested outputting the same property in the catch as well, after the first attempt to access property had failed, and it the catch it works fine.

And thank you for pointing out the tracker.adobe.com, I didn't realize that it existed. Next I will create a bug report there as you suggested. I already e-mailed Adobe support about this, but I didn't get the response I was looking for, but posting the bug to the tracker sounds like a right channel for this.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

soltiger​, you've shown us plenty. For example, the following is confusing, to say the least.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

@BKBK,

Thanks for you suggestions as well! I don't think we get this solved, and as you guys suggested earlier, this is most likely a bug in CF, and I will next create a bug report to their tracker system.

Person as a returtype sounds interesting, I have never noticed that. The generated accessors seem to use the same return type as as well. I tried to quickly google why this is, but didn't find anything. My best guess is that you could write something like this:

person.setFirstName( "Zachary" ).setAge( 30 );

I tested and it seems to work. I don't think it's related to this issue, but seems handy!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 01, 2019 Feb 01, 2019

Copy link to clipboard

Copied

soltiger  wrote

... this is most likely a bug in CF, and I will next create a bug report to their tracker system.

You've nothing to lose; we've all got much to gain.

Person as a returtype sounds interesting, I have never noticed that.

I wonder what the ColdFusion Team had in mind for making the mutator return an instance of the object. The design is doubtful. In object-oriented design, the default return type for a mutator is void.

The generated accessors seem to use the same return type as as well.

Not on my ColdFusion 2018 installation. Here the return type is any, when you specify no type attribute for the CFC property. If you specify type="abracadabra" for the property, the return type will be abracadabra.

I tried to quickly google why this is, but didn't find anything. My best guess is that you could write something like this:

person.setFirstName( "Zachary" ).setAge( 30 );

I tested and it seems to work.

Your example may work, but it is unrelated to a return type of Person.

[About setter having return type of Person] I don't think it's related to this issue

I wouldn't draw such a conclusion, given the complementary relationship between getters and setters. Here again is something I said earlier:

Add a setter and a getter to Person.cfc, and test with the following code

<cfscript>

component accessors=true {

    property name="firstName";

 

    function setFirstName(string fName){

        writeOutput("#getFunctionCalledName()# called. <br>");

        variables.firstName = arguments.fName;

    }

    function getFirstName(){

        writeoutput("#getFunctionCalledName()# called. <br>");

        // If you leave out the following line, you will reproduce the error

        return variables.firstName;

    }

}

</cfscript>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines