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

jruby: safer engine version resolution #716

Merged
merged 2 commits into from
Feb 13, 2025
Merged

Conversation

kares
Copy link
Contributor

@kares kares commented Feb 12, 2025

while also retaining the original version number in the SNAKEYAML_VERSION constant

closes #711

@kares kares changed the title Jruby: safer engine version resolution jruby: safer engine version resolution Feb 12, 2025
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) ) {
Copy link
Contributor Author

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()).

Copy link
Contributor

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) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense.

@headius headius merged commit a5744ed into ruby:master Feb 13, 2025
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

loading jruby ext can fail with NullPointerException
2 participants