Lucee 6 upgrade issue - StructSort

We are working on upgrading to Lucee 6 (6.0.3.1) and have come across a few compatibility issues. We’ve been able to work around all of them so far but figured we’d post them here in case there is interest in fixing them up.

We have a scenario where an object is loaded via the ORM, items are extracted into a struct, and that struct is then sorted on a sql datetime (java.sql.Timestamp) field. The code below simulates the error. On lucee 5 this is successful but on lucee 6 it errors with something like:

Can’t cast Object type [java.sql.Timestamp] to a value of type [number]

Our workaround was to add a numeric key to the struct to sort on.

<cfscript>
javaTimestamp = CreateObject("java", "java.sql.Timestamp");
time1 = javaTimestamp.valueOf("2024-06-20 12:34:56.789");
time2 = javaTimestamp.valueOf("2024-06-20 14:34:56.789");

testStruct = {};
testStruct[1] = { sortme = time1 };
testStruct[2] = { sortme = time2 };

sorted = StructSort(testStruct, 'numeric', 'desc', 'sortme');
writeDump(sorted);
</cfscript>