Permalink
Browse files

Catch more exceptions in web app and update site skin

  • Loading branch information...
srowen committed Aug 30, 2018
1 parent ab4ebad commit 431ae9e06ebb9181531a93c37a5f53394d3b8172
View
@@ -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 @@
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 @@ public final void init(FilterConfig filterConfig) {
// 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.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 @@ protected void doGet(HttpServletRequest request,
// 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 @@ protected void doGet(HttpServletRequest request,
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 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
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 @@ private static void processStream(InputStream is,
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;

0 comments on commit 431ae9e

Please sign in to comment.