Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class cast error for data.xmldata where expected type is a recored nested to an open record #6659

Closed
prakanth97 opened this issue Jun 25, 2024 · 1 comment · Fixed by ballerina-platform/module-ballerina-data.xmldata#26

Comments

@prakanth97
Copy link
Contributor

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):

Copy link

github-actions bot commented Aug 2, 2024

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
1 participant