tracker issue : CF-4152769

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

Replace() fails if one of the strings is a number

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

Reporter/Name(from Bugbase): Ian Clark / Ian Clark (Ian Clark)

Created: 05/13/2016

Components: Functions

Versions: 2016

Failure Type: Crash

Found In Build/Fixed In Build: CF2016_Final /

Priority/Frequency: Critical / All users will encounter

Locale/System: English / Windows 10 64 bit

Vote Count: 0

Duplicate ID:	CF-4126411

Problem Description:I have a custom tag that creates a soundex value of a persons name. This tag has this code:
<CFIF IsDefined("attributes.stringtosoundex")>
	<CFSCRIPT>
		stringtoconvert = ucase(attributes.stringtosoundex);
		stclength = len(stringtoconvert);
		leader = left(stringtoconvert, 1);
		leadervalue = leader;
		body = right(stringtoconvert, stclength - 1);
		body = replacelist(body, "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z",  "0,1,2,3,0,1,2,0,0,2,2,4,5,5,0,1,2,6,2,3,0,1,0,2,0,2");
		leadervalue = replacelist(leadervalue, "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z", "0,1,2,3,0,1,2,0,0,2,2,4,5,5,0,1,2,6,2,3,0,1,0,2,0,2");
	</CFSCRIPT>
	
	<CFLOOP INDEX="counter" from="1" to="9">
		<CFSET DOUBLE = counter * 11>
		<CFSET BODY = replace(BODY, double, counter, "ALL")>
	</CFLOOP>
The CFSET Body fails with a java.lang.Double cannot be cast to java.lang.String error message (this code was developed around 2000 and has been working as is for 16 years.
Steps to Reproduce:
Create a test page with:
<cfset body="Any String12321">
<cfset str1=2>
<cfset str2=4>
<cfset BODY=replace(Body,Str1,Str2,"ALL")>


Actual Result:
Java error
Expected Result:
replace occurs.
Any Workarounds: yes. Need to add ToString() to both numbers.

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

Watson Bug ID:	4152769

External Customer Info:
External Company:  
External Customer Name: Ian Clark
External Customer Email:  
External Test Config: My Hardware and Environment details: Windows 10

Attachments:

  1. May 13, 2016 00:00:00: 1_soundex.cfm

Comments:

I have attached the complete custom tag
Comment by External U.
2816 | May 13, 2016 07:12:34 AM GMT
This issue is fixed in ColdFusion 2016 Update 1. Please apply Update 1 and check if the issue is resolved.
Comment by Nimit S.
2817 | May 16, 2016 01:47:38 AM GMT
I'll have to take your word on this. The only copy of 2016 I am currently running is on a Windows 10 laptop and the Hot fix will not install. I have tried through the Administrator, from the command line both with the GUI and in silent mode. None of them finish and when I restart cold fusion it is the original version!
Comment by External U.
2818 | May 16, 2016 07:20:25 AM GMT
Hi Ian, Can we join over a screen sharing session to look at the issue?
Comment by Anit K.
2819 | May 16, 2016 12:07:22 PM GMT
Thanks for the offer but I am at the SBA all week and my laptop does not have internet access there. At the moment it is not really an issue as I don't have any customers (other than the SBA) moving to 2016 yet and if they do it will not be on windows 10.
Comment by External U.
2820 | May 17, 2016 06:34:43 AM GMT
Anit, I tried again. This time I suspended the anti virus software and it worked. So I now have the patch and I can confirm that it fixed the issue I experienced with the replace function. Thanks, Ian
Comment by External U.
2821 | May 17, 2016 08:35:58 AM GMT