Make sure the date computations don't overflow the integer range.

This commit is contained in:
Knut Forkalsrud 2010-05-20 11:32:24 -07:00
parent 22b810c991
commit bd8abd9053

View file

@ -238,14 +238,14 @@ public class AlbumServlet
if (notModified(req, file)) {
res.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
res.setDateHeader("Expires", System.currentTimeMillis() + (30 * 24 * 3600 * 1000)); // 30 days
res.setDateHeader("Expires", System.currentTimeMillis() + (30 * 24 * 3600 * 1000L)); // 30 days
System.out.println(file.getName() + " not modified (based on date)");
return;
}
String fileEtag = thumbnail.getEtag() + "-" + size;
if (etagMatches(req, fileEtag)) {
res.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
res.setDateHeader("Expires", System.currentTimeMillis() + (30 * 24 * 3600 * 1000)); // 30 days
res.setDateHeader("Expires", System.currentTimeMillis() + (30 * 24 * 3600 * 1000L)); // 30 days
System.out.println(file.getName() + " not modified (based on etag)");
return;
}
@ -269,7 +269,7 @@ public class AlbumServlet
res.setStatus(HttpServletResponse.SC_OK);
res.setDateHeader("Last-Modified", file.lastModified());
res.setHeader("ETag", fileEtag);
res.setDateHeader("Expires", System.currentTimeMillis() + (30 * 24 * 3600 * 1000)); // 30 days
res.setDateHeader("Expires", System.currentTimeMillis() + (30 * 24 * 3600 * 1000L)); // 30 days
res.setContentType(cimg.mimeType);
res.setContentLength(cimg.bits.length);
res.getOutputStream().write(cimg.bits);