-
Notifications
You must be signed in to change notification settings - Fork 252
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
FIX: Ensure Rack::Test::UploadedFile closes its tempfile file descriptor on GC #180
Merged
junaruga
merged 11 commits into
rack:master
from
bsodmike:fix/uploadedfile_close_file_descriptor
Jun 5, 2017
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7030e86
FIX: Ensure Rack::Test::UploadedFile closes its tempfile file descrip…
bsodmike b0665b6
FIX: Ensure an instance of UploadedFile is correctly returned
bsodmike 50a72f1
Nitpick: Changed single quotes to double for consistency
perlun 86c464c
Nitpick: Whitespace fix
perlun 476df61
FIX: Patch spec to support jRuby
bsodmike f7f291d
FIX: Change single quotes to double for consistency, again
bsodmike eed1a17
Merge branch 'master' into fix/uploadedfile_close_file_descriptor
bsodmike 82e7078
Merge branch 'master' into fix/uploadedfile_close_file_descriptor
bsodmike a69651d
FIX: Correct entry for IntelliJ IDEs as per review
bsodmike b28b644
FIX: Ensure descriptor is unlinked post close as per API doc recommen…
bsodmike 274e8e1
FIX: Update spec, do not specify Ruby version, only platform
bsodmike File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ VERSION | |
*.rbc | ||
*.swp | ||
/.bundle | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,12 @@ def test_file_path | |
File.dirname(__FILE__) + "/../../fixtures/foo.txt" | ||
end | ||
|
||
it "returns an instance of `Rack::Test::UploadedFile`" do | ||
uploaded_file = Rack::Test::UploadedFile.new(test_file_path) | ||
|
||
expect(uploaded_file).to be_a(Rack::Test::UploadedFile) | ||
end | ||
|
||
it "responds to things that Tempfile responds to" do | ||
uploaded_file = Rack::Test::UploadedFile.new(test_file_path) | ||
|
||
|
@@ -26,4 +32,29 @@ def test_file_path | |
|
||
expect(File.extname(uploaded_file.path)).to eq(".txt") | ||
end | ||
|
||
context "it should call its destructor" do | ||
it "calls the destructor" do | ||
expect(Rack::Test::UploadedFile).to receive(:actually_finalize).at_least(:once) | ||
|
||
if RUBY_PLATFORM == 'java' && RUBY_VERSION == '2.3.1' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current jruby-head 's Ruby version is 2.3.3. |
||
require 'java' | ||
java_import 'java.lang.System' | ||
|
||
20.times do |i| | ||
uploaded_file = Rack::Test::UploadedFile.new(test_file_path) | ||
|
||
uploaded_file = nil | ||
|
||
System.gc() | ||
end | ||
else | ||
uploaded_file = Rack::Test::UploadedFile.new(test_file_path) | ||
|
||
uploaded_file = nil | ||
|
||
GC.start | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How about this?
It looks more simple.
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.
Check this out mate, http://www.mikeperham.com/2010/02/24/the-trouble-with-ruby-finalizers/
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, I check it. and I learned that we have to use the static method.