Better info logging in web app, and better clearing of buffers

This commit is contained in:
Sean Owen 2016-05-18 14:57:03 +01:00
parent 1f14baf6f2
commit ce072f02f9

View file

@ -244,9 +244,8 @@ public final class DecodeServlet extends HttpServlet {
private static void consumeRemainder(InputStream is) { private static void consumeRemainder(InputStream is) {
try { try {
int available; while (is.read(REMAINDER_BUFFER) > 0) {
while ((available = is.available()) > 0) { // don't care about value, or collision
is.read(REMAINDER_BUFFER, 0, available); // don't care about value, or collision
} }
} catch (IOException | IndexOutOfBoundsException ioe) { } catch (IOException | IndexOutOfBoundsException ioe) {
// sun.net.www.http.ChunkedInputStream.read is throwing IndexOutOfBoundsException // sun.net.www.http.ChunkedInputStream.read is throwing IndexOutOfBoundsException
@ -280,7 +279,7 @@ public final class DecodeServlet extends HttpServlet {
log.info("File upload was not multipart"); log.info("File upload was not multipart");
errorResponse(request, response, "badimage"); errorResponse(request, response, "badimage");
} else { } else {
log.info("Decoding uploaded file"); log.info("Decoding uploaded file " + fileUploadPart);
try (InputStream is = fileUploadPart.getInputStream()) { try (InputStream is = fileUploadPart.getInputStream()) {
processStream(is, request, response); processStream(is, request, response);
} }
@ -378,10 +377,10 @@ public final class DecodeServlet extends HttpServlet {
try { try {
throw savedException == null ? NotFoundException.getNotFoundInstance() : savedException; throw savedException == null ? NotFoundException.getNotFoundInstance() : savedException;
} catch (FormatException | ChecksumException e) { } catch (FormatException | ChecksumException e) {
log.info(e.getMessage()); log.info(e.toString());
errorResponse(request, response, "format"); errorResponse(request, response, "format");
} catch (ReaderException e) { // Including NotFoundException } catch (ReaderException e) { // Including NotFoundException
log.info(e.getMessage()); log.info(e.toString());
errorResponse(request, response, "notfound"); errorResponse(request, response, "notfound");
} }
return; return;