Skip to content

Commit 562a240

Browse files
committed
ensure relative_require on root of uri:classloader:/
this fixes a regression of 0137667 Sponsored by Lookout Inc.
1 parent 0137667 commit 562a240

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

core/src/main/java/org/jruby/util/URLResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static FileResource createClassloaderURI(Ruby runtime, String pathname) {
163163
}
164164
URL url = cl.getResource(pathname);
165165
String[] files = listClassLoaderFiles(cl, pathname);
166-
return new URLResource(URI_CLASSLOADER + pathname,
166+
return new URLResource(URI_CLASSLOADER + "/" + pathname,
167167
cl,
168168
url == null ? null : pathname,
169169
files);

test/relative.rb

Whitespace-only changes.

test/require_relative.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require_relative 'relative'

test/test_load.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ def test_require
4646
assert $loaded_foo_bar
4747
end
4848

49+
# GH-2972
50+
def test_require_relative_via_uri_classloader_protocol
51+
$CLASSPATH << './test'
52+
assert_nothing_raised do
53+
require 'uri:classloader:/require_relative.rb'
54+
end
55+
end
56+
4957
# JRUBY-3231
5058
def test_load_with_empty_string_in_loadpath
5159
begin

0 commit comments

Comments
 (0)