File tree 2 files changed +9
-7
lines changed
main/java/org/springframework/web/servlet/resource
test/java/org/springframework/web/servlet/resource 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 19
19
import java .io .IOException ;
20
20
import java .io .InputStream ;
21
21
import java .util .List ;
22
+
22
23
import javax .activation .FileTypeMap ;
23
24
import javax .activation .MimetypesFileTypeMap ;
24
25
import javax .servlet .ServletException ;
25
26
import javax .servlet .http .HttpServletRequest ;
26
27
import javax .servlet .http .HttpServletResponse ;
27
28
29
+ import org .apache .commons .logging .Log ;
30
+ import org .apache .commons .logging .LogFactory ;
28
31
import org .springframework .beans .factory .InitializingBean ;
29
32
import org .springframework .core .io .ClassPathResource ;
30
33
import org .springframework .core .io .Resource ;
69
72
*/
70
73
public class ResourceHttpRequestHandler extends WebContentGenerator implements HttpRequestHandler , InitializingBean {
71
74
75
+ private final static Log logger = LogFactory .getLog (ResourceHttpRequestHandler .class );
76
+
72
77
private static final boolean jafPresent =
73
78
ClassUtils .isPresent ("javax.activation.FileTypeMap" , ResourceHttpRequestHandler .class .getClassLoader ());
74
79
@@ -90,7 +95,9 @@ public void setLocations(List<Resource> locations) {
90
95
91
96
@ Override
92
97
public void afterPropertiesSet () throws Exception {
93
- Assert .notEmpty (locations , "Locations list must not be empty" );
98
+ if (logger .isWarnEnabled ()) {
99
+ logger .warn ("Locations list is empty. No resources will be served" );
100
+ }
94
101
}
95
102
96
103
/**
Original file line number Diff line number Diff line change 19
19
import java .util .ArrayList ;
20
20
import java .util .Arrays ;
21
21
import java .util .List ;
22
+
22
23
import javax .servlet .http .HttpServletResponse ;
23
24
24
25
import org .junit .Before ;
25
26
import org .junit .Test ;
26
-
27
27
import org .springframework .core .io .ClassPathResource ;
28
28
import org .springframework .core .io .Resource ;
29
29
import org .springframework .mock .web .test .MockHttpServletRequest ;
@@ -219,11 +219,6 @@ public void resourceNotFound() throws Exception {
219
219
assertEquals (404 , response .getStatus ());
220
220
}
221
221
222
- @ Test (expected =IllegalArgumentException .class )
223
- public void locationsNotSet () throws Exception {
224
- new ResourceHttpRequestHandler ().afterPropertiesSet ();
225
- }
226
-
227
222
228
223
private static class TestServletContext extends MockServletContext {
229
224
You can’t perform that action at this time.
0 commit comments