Class cast error for data.xmldata where expected type is a recored nested to an open record
Opened this issue · 0 comments
prakanth97 commented
Description:
import ballerina/io;
import ballerina/data.xmldata;
public function main() returns error? {
string xmlStr = string `
<Data>
<field2>
<str2>2</str2>
<str1>1</str1>
</field2>
</Data>
`;
record {|
record {
string str1;
} field2;
|} rec = check xmldata:parseString(xmlStr);
io:println(rec.field2.str1 is string);
}
This give below runtime error
Running executable
[2024-06-25 17:39:38,961] SEVERE {b7a.log.crash} - class java.lang.Long cannot be cast to class io.ballerina.runtime.api.values.BString (java.lang.Long is in module java.base of loader 'bootstrap'; io.ballerina.runtime.api.values.BString is in unnamed module of loader 'app')
java.lang.ClassCastException: class java.lang.Long cannot be cast to class io.ballerina.runtime.api.values.BString (java.lang.Long is in module java.base of loader 'bootstrap'; io.ballerina.runtime.api.values.BString is in unnamed module of loader 'app')
at io.ballerina.runtime.internal.values.MapValueImpl.getStringValue(MapValueImpl.java:156)
at prakanth.test_xmldata.0.main.main(main.bal:18)
at prakanth.test_xmldata.0.$_init.$moduleExecute(test_xmldata)
at prakanth.test_xmldata.0.$_init.$lambda$$moduleExecute$(test_xmldata)
at io.ballerina.runtime.internal.scheduling.SchedulerItem.execute(SchedulerItem.java:54)
at io.ballerina.runtime.internal.scheduling.Scheduler.run(Scheduler.java:320)
at io.ballerina.runtime.internal.scheduling.Scheduler.runSafely(Scheduler.java:287)
at java.base/java.lang.Thread.run(Thread.java:833)
Steps to reproduce:
Affected Versions:
OS, DB, other environment details and versions:
Related Issues (optional):
Suggested Labels (optional):
Suggested Assignees (optional):