Skip to content

Commit

Permalink
call Kernel.require ruby method from autoload callback instead of cal…
Browse files Browse the repository at this point in the history
…ling internal require
  • Loading branch information
ashanbrown committed Sep 3, 2012
1 parent 26e08ba commit ea7f766
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/org/jruby/RubyKernel.java
Expand Up @@ -189,14 +189,16 @@ public static IRubyObject autoload(final IRubyObject recv, IRubyObject symbol, f
IRubyObject existingValue = module.fastFetchConstant(baseName);
if (existingValue != null && existingValue != RubyObject.UNDEF) return runtime.getNil();

final ThreadContext context = runtime.getCurrentContext();

module.defineAutoload(baseName, new IAutoloadMethod() {
public String file() {
return file.toString();
}

public void load(Ruby runtime) {
if (runtime.getLoadService().lockAndRequire(file())) {
// Do not finish autoloading by cyclic autoload
if (runtime.getKernel().callMethod(context, "require", file).isTrue()) {
// Do not finish autoloading by cyclic autoload
module.finishAutoload(baseName);
}
}
Expand Down

0 comments on commit ea7f766

Please sign in to comment.