Change MediaTypeFactory to return Optional
This commit changes the `MediaTypeFactory` to return `Optional<MediaType>` (instead of a plain `MediaType`) for the `getMediaType` methods. Issue: SPR-14908
This commit is contained in:
@@ -263,14 +263,12 @@ public class MockServletContext implements ServletContext {
|
||||
@Override
|
||||
public String getMimeType(String filePath) {
|
||||
String extension = StringUtils.getFilenameExtension(filePath);
|
||||
MediaType result;
|
||||
if (this.mimeTypes.containsKey(extension)) {
|
||||
result = this.mimeTypes.get(extension);
|
||||
return this.mimeTypes.get(extension).toString();
|
||||
}
|
||||
else {
|
||||
result = MediaTypeFactory.getMediaType(filePath);
|
||||
return MediaTypeFactory.getMediaType(filePath).orElse(MediaType.APPLICATION_OCTET_STREAM).toString();
|
||||
}
|
||||
return result != null ? result.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user