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

[Bug]: MockDesugar throws NPE with legacy function mocking #40731

Closed
Dilhasha opened this issue Jun 16, 2023 · 2 comments · Fixed by #41686
Closed

[Bug]: MockDesugar throws NPE with legacy function mocking #40731

Dilhasha opened this issue Jun 16, 2023 · 2 comments · Fixed by #41686
Assignees
Labels
Area/TestFramework Priority/High Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Bug

Comments

@Dilhasha
Copy link
Contributor

Description

When using legacy function mocking to mock a function in another module, for a multi-module project, it results in an NPE when trying to find the function to be mocked in MockDesugar level.

Steps to Reproduce

[2023-06-16 13:47:29,269] SEVERE {b7a.log.crash} - null 
java.lang.NullPointerException
        at org.wso2.ballerinalang.compiler.desugar.MockDesugar.getInvokableSymbol(MockDesugar.java:214)
        at org.wso2.ballerinalang.compiler.desugar.MockDesugar.getImportFunction(MockDesugar.java:196)
        at org.wso2.ballerinalang.compiler.desugar.MockDesugar.generateMockFunction(MockDesugar.java:159)
        at org.wso2.ballerinalang.compiler.desugar.MockDesugar.generateMockFunctions(MockDesugar.java:131)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:774)

Affected Version(s)

2201.6.0

OS, DB, other environment details and versions

No response

Related area

-> Test Framework

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Area/TestFramework labels Jun 16, 2023
@Dilhasha
Copy link
Contributor Author

Dilhasha commented Oct 5, 2023

If we add the import dilhashanazeer/app1.dao as a null import, the issue gets resolved.
We need to handle the NPE to provide a meaningful error.

Copy link

github-actions bot commented Dec 4, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/TestFramework Priority/High Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants