提交 771db056 编写于 作者: J Juergen Hoeller

changed contentLength() from int to long

上级 e250ff0f
......@@ -129,7 +129,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource {
}
@Override
public int contentLength() throws IOException {
public long contentLength() throws IOException {
URL url = getURL();
if (ResourceUtils.isFileURL(url)) {
// Proceed with file system resolution...
......
......@@ -112,8 +112,8 @@ public abstract class AbstractResource implements Resource {
* if available.
* @see #getFile()
*/
public int contentLength() throws IOException {
return (int) getFile().length();
public long contentLength() throws IOException {
return getFile().length();
}
/**
......
......@@ -96,7 +96,7 @@ public interface Resource extends InputStreamSource {
* @throws IOException if the resource cannot be resolved
* (in the file system or as some other known physical resource type)
*/
int contentLength() throws IOException;
long contentLength() throws IOException;
/**
* Determine the last-modified timestamp for this resource.
......
......@@ -148,7 +148,11 @@ public class ResourceHttpRequestHandler extends WebContentGenerator implements H
if (mediaType != null) {
response.setContentType(mediaType.toString());
}
response.setContentLength(resource.contentLength());
long length = resource.contentLength();
if (length > Integer.MAX_VALUE) {
throw new IOException("Resource content too long (beyond Integer.MAX_VALUE): " + resource);
}
response.setContentLength((int) length);
FileCopyUtils.copy(resource.getInputStream(), response.getOutputStream());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册