Skip to content

[TECHNICAL] Resource leak in CopyAndUploadContentUrisTask #4806

Merged
jesmrec merged 2 commits intoowncloud:masterfrom
dataCenter430:technical/copy-and-upload-content-uris-resource-leak
Mar 20, 2026
Merged

[TECHNICAL] Resource leak in CopyAndUploadContentUrisTask #4806
jesmrec merged 2 commits intoowncloud:masterfrom
dataCenter430:technical/copy-and-upload-content-uris-resource-leak

Conversation

@dataCenter430
Copy link
Contributor

…UrisTask

Related Issues

Fixes #4797

Summary

Fixes a resource leak in CopyAndUploadContentUrisTask reported in #4797.

Problem

In the loop over URIs (lines 147–182), inputStream and outputStream were reassigned every iteration but never closed inside the loop. Only the last iteration’s streams were closed in the outer finally block, so all previous streams were leaked (file descriptors and memory).

Solution

  • Use try-with-resources inside the loop so each iteration opens and closes its own InputStream and FileOutputStream.
  • Remove the outer inputStream/outputStream variables and the stream-closing logic from the outer finally block.

Each URI’s streams are now closed at the end of that iteration (normal or exceptional), so no streams are leaked.

  • Add changelog files for the fixed issues in folder changelog/unreleased. More info here

@dataCenter430 dataCenter430 force-pushed the technical/copy-and-upload-content-uris-resource-leak branch from d1b1561 to bcfe14e Compare March 16, 2026 05:14
@dataCenter430
Copy link
Contributor Author

Hi, @joragua
Sorry for the late PR.
I really appreciate your review with this.
Thank you

@dataCenter430 dataCenter430 changed the title fix: Resource leak in CopyAndUploadContentUrisTask [TECHNICAL] Resource leak in CopyAndUploadContentUrisTask Mar 16, 2026
@joragua
Copy link
Collaborator

joragua commented Mar 16, 2026

Thanks for your contribution @dataCenter430! 💯 I'll check this PR as soon as possible

@dataCenter430
Copy link
Contributor Author

Hi, @joragua
Sorry to ping you, are there any updates yet?
Thank you.

Copy link
Collaborator

@joragua joragua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two comments and it's ready @dataCenter430! 👍🏻

@dataCenter430 dataCenter430 force-pushed the technical/copy-and-upload-content-uris-resource-leak branch from bcfe14e to 74b74aa Compare March 19, 2026 12:50
@dataCenter430 dataCenter430 requested a review from joragua March 19, 2026 12:51
@dataCenter430
Copy link
Contributor Author

Thanks for your review, 👍 @joragua
Could you please review it and let me know any feedback?

Copy link
Collaborator

@joragua joragua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Let's check that nothing is broken with the changes 🚀

@jesmrec
Copy link
Collaborator

jesmrec commented Mar 20, 2026

Just realised one tiny detail: in the changelog file, you defined it as a Bugfix . It's not really a bugfix because the previous behaviour was correct (even when the new one is better 😄 ). Would you mind to set it as Change ? we think, Change matches better.

After re-checking every kind of involved upload (manual, from camera, external, doc provider, external doc), no problem was found. So, it is approved on my side 💯

@dataCenter430 could you perform the change in the calens file and rebase the branch, to be merged? Thanks for your patience!!

@dataCenter430 dataCenter430 force-pushed the technical/copy-and-upload-content-uris-resource-leak branch from 74b74aa to 59924d7 Compare March 20, 2026 11:17
@dataCenter430
Copy link
Contributor Author

Hi, @jesmrec thanks for your review.
I've rebased the branch, are you able to check it?
Thank you

@jesmrec
Copy link
Collaborator

jesmrec commented Mar 20, 2026

I've rebased the branch, are you able to check it?

i checked it, but i realised you merged master into this branch (not the same as rebase). We try to avoid merge commits to keep the history clean and clear. Could you remove the merge commit and rebase the branch? let us know if you need any help.

@dataCenter430 dataCenter430 force-pushed the technical/copy-and-upload-content-uris-resource-leak branch from 6c2dfa6 to 62c1f88 Compare March 20, 2026 11:59
Made-with: Cursor
@dataCenter430 dataCenter430 force-pushed the technical/copy-and-upload-content-uris-resource-leak branch from 62c1f88 to 9fe453a Compare March 20, 2026 12:03
@dataCenter430
Copy link
Contributor Author

dataCenter430 commented Mar 20, 2026

It looks like to be done, no conflict, no error
Thank you again, @jesmrec 👍

@jesmrec
Copy link
Collaborator

jesmrec commented Mar 20, 2026

Thanks to you for your engagement @dataCenter430. Merging... it will be included in 4.8.0

@jesmrec jesmrec merged commit ff6802d into owncloud:master Mar 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TECHNICAL] Resource leak in CopyAndUploadContentUrisTask.java

3 participants