tracker issue : CF-4076717

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

Function listToArray() produces different output on JRE 1.7 and 1.8

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Bla Foo / Bla Foo (Bla Foo)

Created: 10/20/2015

Components: Language, Functions

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: German / Win 2012 Server x64

Vote Count: 0

Listed in the version 2016.0.0.297996 Issues Fixed doc
Verification notes: verified_fixed on August 22, 2019 using build 2016.0.01.298513
Problem Description:
The function listToArray() with no delimiter ("") does not return the same array on JRE 1.7 and 1.8. At least since ColdFusion 8 (and JRE 1.6 I guess) the function listToArray() returned an array which has a length of arrayLen(text)+2, because it added an empty string to the beginning and ending of the array.

Steps to Reproduce:
<cfset arr = listToArray("abc", "", true)>

Actual Result:
The variable "arr" is an array with the following entries: ["a","b","c",""]

Expected Result:
The variable "arr" should be an array with the following entries: ["","a","b","c",""]
Or, but not preffered because it's not the same result like in older ColdFusion versions, this array:  ["a","b","c"]

Any Workarounds:
<cfif arr[1] neq "">
	<cfset arrayPrepend(arr, "")>
</cfif>

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4076717

External Customer Info:
External Company:  
External Customer Name: Bla Bla
External Customer Email:  
External Test Config: My Hardware and Environment details:

ColdFusion Standard Edition 11 Update 6 with JRE 1.7.0_80 and 1.8.0_60

Attachments:

Comments:

For clarification: The actual result is with JRE 1.8 and the expected result is what you got on JRE 1.7 and older.
Comment by External U.
5516 | October 20, 2015 07:37:20 AM GMT
I would argue that any behavior that puts in empty string values in the resulting array is a bug - but, Railo 4.2 and Lucee 4.5 appear to also add the empty strings at both ends of the array. So i agree that at least the existing behavior in ColdFusion should be consistent across JVM versions.
Comment by External U.
5517 | October 21, 2015 08:59:32 AM GMT
This was a regression, fixed it. Regression was because of change in behavior in Java version 8 functionality. To support backward compatibility in CF, added a special fix for that. It will work as expected now, will add empty string at first array index. <cfset arr = listToArray("abc", "", true)> result: ["","a","b","c",""]
Comment by Milan C.
5518 | October 30, 2015 01:52:03 AM GMT
Hi Adobe, I've verified this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
31142 | August 22, 2019 08:22:49 AM GMT