From ce072f02f929b4cada4e04c895d7b8ea447113df Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Wed, 18 May 2016 14:57:03 +0100 Subject: [PATCH] Better info logging in web app, and better clearing of buffers --- .../main/java/com/google/zxing/web/DecodeServlet.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/zxingorg/src/main/java/com/google/zxing/web/DecodeServlet.java b/zxingorg/src/main/java/com/google/zxing/web/DecodeServlet.java index b78064ac9..20364e64f 100644 --- a/zxingorg/src/main/java/com/google/zxing/web/DecodeServlet.java +++ b/zxingorg/src/main/java/com/google/zxing/web/DecodeServlet.java @@ -244,9 +244,8 @@ public final class DecodeServlet extends HttpServlet { private static void consumeRemainder(InputStream is) { try { - int available; - while ((available = is.available()) > 0) { - is.read(REMAINDER_BUFFER, 0, available); // don't care about value, or collision + while (is.read(REMAINDER_BUFFER) > 0) { + // don't care about value, or collision } } catch (IOException | IndexOutOfBoundsException ioe) { // 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"); errorResponse(request, response, "badimage"); } else { - log.info("Decoding uploaded file"); + log.info("Decoding uploaded file " + fileUploadPart); try (InputStream is = fileUploadPart.getInputStream()) { processStream(is, request, response); } @@ -378,10 +377,10 @@ public final class DecodeServlet extends HttpServlet { try { throw savedException == null ? NotFoundException.getNotFoundInstance() : savedException; } catch (FormatException | ChecksumException e) { - log.info(e.getMessage()); + log.info(e.toString()); errorResponse(request, response, "format"); } catch (ReaderException e) { // Including NotFoundException - log.info(e.getMessage()); + log.info(e.toString()); errorResponse(request, response, "notfound"); } return;