Removed some redundant 'else's using early return

See gh-22528
This commit is contained in:
Pradipta Sarma
2020-07-23 18:05:30 +05:30
committed by Stephane Nicoll
parent 72c6435078
commit 2627bf896e
6 changed files with 23 additions and 38 deletions

View File

@@ -152,19 +152,17 @@ public abstract class ResourceUtils {
if (location.startsWith(CLASSPATH_URL_PREFIX)) {
return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
}
else {
if (location.startsWith(FILE_URL_PREFIX)) {
return this.files.getResource(location);
}
try {
// Try to parse the location as a URL...
URL url = new URL(location);
return new UrlResource(url);
}
catch (MalformedURLException ex) {
// No URL -> resolve as resource path.
return getResourceByPath(location);
}
if (location.startsWith(FILE_URL_PREFIX)) {
return this.files.getResource(location);
}
try {
// Try to parse the location as a URL...
URL url = new URL(location);
return new UrlResource(url);
}
catch (MalformedURLException ex) {
// No URL -> resolve as resource path.
return getResourceByPath(location);
}
}