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

refactor FileResource.inputStream to be easier to use #2271

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
2 participants
@mkristian
Copy link
Member

commented Dec 3, 2014

for any client code which needs to convert a uri-like path to an inputstream
the way to go is JRubyFile.create(runtime, path).inputStream()

the motivation for this PR comes from jruby-openssl-0.9.6.dev:

from the user there comes a String with path to a PEM resource. as it turns out this path can be any uri-like path (like from rubygems: https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/rubygems/request.rb#L42).

the following boilerplate code to convert a uri-like path into an input-stream:
jruby/jruby-openssl@aa51d9b#diff-67972a6a9364f41a90295ceabf0e9180R298
is a fix for jruby-1.7.16.1

this PR cleans up the API for such "conversion" and to release jruby-openssl with this clean API it needs a released jruby version with this PR merged.

@mkristian mkristian added this to the JRuby 1.7.17 milestone Dec 3, 2014

@mkristian mkristian added the openssl label Dec 3, 2014

@mkristian mkristian force-pushed the FileResource.inputStream branch from 18da34f to adb3a85 Dec 3, 2014

refactor FileResource.inputStream to be easier to use
for any client code which needs to convert a uri-like path to an inputstream
the way to go is ```JRubyFile.create(runtime, path).inputStream()```

@mkristian mkristian force-pushed the FileResource.inputStream branch from adb3a85 to 36e2ed4 Dec 3, 2014

/**
* opens input-stream to the underlying resource. this is place where
* the input-stream gets opened. users of this method should follow the pattern:
* close the stream where you open it.

This comment has been minimized.

Copy link
@ratnikov

ratnikov Dec 3, 2014

Contributor

I'd keep rationale for closing (implementations allocating native memory) in the new comment.

@@ -235,8 +236,11 @@ public ResourceLibrary(String searchName, String scriptName, FileResource resour

@Override
public void load(Ruby runtime, boolean wrap) {
InputStream is = resource.openInputStream();
if (is == null) {

This comment has been minimized.

Copy link
@ratnikov

ratnikov Dec 3, 2014

Contributor

I think this change is from some other commit, since doesn't seem to do the pure refactor.

@mkristian

This comment has been minimized.

Copy link
Member Author

commented Dec 5, 2014

merge manually

@mkristian mkristian closed this Dec 5, 2014

@mkristian mkristian deleted the FileResource.inputStream branch Dec 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.