I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit e8d94982 authored by zzz's avatar zzz
Browse files

* Console: Try to prevent cascaded IllegalStateExceptions in .jsp code;

      add logging for original error
parent 38db0b0f
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,6 @@ ...@@ -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) { ...@@ -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");
%> %>
\ No newline at end of file
...@@ -11,6 +11,13 @@ String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsoluteP ...@@ -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;
}
} }
%> %>
\ No newline at end of file
...@@ -63,6 +63,13 @@ if (length > 0) ...@@ -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;
}
} }
%> %>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment