Skip to content
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

[JENKINS-60916] Revert try-with-resources for S3GzipCallable #127

Merged
merged 3 commits into from
Oct 15, 2021

Conversation

MMeent
Copy link

@MMeent MMeent commented Mar 3, 2020

This would close the InputStream prematurely, failing on the scheduled uploads who expected an open stream.

Note that as the upload continues after the return, therefore the zip-stream must not (yet) be closed in this context.

Fixes JENKINS-60916

MMeent added 3 commits March 3, 2020 21:38
This would close the InputStream prematurely, failing on the scheduled uploads who expected an open stream.

Note that as the upload continues after the return, therefore the zip-stream must not (yet) be closed in this context.

Fixes JENKINS-60916
@MMeent MMeent changed the title Revert try-with-resources for S3GzipCallable Revert try-with-resources for S3GzipCallable, fixing JENKINS-60916 Mar 4, 2020
pwielgolaski referenced this pull request Apr 30, 2020
General update and cleaning.
// so we cannot use its AutoCloseable behaviour with a
// try-with-resources statement, as that would likely
// close the stream before the upload has succeeded.
final InputStream gzippedStream = new FileInputStream(localFile);
Copy link

Choose a reason for hiding this comment

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

Is startUploading closing it later?

Copy link
Author

Choose a reason for hiding this comment

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

I do not know this with certainty, but as it is an async stream acceptor, I do believe that it at least should accept ownership of the stream, and thus close it when appropriate, and thus not be incorrect usage here. The current usage of the API is (AFAICS) no different from how it is used in the non-gzipped variant in https://github.com/jenkinsci/s3-plugin/blob/master/src/main/java/hudson/plugins/s3/callable/S3UploadCallable.java#L25

Copy link

Choose a reason for hiding this comment

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

I'm fine with reverting if the current behavior is not working, but I think it should be investigated whether a leak is happening and fix it.

Copy link
Author

Choose a reason for hiding this comment

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

Seems like the stream is being closed after upload:

Uploads.getInstance() returns an Uploads, which closes the passed inputstream after completion here

Unless my static analisys is incorrect, this stream will be closed once passed to Uploads#startUploading

Copy link

Choose a reason for hiding this comment

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

Great, thanks for taking the time to validate it!

@MMeent
Copy link
Author

MMeent commented Jan 26, 2021

@alecharp @timja

Could any of you please look at the other open bugfix-MRs and try to release one more bugfix-release? It's nice that v0.11.6 fixes some issues with regards to styling, but without zipped uploads (broken in v0.11.3+) I can't upgrade.

@timja
Copy link
Member

timja commented Jan 26, 2021

I'm not a maintainer here

@MMeent
Copy link
Author

MMeent commented Jan 26, 2021

I pinged you as you are one of the 2 ping-able committers of the last release; so my excuses for this incorrect ping.

@pwielgolaski
Copy link

pwielgolaski commented Sep 19, 2021

@alecharp any luck to get this merged?

@rsandell rsandell changed the title Revert try-with-resources for S3GzipCallable, fixing JENKINS-60916 [JENKINS-60916] Revert try-with-resources for S3GzipCallable Oct 15, 2021
@rsandell rsandell added the bug label Oct 15, 2021
@rsandell rsandell merged commit c5f2238 into jenkinsci:master Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants