Skip to content

OAK-12062 : fixed NPE while uploading metadata for AWS S3#2688

Merged
rishabhdaim merged 2 commits intotrunkfrom
OAK-12062
Jan 21, 2026
Merged

OAK-12062 : fixed NPE while uploading metadata for AWS S3#2688
rishabhdaim merged 2 commits intotrunkfrom
OAK-12062

Conversation

@rishabhdaim
Copy link
Copy Markdown
Contributor

No description provided.

@rishabhdaim rishabhdaim self-assigned this Jan 19, 2026
@reschke
Copy link
Copy Markdown
Contributor

reschke commented Jan 19, 2026

I'm a bit concerned that we have an File leak; deleteOnExit() will not be sufficient unless the VM really terminates.

Deleting the File after use should be sufficient.

tempFile.deleteOnExit(); // Clean up after JVM exits
// we have to read all the stream to get the actual length
// last else block: store to temp file and re-read
final File tempFile = File.createTempFile("inputstream-", ".tmp");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Prefix should show which class created the temp file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed in 8f64b8a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How is it addressed? I do not see where "delete()" is called. It is still only calling "deleteOnExit()", which will not delete immediately.

// we have to read all the stream to get the actual length
// last else block: store to temp file and re-read
final File tempFile = File.createTempFile("inputstream-", ".tmp");
tempFile.deleteOnExit(); // Clean up after JVM exits
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will delete on exit, but not delete after reading. I would delete after reading as well, so that in the normal case (where the process is not killed) the file is deleted. Otherwise we might have a large number of temp files, if the process is not terminated for a long time.

(This could cause out-of-disk space, and if the number of files is huge, also out-of-memory in kubernetes)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed in 8f64b8a

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@rishabhdaim rishabhdaim merged commit 50e1040 into trunk Jan 21, 2026
3 of 4 checks passed
@rishabhdaim rishabhdaim deleted the OAK-12062 branch January 21, 2026 10:42
rishabhdaim added a commit that referenced this pull request Jan 27, 2026
* OAK-12062 : fixed NPE while uploading metadata for AWS S3

* OAK-12062 : removed temp file in finally method
rishabhdaim added a commit that referenced this pull request Jan 29, 2026
)

* OAK-12062 : fixed NPE while uploading metadata for AWS S3 (#2688)

* OAK-12062 : fixed NPE while uploading metadata for AWS S3

* OAK-12062 : removed temp file in finally method

* OAK-12062 : removed unnecessary comment
reschke pushed a commit that referenced this pull request Feb 15, 2026
* OAK-12062 : fixed NPE while uploading metadata for AWS S3

* OAK-12062 : removed temp file in finally method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants