Add auto close for AsyncResultSingle and test#125
Conversation
Signed-off-by: Rb Krishna <krishnarb3@gmail.com>
|
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 krishnarb3@gmail.com