-
Notifications
You must be signed in to change notification settings - Fork 204
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
jruby: safer engine version resolution #716
Conversation
private static final String DUMMY_VERSION = "0.0"; | ||
|
||
public void load(final Ruby runtime, boolean wrap) { | ||
RubyModule psych = runtime.defineModule("Psych"); | ||
|
||
// load version from properties packed with the jar | ||
Properties props = new Properties(); | ||
try( InputStream is = runtime.getJRubyClassLoader().getResourceAsStream("META-INF/maven/org.snakeyaml/snakeyaml-engine/pom.properties") ) { | ||
props.load(is); | ||
try( InputStream is = SpecVersion.class.getResourceAsStream(POM_PROPERTIES) ) { |
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.
using an actual class from the .jar we're trying to locate the resource from should work more reliably (for the common gem case this is going to be the same as before with runtime.getJRubyClassLoader()
).
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.
Makes sense.
private static final String DUMMY_VERSION = "0.0"; | ||
|
||
public void load(final Ruby runtime, boolean wrap) { | ||
RubyModule psych = runtime.defineModule("Psych"); | ||
|
||
// load version from properties packed with the jar | ||
Properties props = new Properties(); | ||
try( InputStream is = runtime.getJRubyClassLoader().getResourceAsStream("META-INF/maven/org.snakeyaml/snakeyaml-engine/pom.properties") ) { | ||
props.load(is); | ||
try( InputStream is = SpecVersion.class.getResourceAsStream(POM_PROPERTIES) ) { |
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.
Makes sense.
while also retaining the original version number in the
SNAKEYAML_VERSION
constantcloses #711