forked from I2P_Developers/i2p.i2p
* Console: Try to prevent cascaded IllegalStateExceptions in .jsp code;
add logging for original error
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
* flags.jsp?c=de => icons/flags/de.png
|
* flags.jsp?c=de => icons/flags/de.png
|
||||||
* with headers set so the browser caches.
|
* with headers set so the browser caches.
|
||||||
*/
|
*/
|
||||||
boolean rendered = false;
|
|
||||||
String c = request.getParameter("c");
|
String c = request.getParameter("c");
|
||||||
if (c != null && c.length() > 0) {
|
if (c != null && c.length() > 0) {
|
||||||
java.io.OutputStream cout = response.getOutputStream();
|
java.io.OutputStream cout = response.getOutputStream();
|
||||||
@@ -38,17 +37,23 @@ if (c != null && c.length() > 0) {
|
|||||||
response.setContentType("image/png");
|
response.setContentType("image/png");
|
||||||
try {
|
try {
|
||||||
net.i2p.util.FileUtil.readFile(file, base, cout);
|
net.i2p.util.FileUtil.readFile(file, base, cout);
|
||||||
rendered = true;
|
} catch (java.io.IOException ioe) {
|
||||||
} catch (java.io.IOException ioe) {}
|
// prevent 'Committed' IllegalStateException from Jetty
|
||||||
if (rendered)
|
if (!response.isCommitted()) {
|
||||||
cout.close();
|
response.sendError(403, ioe.toString());
|
||||||
|
} else {
|
||||||
|
net.i2p.I2PAppContext.getGlobalContext().logManager().getLog(getClass()).error("Error serving flags/" + c + ".png", ioe);
|
||||||
|
// Jetty doesn't log this
|
||||||
|
throw ioe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Send a 403 instead of a 404, because the server sends error.jsp
|
||||||
|
* for 404 errors, complete with the summary bar, which would be
|
||||||
|
* a huge load for a page full of flags if the user didn't have the
|
||||||
|
* flags directory for some reason.
|
||||||
|
*/
|
||||||
|
response.sendError(403, "No flag specified");
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Send a 403 instead of a 404, because the server sends error.jsp
|
|
||||||
* for 404 errors, complete with the summary bar, which would be
|
|
||||||
* a huge load for a page full of flags if the user didn't have the
|
|
||||||
* flags directory for some reason.
|
|
||||||
*/
|
|
||||||
if (!rendered)
|
|
||||||
response.sendError(403, "Flag not found");
|
|
||||||
%>
|
%>
|
@@ -11,6 +11,13 @@ String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsoluteP
|
|||||||
try {
|
try {
|
||||||
net.i2p.util.FileUtil.readFile("history.txt", base, response.getOutputStream());
|
net.i2p.util.FileUtil.readFile("history.txt", base, response.getOutputStream());
|
||||||
} catch (java.io.IOException ioe) {
|
} catch (java.io.IOException ioe) {
|
||||||
response.sendError(403, ioe.toString());
|
// prevent 'Committed' IllegalStateException from Jetty
|
||||||
|
if (!response.isCommitted()) {
|
||||||
|
response.sendError(403, ioe.toString());
|
||||||
|
} else {
|
||||||
|
net.i2p.I2PAppContext.getGlobalContext().logManager().getLog(getClass()).error("Error serving history.txt", ioe);
|
||||||
|
// Jetty doesn't log this
|
||||||
|
throw ioe;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%>
|
%>
|
@@ -63,6 +63,13 @@ if (length > 0)
|
|||||||
try {
|
try {
|
||||||
net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
|
net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
|
||||||
} catch (java.io.IOException ioe) {
|
} catch (java.io.IOException ioe) {
|
||||||
response.sendError(403, ioe.toString());
|
// prevent 'Committed' IllegalStateException from Jetty
|
||||||
|
if (!response.isCommitted()) {
|
||||||
|
response.sendError(403, ioe.toString());
|
||||||
|
} else {
|
||||||
|
net.i2p.I2PAppContext.getGlobalContext().logManager().getLog(getClass()).error("Error serving " + uri, ioe);
|
||||||
|
// Jetty doesn't log this
|
||||||
|
throw ioe;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%>
|
%>
|
Reference in New Issue
Block a user