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

Make Jsii Thread Safe #4311

Open
2 tasks
fahhas-aws opened this issue Oct 26, 2023 · 0 comments
Open
2 tasks

Make Jsii Thread Safe #4311

fahhas-aws opened this issue Oct 26, 2023 · 0 comments
Labels
feature-request A feature should be added or improved. p2

Comments

@fahhas-aws
Copy link

fahhas-aws commented Oct 26, 2023

Describe the feature

Hello,

The Jsii Library is not thread safe. This has been confirmed several times using the CDK library in java. When attempting to build CDK templates in more than one thread, you are greeted with this error.

Exception in thread "Thread-1" software.amazon.jsii.JsiiException: Malformed object reference. Expecting $jsii.byref at software.amazon.jsii.JsiiObjectRef.parse(JsiiObjectRef.java:52) at software.amazon.jsii.JsiiClient.createObject(JsiiClient.java:91) at software.amazon.jsii.JsiiEngine.createNewObject(JsiiEngine.java:458)

The current workaround is to synchronize requests via a lock in Java when performing any actions with CDK.

Please update jsii to be thread safe.

Use Case

Attempting to build CloudFormation templates in more than one thread by leveraging CDK with Java.

Proposed Solution

There seems to be a static singleton of the JsiiEngine instance that is used to build constructs in CDK - regardless of what app is using it. Instead of JsiiEngine.getInstance() this could instead be new JsiiEngine(..) that could be used by an app object upon its creation.

Would investigate in updating all statically called methods that reference any jsii related objects to instead be standard object -> method calls instead.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

v2.103.0

Environment details (OS name and version, etc.)

Mac OS Ventura

@fahhas-aws fahhas-aws added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 26, 2023
@mrgrain mrgrain added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants