mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -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
|
// Shortcut for data URI
|
||||||
if ("data".equals(imageURI.getScheme())) {
|
if ("data".equals(imageURI.getScheme())) {
|
||||||
|
BufferedImage image = null;
|
||||||
try {
|
try {
|
||||||
BufferedImage image = ImageReader.readDataURIImage(imageURI);
|
image = ImageReader.readDataURIImage(imageURI);
|
||||||
processImage(image, request, response);
|
|
||||||
} catch (IOException | IllegalStateException e) {
|
} catch (IOException | IllegalStateException e) {
|
||||||
log.info(e.toString());
|
log.info(e.toString());
|
||||||
errorResponse(request, response, "badurl");
|
errorResponse(request, response, "badurl");
|
||||||
}
|
}
|
||||||
|
if (image == null) {
|
||||||
|
errorResponse(request, response, "badimage");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
processImage(image, request, response);
|
||||||
|
} finally {
|
||||||
|
image.flush();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,14 +313,19 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
errorResponse(request, response, "badimage");
|
errorResponse(request, response, "badimage");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (image.getHeight() <= 1 || image.getWidth() <= 1 ||
|
try {
|
||||||
image.getHeight() * image.getWidth() > MAX_PIXELS) {
|
int height = image.getHeight();
|
||||||
log.info("Dimensions out of bounds: " + image.getWidth() + 'x' + image.getHeight());
|
int width = image.getWidth();
|
||||||
errorResponse(request, response, "badimage");
|
if (height <= 1 || width <= 1 || height * width > MAX_PIXELS) {
|
||||||
return;
|
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,
|
private static void processImage(BufferedImage image,
|
||||||
|
|
|
@ -31,16 +31,16 @@
|
||||||
|
|
||||||
<Service name="Catalina">
|
<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"
|
<Connector port="80" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
|
||||||
redirectPort="443"
|
redirectPort="443"
|
||||||
server="Apache" compression="4096"
|
server="Apache" compression="8192"
|
||||||
executor="tomcatThreadPool"
|
executor="tomcatThreadPool"
|
||||||
URIEncoding="UTF-8"/>
|
URIEncoding="UTF-8"/>
|
||||||
|
|
||||||
<Connector port="443" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
|
<Connector port="443" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
|
||||||
server="Apache" compression="4096"
|
server="Apache" compression="8192"
|
||||||
executor="tomcatThreadPool"
|
executor="tomcatThreadPool"
|
||||||
SSLEnabled="true" scheme="https" secure="true"
|
SSLEnabled="true" scheme="https" secure="true"
|
||||||
keyAlias="zxingorg"
|
keyAlias="zxingorg"
|
||||||
|
|
Loading…
Reference in a new issue