tracker issue : CF-4199987

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

ColdFusion does not allow chaining of methods exposed in Java libraries

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): / ()

Created: 10/10/2017

Components: Language

Versions: 2016,11.0,2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: Alpha, 304000 / 299481

Priority/Frequency: Normal / Few users will encounter

Locale/System: /

Vote Count: 1

Problem:
Interop with Java libs is way harder than it should be. Consider this real-world example of using the ElasticSearch Java API. (docs: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-term-level-queries.html)

{code:java}
QueryBuilder qb = rangeQuery("age")   
    .gte("10")                        
    .lt("20");    
{code}

If you create an instance of Elastic's rangeQuery, you can not call the gte method from ColdFusion at all. You get an error:

Invalid CFML construct found on line 12 at column 10.

ColdFusion was looking at the following text:
gte

Method:

Result:

Expected:

Workaround:

Note:

Attachments:

Comments:

This is not an issue with parsing *gte* but a problem with recursive chaining. I just created a sample code snippet with *gte()* function and verified that the following code works: {code:java} WriteOutput(sample.gte(5)); {code} But the one having multiple dotted references fails eg: {code:java} WriteOutput(sample.gte(5).lte(15)); {code}
Comment by Ashudeep S.
246 | October 10, 2017 11:22:55 AM GMT
You sure yer looking at the same code, Ashudeep? The error reported in the ticket is a *compile* error. Having a problem multiple chained methods would be a runtime issue, would it not?
Comment by Adam C.
247 | October 11, 2017 10:03:30 AM GMT
Yeah i know this is an issue with chaining kind of syntax in our parser.This will be a problem with any reserved keywords being used at the second and subsequent levels during function chaining and we are going to fix it.
Comment by Ashudeep S.
248 | October 11, 2017 10:51:09 AM GMT