-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add auto close for AsyncResultSingle and test #125
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Rb Krishna <[email protected]>
I think this code does not achieve the desired effect and the only way to achieve it is to consider it from the perspective of the Single we return in the generated code. The
and to have this code, we would need when we generate the code to know that the returned type implements |
So put another way : I don't think we can implement it in |
So first I'm wondering if we can today detect at generation time (in templates) that the type of a single extends AutoCloseable |
Since we are closing when the single is disposed, the closing would still happen even if the stream does not terminate.. For example:
On executing this program the formatter object is closed properly, inspite of the stream not getting terminated. Please do correct me if I interpreted your comment the wrong way. I understand this method would work only when the type is known, can you elaborate on how to detect at generation time (in templates) that the type of a single extends AutoCloseable ? |
the user case is more for single than streams (although it's not exclusive). for compile time, the codegen project should support it in |
Sorry, I'm a bit stuck here: When I add the boolean autoCloseable to ApiTypeInfo and as a constructor parameter, how should I check if the type implements AutoCloseable (Using Reflection perhaps?) in the files TypeReflectionFactory and TypeMirrorFactory which use the constructor? |
check at how the same is achieved for the readStream / writeStream booleans |
Fixes #122
Signed-off-by: Rb Krishna [email protected]