SimpleRetryPolicy:Throwable 映射中的布尔值表示什么?

SimpleRetryPolicy: What does the boolean in the Throwable map indicate?

SimpleRetryPolicy 的构造函数允许您指定哪些异常是可重试的。太棒了!

然而,这个输入是一个map,其中key是Throwable的class,value是一个boolean。没有任何文档说明此布尔值的用途 - 这里有人知道吗?

本质上,它填充了一个 SubclassClassifier 的实例,其文档对我简单的头脑来说太难理解了:

A Classifier for a parameterised object type based on a map. Classifies objects according to their inheritance relation with the supplied type map. If the object to be classified is one of the keys of the provided map, or is a subclass of one of the keys, then the map entry value for that key is returned. Otherwise returns the default value which is null by default.

SimpleRetryPolicy.retryForException():

/**
 * Delegates to an exception classifier.
 *
 * @param ex
 * @return true if this exception or its ancestors have been registered as
 * retryable.
 */
private boolean retryForException(Throwable ex) {
    return retryableClassifier.classify(ex);
}

即如果 throwable 已分类(在地图中),则返回该地图条目的布尔值。

这允许您设置一组例外,您可以在其中明确声明您不想重试某些例外。

考虑异常 Bar 扩展 Foo(并且 Bar 有一些兄弟 类,比如 BazQux)。

如果您将 Foo:true 添加到地图并添加 Bar:false,则 Foo 及其除 Bar 之外的所有子类 都可以重试。