Skip to content

Commit

Permalink
synchronized class loading properly - fixes #2108
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
mkristian committed Nov 7, 2014
1 parent 5d93cdc commit ac9f2eb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions core/src/main/java/org/jruby/util/JRubyClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ public void addURL(URL url) {

@Override
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
Class<?> c = findLoadedClass(name);
if (c == null) {
try {
c = findClass(name);
} catch (ClassNotFoundException e) {
return super.loadClass(name, resolve);
synchronized (getClassLoadingLock(name)) {
Class<?> c = findLoadedClass(name);
if (c == null) {
try {
c = findClass(name);
} catch (ClassNotFoundException e) {
return super.loadClass(name, resolve);
}
}
return c;
}
return c;
}

/**
Expand Down

0 comments on commit ac9f2eb

Please sign in to comment.