Browse Source

Quartz ResourceLoaderClassLoadHelper explicitly falls back to classpath lookup

Issue: SPR-13706
(cherry picked from commit 51f356f)
pull/1057/head
Juergen Hoeller 10 years ago
parent
commit
7c998a70bc
  1. 44
      spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java

44
spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.scheduling.quartz; package org.springframework.scheduling.quartz;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
@ -82,32 +81,41 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper {
public URL getResource(String name) { public URL getResource(String name) {
Resource resource = this.resourceLoader.getResource(name); Resource resource = this.resourceLoader.getResource(name);
try { if (resource.exists()) {
return resource.getURL(); try {
} return resource.getURL();
catch (FileNotFoundException ex) { }
return null; catch (IOException ex) {
if (logger.isWarnEnabled()) {
logger.warn("Could not load " + resource);
}
return null;
}
} }
catch (IOException ex) { else {
logger.warn("Could not load " + resource); return getClassLoader().getResource(name);
return null;
} }
} }
public InputStream getResourceAsStream(String name) { public InputStream getResourceAsStream(String name) {
Resource resource = this.resourceLoader.getResource(name); Resource resource = this.resourceLoader.getResource(name);
try { if (resource.exists()) {
return resource.getInputStream(); try {
} return resource.getInputStream();
catch (FileNotFoundException ex) { }
return null; catch (IOException ex) {
if (logger.isWarnEnabled()) {
logger.warn("Could not load " + resource);
}
return null;
}
} }
catch (IOException ex) { else {
logger.warn("Could not load " + resource); return getClassLoader().getResourceAsStream(name);
return null;
} }
} }
@Override
public ClassLoader getClassLoader() { public ClassLoader getClassLoader() {
return this.resourceLoader.getClassLoader(); return this.resourceLoader.getClassLoader();
} }

Loading…
Cancel
Save