-
Notifications
You must be signed in to change notification settings - Fork 736
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
Singlethons populated inside GeneratorTask is inaccessible from CompilerLifecycleTask #34296
Comments
@xlight05 I tested this with a simple Singleton class with Beta.6 RC2 pack but didn't encounter any issues. Here is the scenario I tried:
The source code of the plugin and the Singleton can be found here: https://gist.github.com/azinneera/2288815f83fe2e8b03cd762f7047c6fe This is the output I got:
I dont see any issues in the functionality of the singleton. Please let us know if your scenario is different |
The above was tested with an in-built compiler plugin. Was able to reproduce the issue with a package-provided compiler plugin. |
This is the expected behavior since the classloaders are different for the analysis and lifecycle phases. The suggested approach to pass information is to persist to the target/ directory and access it. |
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. |
Description:
In Azure functions and AWS Lambda functions modules, we generate the source file inside GeneratorTask class. We use the same data model inside CompilerLifecycleTask phase so we store it in a singlethon class as a cache. For some reason in latest pack, Singlethon class seems to be empty when CompilerLifecycleTask phase is reached.
Steps to reproduce:
https://github.com/xlight05/module-ballerinax-azure.functions/tree/stripped-ext
you can make the pack by executing ./gradlew clean build . It'll be created in /azurefunctions-extension-bala azurefunctions-extension-bala/build/extracted-distribution.
Test case is available at azurefunctions-extension-test/src/test/resources/deployment
You can do BAL_JAVA_DEBUG=5005 /azurefunctions-extension-bala/build/extracted-distribution/jballerina-tools-2.0.0-beta.6-20211211-193900-8a474932/bin/bal build
to debug.
extension source- , azurefunctions-extension
You can observe the value of TestSinglethon using the above sample.
Affected Versions:
OS, DB, other environment details and versions:
Related Issues (optional):
Suggested Labels (optional):
Suggested Assignees (optional):
The text was updated successfully, but these errors were encountered: