tracker issue : CF-4206904

select a category, or use search below
(searches all categories and all time range)
Title:

GetMetaData(cfc) returns null

| View in Tracker

Status/Resolution/Reason: Open//

Reporter/Name(from Bugbase): Chris P. / ()

Created: 01/28/2020

Components: Language, Functions

Versions: 2016

Failure Type: Non Functioning

Found In Build/Fixed In Build: 2016.0.13.316217 /

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Win 2016

Vote Count: 7

# Problem Description:
We are using GetMetaData(cfc) for "reflection" style programming. In particular, I have a package that loads components (accessors=true) with deeply nested data. This works by using GetMetaData(cfc).name to determine the correct code to run.

See https://github.com/cfchris/cfc_loader

Frequently, GetMetaData(cfc).name throws (java.lang.NullPointerException). When this happens, it will only stop after we use the "Clear Template Cache Now" button in the CF Admin. This error happens both with and without "Trusted Cache" enabled.

# Steps to Reproduce:
* Use GetMetaData(cfc) to get metadata about a CFC in your code.
* Deploy updates to CFCs (any CFC not even related to the one you're getting metadata on)

# Actual Result:
* CF will "forget" the metadata for the CFC and throw NPE errors (until you "Clear Template Cache")

# Expected Result:
* CF returns the CFC metadata for the CFC.

# Any Workarounds:
* No real workaround. You're customers get a bunch of errors. Then, you get alerts. Then, you go "Clear Template Cache".

Attachments:

Comments:

The error will be on a line like: return GetMetaData(arguments.cfc).name; And it will have this stack trace: java.lang.NullPointerException at coldfusion.util.CaseInsensitiveMap$FastHashKeyEnumerator.next(CaseInsensitiveMap.java:477) at coldfusion.runtime.MetadataUtils.getMetaData(MetadataUtils.java:58) at coldfusion.runtime.CfJspPage.GetMetadata(CfJspPage.java:3769) at cfloader2ecfc1346762195$funcGETCFCNAME.runFunction(I:\dealerpeak\com\github\cfchris\cfc_loader\loader.cfc:68)
Comment by Chris P.
31965 | January 28, 2020 08:15:43 PM GMT
We have been struggling with these errors for over a year. I would have submitted the bug much sooner. But, I cannot replicate. I tried the following: * set up a clean CF server * wrote a template that spins through and creates CFCs of particular name (and overwrites them with different contents) and reads their metadata (If this encounters and error it sets a server level variable to tell all other pages to stop what they are doing. * wrote another page that clears trusted cache occasionally (and stops if it sees the flag) * pointed a load testing tool at those pages and had it run them aggressively for an entire night. ^ The above is a summary. Basically, I emulated everything related to deploying code (which is when it happens) And I _could not_ get it to happens locally. But, it happens daily in production. Sometimes one (of ten) servers will choke after a deploy. Sometimes a couple will. It's totally unpredictable. Somehow GetMetaData(cfc) is related to trusted cache (at least in that "Clear Template Cache") resets it and it starts working again.
Comment by Chris P.
31966 | January 28, 2020 08:22:30 PM GMT
GetMetaData(cfc) should never return NULL if the CFC is a valid CFC. A developer needs to look at why GetMetaData() would return NULL for a CFC (and why "Clear Template Cache" would fix it).
Vote by Chris p.
31969 | January 28, 2020 08:29:53 PM GMT
Please review both UndefinedMetaData.png attachments. I managed to get on a server that is having the problem with a CFC right now. You can see the results of the following code in the images. ```<cfscript> function test() { try { // Creating the object works. var c = new com.dealerpeak.vo.User(); // Calling a method on it works. (So, it *is* an instance of a CFC.) c.setActive(true); var cm = GetComponentMetaData("com.dealerpeak.vo.User"); WriteDump([ "cfc": c, // undefined "meta": cm, // undefined "c.active": c.getActive() // works? ]); } catch (any e) { WriteDump(e); } try { // This completely throws an error. var m = GetMetaData(c); } catch (any e) { WriteDump(e); } } test(); </cfscript>```
Comment by Chris P.
31967 | January 29, 2020 02:28:32 AM GMT
And if you will look at DefinedMetaData.png, you will see that the above code is working as expected after I logged into the CF Admin and clicked "Clear Template Cache Now". I have to do this every time we deploy and it can show up hours later. This is a nightmare. We don't even have "Trusted Cache" on anymore. It happens either way regardless.
Comment by Chris P.
31968 | January 29, 2020 02:34:48 AM GMT
This is causing frequent errors in our application and frustrating customers.
Vote by Eric A.
31970 | January 29, 2020 05:25:41 PM GMT