mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Catch more exceptions in web app and update site skin
This commit is contained in:
parent
ab4ebad305
commit
431ae9e06e
|
@ -22,7 +22,7 @@
|
|||
<skin>
|
||||
<groupId>org.apache.maven.skins</groupId>
|
||||
<artifactId>maven-fluido-skin</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>1.7</version>
|
||||
</skin>
|
||||
|
||||
<body>
|
||||
|
|
|
@ -19,13 +19,9 @@ package com.google.zxing.web;
|
|||
import com.google.common.net.HttpHeaders;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Provides no-op default implementations for convenience of subclasses.
|
||||
|
@ -37,11 +33,6 @@ abstract class AbstractFilter implements Filter {
|
|||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void doFilter(ServletRequest request,
|
||||
ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException;
|
||||
|
||||
@Override
|
||||
public final void destroy() {
|
||||
// do nothing
|
||||
|
|
|
@ -38,7 +38,6 @@ import com.google.common.io.Resources;
|
|||
import com.google.common.net.HttpHeaders;
|
||||
import com.google.common.net.MediaType;
|
||||
|
||||
import java.awt.color.CMMException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -179,10 +178,10 @@ public final class DecodeServlet extends HttpServlet {
|
|||
|
||||
// Shortcut for data URI
|
||||
if ("data".equals(imageURI.getScheme())) {
|
||||
BufferedImage image = null;
|
||||
BufferedImage image;
|
||||
try {
|
||||
image = ImageReader.readDataURIImage(imageURI);
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
} catch (Exception e) {
|
||||
log.info("Error " + e + " while reading data URI: " + imageURIString);
|
||||
errorResponse(request, response, "badurl");
|
||||
return;
|
||||
|
@ -240,7 +239,7 @@ public final class DecodeServlet extends HttpServlet {
|
|||
|
||||
try {
|
||||
connection.connect();
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
} catch (Exception e) {
|
||||
// Encompasses lots of stuff, including
|
||||
// java.net.SocketException, java.net.UnknownHostException,
|
||||
// javax.net.ssl.SSLPeerUnverifiedException,
|
||||
|
@ -302,12 +301,9 @@ public final class DecodeServlet extends HttpServlet {
|
|||
Collection<Part> parts;
|
||||
try {
|
||||
parts = request.getParts();
|
||||
} catch (IllegalStateException ise) {
|
||||
log.info("File upload was too large or invalid");
|
||||
errorResponse(request, response, "badimage");
|
||||
return;
|
||||
} catch (IOException ioe) {
|
||||
log.info(ioe.toString());
|
||||
} catch (Exception e) {
|
||||
// Includes IOException, InvalidContentTypeException, other parsing IllegalStateException
|
||||
log.info(e.toString());
|
||||
errorResponse(request, response, "badimage");
|
||||
return;
|
||||
}
|
||||
|
@ -336,9 +332,8 @@ public final class DecodeServlet extends HttpServlet {
|
|||
BufferedImage image;
|
||||
try {
|
||||
image = ImageIO.read(is);
|
||||
} catch (IOException | CMMException | IllegalArgumentException | ArrayIndexOutOfBoundsException e) {
|
||||
// Have seen these in some logs, like an AIOOBE from certain GIF images
|
||||
// https://github.com/zxing/zxing/issues/862#issuecomment-376159343
|
||||
} catch (Exception e) {
|
||||
// Many possible failures from JAI, so just catch anything as a failure
|
||||
log.info(e.toString());
|
||||
errorResponse(request, response, "badimage");
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue