Skip to content

Commit

Permalink
Merge pull request #1224 from flybyray/play1-1223
Browse files Browse the repository at this point in the history
[#1823] Fix play.exceptions.CompilationException (fix for the fix #786)
  • Loading branch information
xael-fry authored Mar 16, 2018
2 parents 71874ce + ccb76af commit a7b2fcf
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions framework/src/play/classloading/ApplicationClassloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,34 +238,39 @@ public InputStream getResourceAsStream(String name) {
return res.inputstream();
}
}
URL url = this.getResource(name);
if (url != null) {
try {
File file = new File(url.toURI());
String fileName = file.getCanonicalFile().getName();
if (!name.endsWith(fileName)) {
return null;
}
} catch (Exception e) {
}
}
URL url = getResource(name);

return super.getResourceAsStream(name);
}

@Override
public URL getResource(String name) {
for (VirtualFile vf : Play.javaPath) {
VirtualFile res = vf.child(name);
if (res != null && res.exists()) {
URL url = null;
for (VirtualFile vf : Play.javaPath) {
VirtualFile res = vf.child(name);
if (res != null && res.exists()) {
try {
return res.getRealFile().toURI().toURL();
} catch (MalformedURLException ex) {
throw new UnexpectedException(ex);
url = res.getRealFile().toURI().toURL();
break;
} catch (MalformedURLException ex) {
throw new UnexpectedException(ex);
}
}
}
if (url == null) {
url = super.getResource(name);
if (url != null) {
try {
File file = new File(url.toURI());
String fileName = file.getCanonicalFile().getName();
if (!name.endsWith(fileName)) {
url = null;
}
} catch (Exception ignore) {
}
}
}
return super.getResource(name);
return url;
}

@Override
Expand Down

0 comments on commit a7b2fcf

Please sign in to comment.