* 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:
parent
2f3f7d665c
commit
afcef645b9
1 changed files with 21 additions and 31 deletions
|
@ -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();
|
||||||
|
|
||||||
try {
|
|
||||||
localrtx.abort();
|
localrtx.abort();
|
||||||
} catch (Exception ignore) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void startTransactor() {
|
private synchronized void startTransactor() {
|
||||||
|
@ -618,12 +612,15 @@ 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);
|
||||||
|
} catch (InterruptedException ix) {
|
||||||
|
// we got interrrupted, releases resources and thread
|
||||||
|
rtx = null;
|
||||||
|
}
|
||||||
|
|
||||||
// if no request arrived, release ressources and thread
|
// if no request arrived, release ressources and thread
|
||||||
if ((reqtype == NONE) && (rtx == localrtx)) {
|
if ((reqtype == NONE) && (rtx == localrtx)) {
|
||||||
|
@ -633,8 +630,6 @@ public final class RequestEvaluator implements Runnable {
|
||||||
// scriptingEngine = null;
|
// scriptingEngine = null;
|
||||||
rtx = null;
|
rtx = null;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException ix) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -659,12 +654,7 @@ public final class RequestEvaluator implements Runnable {
|
||||||
reqtype = NONE;
|
reqtype = NONE;
|
||||||
|
|
||||||
t.kill();
|
t.kill();
|
||||||
|
|
||||||
try {
|
|
||||||
t.abort();
|
t.abort();
|
||||||
} catch (Exception ignore) {
|
|
||||||
}
|
|
||||||
|
|
||||||
t.closeConnections();
|
t.closeConnections();
|
||||||
|
|
||||||
notifyAll();
|
notifyAll();
|
||||||
|
|
Loading…
Add table
Reference in a new issue