Browse Source

Replace assert w/ warning in ResourceHttpRequestHandl.

Issue: SPR-9186
pull/297/merge
Rossen Stoyanchev 11 years ago
parent
commit
a4c15d6678
  1. 9
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java
  2. 7
      spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java

9
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java

@ -19,12 +19,15 @@ package org.springframework.web.servlet.resource; @@ -19,12 +19,15 @@ package org.springframework.web.servlet.resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import javax.activation.FileTypeMap;
import javax.activation.MimetypesFileTypeMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@ -69,6 +72,8 @@ import org.springframework.web.servlet.support.WebContentGenerator; @@ -69,6 +72,8 @@ import org.springframework.web.servlet.support.WebContentGenerator;
*/
public class ResourceHttpRequestHandler extends WebContentGenerator implements HttpRequestHandler, InitializingBean {
private final static Log logger = LogFactory.getLog(ResourceHttpRequestHandler.class);
private static final boolean jafPresent =
ClassUtils.isPresent("javax.activation.FileTypeMap", ResourceHttpRequestHandler.class.getClassLoader());
@ -90,7 +95,9 @@ public class ResourceHttpRequestHandler extends WebContentGenerator implements H @@ -90,7 +95,9 @@ public class ResourceHttpRequestHandler extends WebContentGenerator implements H
@Override
public void afterPropertiesSet() throws Exception {
Assert.notEmpty(locations, "Locations list must not be empty");
if (logger.isWarnEnabled()) {
logger.warn("Locations list is empty. No resources will be served");
}
}
/**

7
spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java

@ -19,11 +19,11 @@ package org.springframework.web.servlet.resource; @@ -19,11 +19,11 @@ package org.springframework.web.servlet.resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.mock.web.test.MockHttpServletRequest;
@ -219,11 +219,6 @@ public class ResourceHttpRequestHandlerTests { @@ -219,11 +219,6 @@ public class ResourceHttpRequestHandlerTests {
assertEquals(404, response.getStatus());
}
@Test(expected=IllegalArgumentException.class)
public void locationsNotSet() throws Exception {
new ResourceHttpRequestHandler().afterPropertiesSet();
}
private static class TestServletContext extends MockServletContext {

Loading…
Cancel
Save