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
Use a proxy based Stream decorator to support close on terminal #4015
Conversation
Thanks for your pull request! This pull request does not follow the contribution rules. Could you have a look? ❌ The PR title or body should list the keys of all JIRA issues mentioned in the commits › This message was automatically generated. |
You need to create testing case(s) to show case:
Without such proof, there is pretty slim chance to be approved or even reviewed, unless it is trivial. Seems good testing case is straightforward for this ticket. Please refer to existing testing cases when creating your own. Please try to ensure your CI building is green and solve any issue preventing it. |
I think the test BasicStreamTest and JpaStreamTest is enough for this. And without |
A little bit confused. It seems the existing testing cases didn't cover the bug that close would be called multiple times. If I didn't misunderstand, you are trying to solve the issue via redesigning. IMHO it would be a good testing case to expose the duplicated closing issue and you can demo that your approach makes the testing case green. |
You can refer #4011. #3834 only solved that when My two pull requests are focus on calling the And I think that And I remove the field |
I think to solve this, the conservative way is to merge #4011 and the aggressive way is to merge this. |
TBH, I am confused by the two PRs: which one to review? Both? That seems a little bit ambitious. As I've said, you need at least a compelling testing case in your #4011 to have it merged. I would suggest your choosing one of them as the solution. Regardless of which one to choose, ideally a compelling testing case is expected to expose the issue you are trying to solve. |
You say you want an aggressive way to solve this. I provided it here. But I think the conservative way in #4011 is also enough to solve the same problems. #4011 is safer than this but a little dirty and redundant, and not well handling the methods added in JDK above 8 like Either of the two can be merged. That leaves to you to leverage. Which way you like. I can create a test to expose the issue I mentioned. But after I delete the field |
I think it is still testable from external behaviour which should not be bound to internal implementation detail. Not 100% sure about its feasibility but naturally without good testing case such aggressive refactoring is difficult to convince. |
Please inspire me on how to do it, and I will do it. |
I agree the old PR is not elegant and attractive. I think we can close it
and focus on this one. Definitively we can create a good testing case for
it to prove that the delegate stream is only closed once. I don't have
enough bandwidth to help on this but I do think it is doable.
…On Thu, May 27, 2021 at 10:11 PM MoonFruit ***@***.***> wrote:
Please inspire me on how to do it, and I will do it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4015 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6UYAT5DIQ7QUA5FOHY5IDTP33VJANCNFSM45T5CPDA>
.
|
Personally I am very intrigued by this ticket. Tomorrow I might take a look
at it and explore on testing possibility, but I cannot guarantee my
availability.
On Thu., May 27, 2021, 11:05 p.m. Nathan Xu, ***@***.***>
wrote:
… I agree the old PR is not elegant and attractive. I think we can close it
and focus on this one. Definitively we can create a good testing case for
it to prove that the delegate stream is only closed once. I don't have
enough bandwidth to help on this but I do think it is doable.
On Thu, May 27, 2021 at 10:11 PM MoonFruit ***@***.***>
wrote:
> Please inspire me on how to do it, and I will do it.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#4015 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AB6UYAT5DIQ7QUA5FOHY5IDTP33VJANCNFSM45T5CPDA>
> .
>
|
Add test for the basic functions of |
I like the approach of #4011 more so I'm inclined to close this PR. |
Very interesting, but we should also look at how this impacts compatibility with GraalVM native images. proxies aren't easy to configure there. |
@Sanne, I refactor function I don't know how to run tests on graalvm native images, but I test it in a standalone program, it worked. |
9a26336
to
9f9a6b8
Compare
hi @moonfruit - apologies I forgot about this one. Again - it looks interesting but I really need to check how this could work in GraalVM; since I'm not expecting to find time in 10 more days I'll see if I can find another team mate to help with that. |
According to GraalVM DynamicProxy Automatic Detection, this implementation should work on GraalVM native image. Maybe we should introduce GraalVM native image unit test like this. |
Yes introducing a module for GraalVM specific integration tests would really help. We even have a |
The Stream API explicitly says that streams should be closed by the user if they involve IO, so IMO we should drop all decorators and just register the onClose handler on the JDK stream. |
For #4011, here provide a redesign for
Stream
decorator that supports close on terminal.Inspired by https://rmannibucau.metawerx.net/post/java-stream-decorator.
@NathanQingyangXu @vladmihalcea