Catch more exceptions in web app and update site skin

This commit is contained in:
Sean Owen 2018-08-30 16:47:18 -05:00
parent ab4ebad305
commit 431ae9e06e
3 changed files with 9 additions and 23 deletions

View file

@ -22,7 +22,7 @@
<skin> <skin>
<groupId>org.apache.maven.skins</groupId> <groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId> <artifactId>maven-fluido-skin</artifactId>
<version>1.6</version> <version>1.7</version>
</skin> </skin>
<body> <body>

View file

@ -19,13 +19,9 @@ package com.google.zxing.web;
import com.google.common.net.HttpHeaders; import com.google.common.net.HttpHeaders;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig; import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/** /**
* Provides no-op default implementations for convenience of subclasses. * Provides no-op default implementations for convenience of subclasses.
@ -37,11 +33,6 @@ abstract class AbstractFilter implements Filter {
// do nothing // do nothing
} }
@Override
public abstract void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain) throws IOException, ServletException;
@Override @Override
public final void destroy() { public final void destroy() {
// do nothing // do nothing

View file

@ -38,7 +38,6 @@ import com.google.common.io.Resources;
import com.google.common.net.HttpHeaders; import com.google.common.net.HttpHeaders;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import java.awt.color.CMMException;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -179,10 +178,10 @@ public final class DecodeServlet extends HttpServlet {
// Shortcut for data URI // Shortcut for data URI
if ("data".equals(imageURI.getScheme())) { if ("data".equals(imageURI.getScheme())) {
BufferedImage image = null; BufferedImage image;
try { try {
image = ImageReader.readDataURIImage(imageURI); image = ImageReader.readDataURIImage(imageURI);
} catch (IOException | IllegalStateException e) { } catch (Exception e) {
log.info("Error " + e + " while reading data URI: " + imageURIString); log.info("Error " + e + " while reading data URI: " + imageURIString);
errorResponse(request, response, "badurl"); errorResponse(request, response, "badurl");
return; return;
@ -240,7 +239,7 @@ public final class DecodeServlet extends HttpServlet {
try { try {
connection.connect(); connection.connect();
} catch (IOException | IllegalArgumentException e) { } catch (Exception e) {
// Encompasses lots of stuff, including // Encompasses lots of stuff, including
// java.net.SocketException, java.net.UnknownHostException, // java.net.SocketException, java.net.UnknownHostException,
// javax.net.ssl.SSLPeerUnverifiedException, // javax.net.ssl.SSLPeerUnverifiedException,
@ -302,12 +301,9 @@ public final class DecodeServlet extends HttpServlet {
Collection<Part> parts; Collection<Part> parts;
try { try {
parts = request.getParts(); parts = request.getParts();
} catch (IllegalStateException ise) { } catch (Exception e) {
log.info("File upload was too large or invalid"); // Includes IOException, InvalidContentTypeException, other parsing IllegalStateException
errorResponse(request, response, "badimage"); log.info(e.toString());
return;
} catch (IOException ioe) {
log.info(ioe.toString());
errorResponse(request, response, "badimage"); errorResponse(request, response, "badimage");
return; return;
} }
@ -336,9 +332,8 @@ public final class DecodeServlet extends HttpServlet {
BufferedImage image; BufferedImage image;
try { try {
image = ImageIO.read(is); image = ImageIO.read(is);
} catch (IOException | CMMException | IllegalArgumentException | ArrayIndexOutOfBoundsException e) { } catch (Exception e) {
// Have seen these in some logs, like an AIOOBE from certain GIF images // Many possible failures from JAI, so just catch anything as a failure
// https://github.com/zxing/zxing/issues/862#issuecomment-376159343
log.info(e.toString()); log.info(e.toString());
errorResponse(request, response, "badimage"); errorResponse(request, response, "badimage");
return; return;