Skip to content

Commit 4cb157d

Browse files
committed
jruby: safe pom resource lookup using class
1 parent 7da76a7 commit 4cb157d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

ext/java/org/jruby/ext/psych/PsychLibrary.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,24 @@
4141
import org.jruby.runtime.builtin.IRubyObject;
4242
import org.jruby.runtime.load.Library;
4343

44+
import org.snakeyaml.engine.v2.common.SpecVersion;
45+
4446
import java.io.IOException;
4547
import java.io.InputStream;
4648
import java.util.Properties;
4749

4850
public class PsychLibrary implements Library {
51+
52+
private static final String POM_PROPERTIES = "META-INF/maven/org.snakeyaml/snakeyaml-engine/pom.properties";
4953
private static final String DUMMY_VERSION = "0.0";
5054

5155
public void load(final Ruby runtime, boolean wrap) {
5256
RubyModule psych = runtime.defineModule("Psych");
5357

5458
// load version from properties packed with the jar
5559
Properties props = new Properties();
56-
try( InputStream is = runtime.getJRubyClassLoader().getResourceAsStream("META-INF/maven/org.snakeyaml/snakeyaml-engine/pom.properties") ) {
57-
props.load(is);
60+
try( InputStream is = SpecVersion.class.getResourceAsStream(POM_PROPERTIES) ) {
61+
if (is != null) props.load(is);
5862
}
5963
catch( IOException e ) {
6064
// ignored

0 commit comments

Comments
 (0)