Skip to content

[TECHNICAL] Stream handling and double-close in UploadFileFromContentUriWorker #4798

Description

@dataCenter430

In copyFileToLocalStorage(), streams are not closed safely and the output stream is closed twice.

  • Double-close: outputStream is closed inside outputStream.use { ... }, then outputStream.close() is called again. The second close is redundant and can cause issues.
  • Leak on error: inputStream is not used inside a use block. If inputStream?.copyTo(fileOut) throws, the input stream is never closed.

Suggested fix: Use inputStream?.use { it.copyTo(fileOut) } so the input stream is always closed, and remove the explicit inputStream?.close() and outputStream.close() calls so only use is responsible for closing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions