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

Issue when creating a BTable using ValueCreator #5739

Closed
dilanSachi opened this issue Nov 7, 2023 · 2 comments
Closed

Issue when creating a BTable using ValueCreator #5739

dilanSachi opened this issue Nov 7, 2023 · 2 comments
Labels

Comments

@dilanSachi
Copy link
Contributor

Description:
I have types defined as follows and a table as a field.

public type MQRFH2Field record {|
    readonly string folder;
    readonly string 'field;
    int|float|byte|byte[]|string value;
|};

public type MQRFH2 record {|
    table<MQRFH2Field> key(folder, 'field) fieldValues = table [];
|};

In the runtime, I'm trying to create a BTable fieldValues and populate it as follows.

BTable fieldTable = ValueCreator.createTableValue(TypeCreator.createTableType(TypeCreator.createRecordType("MQRFH2Field", getModule(), 0, false, 0), false));

BMap<BString, Object> field = ValueCreator.createRecordValue(getModule(), "MQRFH2Field");
field.put(StringUtils.fromString("folder"), StringUtils.fromString(folder.getName()));
field.put(StringUtils.fromString("field"), StringUtils.fromString(child.getName()));
field.put(StringUtils.fromString("value"), getBValueForMQObjectValue(child.getValue()));
fieldTable.add(field);

Then I pass it to the Ballerina side and when testing this, it ends with a exception. However, if I print the table, the values are there.

io:println(headers[0].fieldValues); --> [{"folder":"mcd","field":"Msd","value":"TestMcdValue"},{"folder":"jms","field":"Dlv","value":134}]
MQRFH2Field[] fieldArray = headers[0].fieldValues.toArray(); ----> LN 260 is this line.

error("java.lang.NullPointerException",message="Cannot invoke "io.ballerina.runtime.api.types.Type.isNilable()" because "memberType" is null")
                                callableName: toArray moduleName: ballerina.lang.table.0 fileName: table.bal lineNumber: 399
                                callableName: publishSubscribeWithHeadersTest moduleName: ballerinax.ibm.ibmmq$test.0.tests.topic_publisher_subscriber_tests fileName: tests/topic_publisher_subscriber_tests.bal lineNumber: 260

Related discord thread -> https://discord.com/channels/957996897782616114/1170261923946831922/1170261923946831922

Copy link

github-actions bot commented Nov 7, 2023

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.

@dilanSachi dilanSachi added the Reason/Invalid Issue is invalid. label Nov 7, 2023
@dilanSachi
Copy link
Contributor Author

Should be created in lang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant