tracker issue : CF-4201538

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

expandPath in event gateways throws StringIndexOutOfBoundsException

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/CannotReproduce

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood ()

Created: 03/15/2018

Components: Language

Versions: 11.0

Failure Type: Crash

Found In Build/Fixed In Build: CF11 update 13 /

Priority/Frequency: Normal / Unknown

Locale/System: ALL / Platforms All

Vote Count: 0

Problem Description:
The following code is erroring when being run from inside an event gateway.

expandPath( appMapping ) 

The value of the appMapping variable is "cbroot".  When I debug getAPplicationMetadata().mappings.keyList() it shows there is a mapping called "/cbroot" in existence.  

The error is:

An exception occurred while invoking an event handler method from Application.cfc. The method name is: onApplicationStart."
coldfusion.runtime.EventHandlerException: Event handler exception.
	at coldfusion.runtime.AppEventInvoker.onApplicationStart(
	at coldfusion.filter.ApplicationFilter.invoke(
	at coldfusion.filter.EventRequestMonitorFilter.invoke(
	at coldfusion.filter.MonitoringFilter.invoke(
	at coldfusion.filter.ClientScopePersistenceFilter.invoke(
	at coldfusion.filter.GlobalsFilter.invoke(
	at coldfusion.filter.DatasourceFilter.invoke(
	at coldfusion.eventgateway.EventProxy.invokeComponent(
	at coldfusion.eventgateway.EventProxy.invokeComponent(
	at coldfusion.eventgateway.EventRequestHandler.invokeCFC(
	at coldfusion.eventgateway.EventRequestHandler.processRequest(
	at coldfusion.eventgateway.EventRequestDispatcher$
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at coldfusion.util.Utils.expandPath(
	at coldfusion.runtime.CFPage.ExpandPath(
	at cfApplicationLoader2ecfc1888534889$funcLOADCONFIGURATION.runFunction(D:\wwwroot\coldbox\system\web\config\ApplicationLoader.cfc:103)



I figured out why this had worked initially, then stopped working. I deleted and re-created my event gateway and the path to my CFC used to be D:\wwwroot\cfc\BatchTransactionGateway.cfc but when I re-added the gateway, I used the "browse" button to find the file and it used this path (note the slashes are different!) D:/wwwroot/cfc/BatchTransactionGateway.cfc Something in expandPath() seems to be assuming that getBaseTemplatePath() will return slashes that match the local separator char.
Comment by Bradley W.
61 | March 15, 2018 03:36:56 AM GMT
Brad, I don't see expandPath( appMapping ) erroring out when I use it in an event gateway. I got as far as creating a server mapping and using in in a simple gateway. I see the output I expect, but no errors. I'll lay out what I did in an attempt to recreate the issue, here, for your benefit. I'm on CF2016.0.05.303689 / win7 x64 created server mapping: "/dummymap" that points to say, "C:/inetpub/" created and registered a directory watcher service (gateway CFC path in CF admin "C:/ColdFusion2016/cfusion/wwwroot/gw/imagewatcher.cfc") that simply outputs physical path of the mapping as follows: <cfcomponent> <cffunction name="onAdd" output="false" returnType="void"> <cfargument name="CFEvent" type="struct" required="true"> <cfdump var=#CFEvent# label="CFEvent-in-onAdd-debug" output="console"> <cfset appMapping = "/dummymap"> <cfdump var=#expandPath(appMapping)# label="exp-debug" output="console"> </cffunction> </cfcomponent> when I do whatever I do to invoke that method, it outputs the path (along with some other irrelevant details that I am omitting here for the sake of brevity) as : CFCMETHOD: onAdd ...... C:\inetpub I think I might be missing the bigger picture. So, could you pls. dwell a bit more on the application that's hitting "D:\wwwroot\coldbox\system\web\config\ApplicationLoader.cfc", which in turn is causing the StringIndexOutOfBounds exception.
Comment by Piyush K.
27523 | April 17, 2018 07:39:01 PM GMT
Brad, Can you pls check out my last comment and share the requested info.
Comment by Piyush K.
29459 | August 10, 2018 10:05:44 AM GMT
This issue was reported on CF11, not CF 2016. Did you test this on CF11? ApplicationLoader.cfc is part of the ColdBox framework but I don't think the context really matters, it's just an expandPath() call. I know with a high degree of certainty the slashes were being mishandled in CF11 but it's possible the issue was fixed in 2016.
Comment by Bradley W.
29466 | August 10, 2018 03:30:45 PM GMT
don't see this happening in CF11 either. To recap: win x64 / CF11 update14 the mapping as stored in my neo-runtime.xml file: <var name="/dummymap"> <string>C:\inetpub\cfdummy</string> </var> When I dump expand this mapping in an event handler in a gateway cfc, like so <cfset appMapping = "/dummymap"> <cfdump var=#expandPath(appMapping)# label="exp-debug" output="console"> I get "C:\inetpub\cfdummy" (details in my preceeding comment). I tried this with the gateway listener CFC path specified with forward and backward slashes.  
Comment by Piyush K.
29516 | August 16, 2018 02:01:21 PM GMT
Brad, closing this since the issue is not replicable and haven't heard back from you. If you need this revisited, drop a note here or write to me at 
Comment by Piyush K.
29644 | August 30, 2018 07:33:03 AM GMT