-
Notifications
You must be signed in to change notification settings - Fork 153
Conversation
Codecov Report
@@ Coverage Diff @@
## master #865 +/- ##
============================================
+ Coverage 48.28% 48.31% +0.02%
- Complexity 1641 1644 +3
============================================
Files 195 195
Lines 10394 10413 +19
Branches 751 753 +2
============================================
+ Hits 5019 5031 +12
- Misses 5018 5024 +6
- Partials 357 358 +1
Continue to review full report at Codecov.
|
@getodk/briefcase |
Thank you so much for taking this on, @timkoon, and sorry about the radio silence! I am unfortunately not very familiar with this code. One thing that I've been wanting to verify is that it indeed is necessary to keep track of all streams and close them all at once at the end. Did you verify that the streams are indeed still open at that point? I would have expected the methods in RequestBuilder at
Request.body that never gets closed?
|
src/org/opendatakit/briefcase/push/aggregate/PushToAggregate.java
Outdated
Show resolved
Hide resolved
src/org/opendatakit/briefcase/push/aggregate/PushToAggregate.java
Outdated
Show resolved
Hide resolved
src/org/opendatakit/briefcase/reused/transfer/AggregateServer.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me, although I have some reservations about making the server class aware of the file streams that some of its requests open. While I believe this alleviates the original issue, I think this should be something that the Request
should provide instead of the server, along the lines of "file resources opened by this request" so that the HTTP client can close them automatically once the request is sent.
Having said that, I think this doesn't block the release of this PR, although I would consider opening a new PR to address the design improvements I've mentioned above.
I'm also missing tests for this change, which would be nice to have.
Codecov Report
@@ Coverage Diff @@
## master #865 +/- ##
============================================
+ Coverage 48.33% 48.36% +0.03%
- Complexity 1647 1648 +1
============================================
Files 195 195
Lines 10422 10438 +16
Branches 753 754 +1
============================================
+ Hits 5037 5048 +11
- Misses 5026 5030 +4
- Partials 359 360 +1
Continue to review full report at Codecov.
|
Hi @lognaturel and no problem! In regards to pointing out the line in the RequestBuilder, I would think that approach is optimal when it comes to attachments in the request, but attachments in the request object are actually using Here is where I found Aggregate server is calling that static method:
I haven't verified that the InputStreams are still open while the application is running, but that could possibly be done in an integration test. I did include unit tests to verify Java InputStreams are working as expected, and that @ggalmazor Thanks for your review and suggestion. I do like your suggestion of making the Client handle closing InputStreams rather than the Server. After reviewing the flow again, I found the Request is already tracking the attachments and InputStreams. I reverted the previous fix and implemented changes in the new commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great improvement to me, @timkoon! It's now very clear which streams could be left open. The change feels nicely targeted and tested.
I'll give @ggalmazor a little bit in case he has comments too.
(Apologies! will have some cycles for this during the weekend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for considering my suggestions. I think the implementation is ready, but I've seen some things in the new test class that should be addressed, so I'm requesting some changes there. Feel free to ping me anytime if you think I could help you with that ;)
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
test/java/org/opendatakit/briefcase/reused/UncheckedFilesTest.java
Outdated
Show resolved
Hide resolved
@ggalmazor Do you have a chance to review the updates? |
Thanks so much for thoughtfully addressing the review feedback, @timkoon, and for the ping on this. I'm very happy with this as-is and would like to merge. @ggalmazor I can't seem to do so without your approval, though! |
test/java/org/opendatakit/briefcase/reused/UncheckedFilesInputStreamTest.java
Outdated
Show resolved
Hide resolved
src/org/opendatakit/briefcase/push/aggregate/PushToAggregate.java
Outdated
Show resolved
Hide resolved
src/org/opendatakit/briefcase/push/aggregate/PushToAggregate.java
Outdated
Show resolved
Hide resolved
src/org/opendatakit/briefcase/push/aggregate/PushToAggregate.java
Outdated
Show resolved
Hide resolved
I went ahead and change some small details that I think we should really have before merging in order to be consistent with the previous code and simplify it as much as possible.
… it's not present
Codecov Report
@@ Coverage Diff @@
## master #865 +/- ##
============================================
+ Coverage 48.33% 48.35% +0.02%
- Complexity 1647 1649 +2
============================================
Files 195 195
Lines 10422 10435 +13
Branches 753 754 +1
============================================
+ Hits 5037 5046 +9
- Misses 5026 5029 +3
- Partials 359 360 +1
Continue to review full report at Codecov.
|
Hi, @timkoon, @lognaturel! MEGA Apologies for the delay in this review. This is not how I like to do things, and I hope you can forgive me. This PR solves the issue at hand but I think there were a couple of small things we needed to change to align the changes with previous code and make it a smidge simpler if possible. I've gone ahead and applied the changes myself to avoid delaying the PR anymore. I hope you understand. Other than that: LGTM! |
Thanks both so much! And again, really appreciate your patience, @timkoon. Briefcase v1.18.0 is now out with this fix. 🎉 https://forum.getodk.org/t/odk-briefcase-v1-18/31039 |
Closes #848
What has been done to verify that this works as intended?
Code complies, all tests pass, and application runs.
Why is this the best possible solution? Were any other approaches considered?
As discussed in the issue, closing the InputStreams after we received the response will help to reduce the number of files opened during a large number of submissions or attachments.
Other approaches were thought of, but would require more re-work/refactoring of existing functionality, where this current solution fits in line with how the code is organized and utilizes InputStreams from the class UncheckedFiles.
I attempted to update and refactor CentralServer using the similar closeInputStream method, but ran into 3 failing unit tests. Code can be found here: poketim@915e262
That change may be verified in a separate pull request as issue 848 just references AggregateServer.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
The changes should reduce the errors regarding too many files opened. There shouldn't be other impacts to a user's experience. As a note, after the PushToAggregate operation receives a response, it now does some cleaning up (closing input streams and clearing the tracked streams opened).
Does this change require updates to documentation? If so, please file an issue at https://github.com/opendatakit/docs/issues/new and include the link below.
I don't believe so.