Wednesday, 3 July 2013

Threads add weird methods into CFCs

G'day:
This is a weird one. And not terribly interesting, but a blog is supposed to be a log of what I'm doing, and this is what I'm currently looking at.


Here's some code:

component {

    public void function f(){
        var t1 = false;
        thread name="t1" action="run" {
            // nowt
        }
    }

}

o = new C();
md = getMetadata(o);

writeDump([o,md]);

This outputs:

array
1
component shared.git.blogExamples.thread.C
METHODS
2
struct
EXTENDS
struct
FULLNAMEWEB-INF.cftags.component
NAMEWEB-INF.cftags.component
PATHC:\Apps\JRunservers\cf9.en01.hostelbookers.local\cfusion.ear\cfusion.war\WEB-INF\cftags\component.cfc
TYPEcomponent
FULLNAMEshared.git.blogExamples.thread.C
FUNCTIONS
array
1
struct
ACCESSpublic
NAMEf
PARAMETERS
array [empty]
RETURNTYPEvoid
2
struct
NAME_cffunccfthread_cfC2ecfc8719792511
PARAMETERS
array
1
struct
NAMEATTRIBUTES
REQUIREDtrue
NAMEshared.git.blogExamples.thread.C
PATHD:\websites\www.scribble.local\shared\git\blogExamples\thread\C.cfc
TYPEcomponent


Note the highlighted bit. WTF? Well I can guess what it's for, it's some internal thing that ColdFusion is doing to be able to kick off the thread. If I take the thread reference out, this goes away.

I'm not that enamoured with this. I don't care if CF needs to create methods under the hood to run stuff, but it should not bleed out into my code / environment.

This came up in a real-world situation. I'm writing some code which has an outwards-facing API, and I'm using the auto-generated API docs that CF generates if one browses to a CFC, eg this:

So this is a bit crap. I don't want Adobe's rubbish cluttering up my API. Also, note, that this has been created as a public method, which I really don't think is correct even if Adobe must bleed their code out into mine.  And, yes, I can actually run it!

Sloppy shit.

As is becoming a thematic refrain on this blog "Railo doesn't behave this way", IE: it does not create spurious methods inside my CFCs.

I've raised a bug for this: 3589407.

Back to my day job.

--
Adam