Skip to content

Commit 7c998a7

Browse files
committed
Quartz ResourceLoaderClassLoadHelper explicitly falls back to classpath lookup
Issue: SPR-13706 (cherry picked from commit 51f356f)
1 parent 8adff1b commit 7c998a7

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.scheduling.quartz;
1818

19-
import java.io.FileNotFoundException;
2019
import java.io.IOException;
2120
import java.io.InputStream;
2221
import java.net.URL;
@@ -82,32 +81,41 @@ public <T> Class<? extends T> loadClass(String name, Class<T> clazz) throws Clas
8281

8382
public URL getResource(String name) {
8483
Resource resource = this.resourceLoader.getResource(name);
85-
try {
86-
return resource.getURL();
87-
}
88-
catch (FileNotFoundException ex) {
89-
return null;
84+
if (resource.exists()) {
85+
try {
86+
return resource.getURL();
87+
}
88+
catch (IOException ex) {
89+
if (logger.isWarnEnabled()) {
90+
logger.warn("Could not load " + resource);
91+
}
92+
return null;
93+
}
9094
}
91-
catch (IOException ex) {
92-
logger.warn("Could not load " + resource);
93-
return null;
95+
else {
96+
return getClassLoader().getResource(name);
9497
}
9598
}
9699

97100
public InputStream getResourceAsStream(String name) {
98101
Resource resource = this.resourceLoader.getResource(name);
99-
try {
100-
return resource.getInputStream();
101-
}
102-
catch (FileNotFoundException ex) {
103-
return null;
102+
if (resource.exists()) {
103+
try {
104+
return resource.getInputStream();
105+
}
106+
catch (IOException ex) {
107+
if (logger.isWarnEnabled()) {
108+
logger.warn("Could not load " + resource);
109+
}
110+
return null;
111+
}
104112
}
105-
catch (IOException ex) {
106-
logger.warn("Could not load " + resource);
107-
return null;
113+
else {
114+
return getClassLoader().getResourceAsStream(name);
108115
}
109116
}
110117

118+
@Override
111119
public ClassLoader getClassLoader() {
112120
return this.resourceLoader.getClassLoader();
113121
}

0 commit comments

Comments
 (0)