Use null in MockServletContext for unknown mime types
MockServletContext.getMimeTypes now returns null if the Java Activation Framework returns "application/octet-stream", which is the default media type it returns if the mime type is unknown. This enforces the contract for ServletContext.getMimeTypes (return null for uknown mime types) but does mean "application/octet-stream" cannot be returned. Issue: SPR-10334
This commit is contained in:
@@ -242,8 +242,16 @@ public class MockServletContext implements ServletContext {
|
||||
return this.effectiveMinorVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method uses the Java Activation framework, which returns
|
||||
* "application/octet-stream" when the mime type is unknown (i.e. it never returns
|
||||
* {@code null}). In order to maintain the {@link ServletContext#getMimeType(String)
|
||||
* contract, as of version 3.2.2, this method returns null if the mimeType is
|
||||
* "application/octet-stream".
|
||||
*/
|
||||
public String getMimeType(String filePath) {
|
||||
return MimeTypeResolver.getMimeType(filePath);
|
||||
String mimeType = MimeTypeResolver.getMimeType(filePath);
|
||||
return ("application/octet-stream".equals(mimeType)) ? null : mimeType;
|
||||
}
|
||||
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
|
||||
Reference in New Issue
Block a user