0
Ich kann die StaleStateException von RuntimeException nicht sofort abfangen, warum? Warum das entwerfen?Ich kann die StaleStateException nicht sofort abfangen, warum?
, wenn die erste transaktionale nicht vorlegen, werde ich die Ausnahme nicht fangen, aber StaleStateException erstreckt Runtime, Zweifel, sollte es sollte es sofort fangen
public ResponseInfo catchExce() {
try {
throwExceServiceA.throwExce();
} catch (StaleStateException e) {
System.out.println("This is a StaleStateException");
} catch (Exception e) {
System.out.println("This is a StaleStateException. Also is catched here");
} finally {
System.out.println("This block is always executed");
}
}
ThrowExceServiceA
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void throwExce() throws InterruptedException {
throwExceServiceB.throwExce();
Thread.sleep(1000);
}
ThrowExceServiceB
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void throwExce() {
throw new StaleStateException("");
}
Sie haben keinen Code innerhalb der Fang Ihres ersten Codeblock, sollten Sie in der Lage sein, die Ausnahme zu fangen – cralfaro
Ich frage mich, warum Sie re- poste deine erste Frage. Sie haben diese andere Frage bearbeitet, warten Sie also entweder, bis sie wieder geöffnet wird, oder löschen Sie sie. – Tom
@Tom Ich werde es löschen –