Fixed
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Brad Wood
Brad WoodPriority
Labels
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Created 5 January 2022 at 22:28
Updated 19 January 2022 at 00:37
Resolved 19 January 2022 at 00:37
I came across this issue on some client code which was calling duplicate() on a CFC instance. I have no idea what specific nested Map was being created at the time as the stack trace is generic, but a review of the code reveals the programming error.
lucee.runtime.exp.NativeException: class java.lang.NoSuchMethodException cannot be cast to class java.util.Map (java.lang.NoSuchMethodException and java.util.Map are in module java.base of loader 'bootstrap') at lucee.runtime.op.Duplicator.duplicateMap(Duplicator.java:212) at lucee.runtime.op.Duplicator.duplicate(Duplicator.java:135) at lucee.runtime.type.StructImpl.copy(StructImpl.java:242) at lucee.runtime.type.StructImpl.duplicate(StructImpl.java:230) at lucee.runtime.op.Duplicator.duplicate(Duplicator.java:131) at lucee.runtime.ComponentImpl.duplicateDataMember(ComponentImpl.java:335) at lucee.runtime.ComponentImpl._duplicate(ComponentImpl.java:253) at lucee.runtime.ComponentImpl._duplicate(ComponentImpl.java:239) at lucee.runtime.ComponentImpl.duplicate(ComponentImpl.java:211) at lucee.runtime.op.Duplicator.duplicate(Duplicator.java:131)
You can see an instance of java.lang.NoSuchMethodException was trying to be cast to a Map, which of course won't work. The problem is here:
https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/commons/lang/ClassUtil.java#L403
That code path incorrectly RETURNS the exception object instead of THROWING it. The calling code naturally expects it will only get an instance of a Map back (or an exception raised)
https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/runtime/op/Duplicator.java#L212
But when the ClassUtil returns an exception instead of throwing it, it gives a casting error.
This change was made in Oct 2020 for 5.3.8.86-SNAPSHOT as part of this commit:
https://github.com/lucee/Lucee/commit/61df63d8edf198873a0b03056333a52f25dd3fc1
though I don't see an associated ticket for the commit.
I believe the fix is to replace this line
return ce;
with this
throw ce;