mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
More attempt to tune memory problem on decode server
This commit is contained in:
parent
5447790002
commit
cac5b1a6fe
|
@ -162,13 +162,22 @@ public final class DecodeServlet extends HttpServlet {
|
|||
|
||||
// Shortcut for data URI
|
||||
if ("data".equals(imageURI.getScheme())) {
|
||||
BufferedImage image = null;
|
||||
try {
|
||||
BufferedImage image = ImageReader.readDataURIImage(imageURI);
|
||||
processImage(image, request, response);
|
||||
image = ImageReader.readDataURIImage(imageURI);
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
log.info(e.toString());
|
||||
errorResponse(request, response, "badurl");
|
||||
}
|
||||
if (image == null) {
|
||||
errorResponse(request, response, "badimage");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
processImage(image, request, response);
|
||||
} finally {
|
||||
image.flush();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -304,14 +313,19 @@ public final class DecodeServlet extends HttpServlet {
|
|||
errorResponse(request, response, "badimage");
|
||||
return;
|
||||
}
|
||||
if (image.getHeight() <= 1 || image.getWidth() <= 1 ||
|
||||
image.getHeight() * image.getWidth() > MAX_PIXELS) {
|
||||
log.info("Dimensions out of bounds: " + image.getWidth() + 'x' + image.getHeight());
|
||||
errorResponse(request, response, "badimage");
|
||||
return;
|
||||
try {
|
||||
int height = image.getHeight();
|
||||
int width = image.getWidth();
|
||||
if (height <= 1 || width <= 1 || height * width > MAX_PIXELS) {
|
||||
log.info("Dimensions out of bounds: " + width + 'x' + height);
|
||||
errorResponse(request, response, "badimage");
|
||||
return;
|
||||
}
|
||||
|
||||
processImage(image, request, response);
|
||||
} finally {
|
||||
image.flush();
|
||||
}
|
||||
|
||||
processImage(image, request, response);
|
||||
}
|
||||
|
||||
private static void processImage(BufferedImage image,
|
||||
|
|
|
@ -31,16 +31,16 @@
|
|||
|
||||
<Service name="Catalina">
|
||||
|
||||
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="10" minSpareThreads="2"/>
|
||||
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="4" minSpareThreads="1"/>
|
||||
|
||||
<Connector port="80" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
|
||||
redirectPort="443"
|
||||
server="Apache" compression="4096"
|
||||
server="Apache" compression="8192"
|
||||
executor="tomcatThreadPool"
|
||||
URIEncoding="UTF-8"/>
|
||||
|
||||
<Connector port="443" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
|
||||
server="Apache" compression="4096"
|
||||
server="Apache" compression="8192"
|
||||
executor="tomcatThreadPool"
|
||||
SSLEnabled="true" scheme="https" secure="true"
|
||||
keyAlias="zxingorg"
|
||||
|
|
Loading…
Reference in a new issue