*
* @return an exception classifier: maps to true if an exception should cause rollback
*/
protected Classifier<Throwable, Boolean> getRollbackClassifier() {
Classifier<Throwable, Boolean> classifier = new BinaryExceptionClassifier(noRollbackExceptionClasses, false);
// Try to avoid pathological cases where we cannot force a rollback
// (should be pretty uncommon):
if (!classifier.classify(new ForceRollbackForWriteSkipException("test", new RuntimeException()))
|| !classifier.classify(new ExhaustedRetryException("test"))) {
final Classifier<Throwable, Boolean> binary = classifier;
Collection<Class<? extends Throwable>> types = new HashSet<Class<? extends Throwable>>();
types.add(ForceRollbackForWriteSkipException.class);
types.add(ExhaustedRetryException.class);
final Classifier<Throwable, Boolean> panic = new BinaryExceptionClassifier(types, true);
classifier = new Classifier<Throwable, Boolean>() {
@Override
public Boolean classify(Throwable classifiable) {
// Rollback if either the user's list or our own applies
return panic.classify(classifiable) || binary.classify(classifiable);
}
};
}