* Use logError() to log exceptions for internal, external and XML-RPC requests instead of logEvent().

* Try to handle InterruptedException properly by exiting the main request transactor loop.
* No more need to catch Exceptions from Transactor.abort().
This commit is contained in:
hns 2006-02-06 13:55:26 +00:00
parent 2f3f7d665c
commit afcef645b9

View file

@ -146,8 +146,6 @@ public final class RequestEvaluator implements Runnable {
String error = null; String error = null;
while (!done && localrtx == rtx) { while (!done && localrtx == rtx) {
currentElement = null;
// catch errors in path resolution and script execution // catch errors in path resolution and script execution
try { try {
@ -425,9 +423,7 @@ public final class RequestEvaluator implements Runnable {
commitTransaction(); commitTransaction();
} catch (Exception x) { } catch (Exception x) {
abortTransaction(); abortTransaction();
app.logError(txname + ": " + error, x);
app.logEvent("Exception in " + Thread.currentThread() + ": " +
x);
// If the transactor thread has been killed by the invoker thread we don't have to // If the transactor thread has been killed by the invoker thread we don't have to
// bother for the error message, just quit. // bother for the error message, just quit.
@ -455,9 +451,7 @@ public final class RequestEvaluator implements Runnable {
commitTransaction(); commitTransaction();
} catch (Exception x) { } catch (Exception x) {
abortTransaction(); abortTransaction();
app.logError(txname + ": " + error, x);
app.logEvent("Exception in " + Thread.currentThread() +
": " + x);
// If the transactor thread has been killed by the invoker thread we don't have to // If the transactor thread has been killed by the invoker thread we don't have to
// bother for the error message, just quit. // bother for the error message, just quit.
@ -487,9 +481,13 @@ public final class RequestEvaluator implements Runnable {
try { try {
// wait a bit longer with each try // wait a bit longer with each try
int base = 800 * tries; int base = 800 * tries;
Thread.sleep((long) (base + (Math.random() * base * 2))); Thread.sleep((long) (base + (Math.random() * base * 2)));
} catch (Exception ignore) { } catch (InterruptedException interrupt) {
// we got interrrupted, create minimal error message
res.writeErrorReport(app.getName(), error);
done = true;
// and release resources and thread
rtx = null;
} }
} else { } else {
abortTransaction(); abortTransaction();
@ -580,11 +578,7 @@ public final class RequestEvaluator implements Runnable {
synchronized void abortTransaction() { synchronized void abortTransaction() {
Transactor localrtx = (Transactor) Thread.currentThread(); Transactor localrtx = (Transactor) Thread.currentThread();
localrtx.abort();
try {
localrtx.abort();
} catch (Exception ignore) {
}
} }
private synchronized void startTransactor() { private synchronized void startTransactor() {
@ -618,22 +612,23 @@ public final class RequestEvaluator implements Runnable {
} }
reqtype = NONE; reqtype = NONE;
notifyAll(); notifyAll();
try { try {
// wait for request, max 10 min // wait for request, max 10 min
wait(1000 * 60 * 10); wait(1000 * 60 * 10);
// if no request arrived, release ressources and thread
if ((reqtype == NONE) && (rtx == localrtx)) {
// comment this in to release not just the thread, but also the scripting engine.
// currently we don't do this because of the risk of memory leaks (objects from
// framework referencing into the scripting engine)
// scriptingEngine = null;
rtx = null;
}
} catch (InterruptedException ix) { } catch (InterruptedException ix) {
// we got interrrupted, releases resources and thread
rtx = null;
}
// if no request arrived, release ressources and thread
if ((reqtype == NONE) && (rtx == localrtx)) {
// comment this in to release not just the thread, but also the scripting engine.
// currently we don't do this because of the risk of memory leaks (objects from
// framework referencing into the scripting engine)
// scriptingEngine = null;
rtx = null;
} }
} }
@ -659,12 +654,7 @@ public final class RequestEvaluator implements Runnable {
reqtype = NONE; reqtype = NONE;
t.kill(); t.kill();
t.abort();
try {
t.abort();
} catch (Exception ignore) {
}
t.closeConnections(); t.closeConnections();
notifyAll(); notifyAll();