CachedValue/IdempotenceChecker javadoc: more links, fix code

This commit is contained in:
peter
2019-03-21 18:44:42 +01:00
parent 77bc46e81a
commit 9dfaa31586
2 changed files with 5 additions and 1 deletions
@@ -47,6 +47,8 @@ import org.jetbrains.annotations.NotNull;
* <li>Cached arrays or lists should have the same number of elements, and they also should be equivalent and come in the same order.</li>
* <li>If the result object's class has a meaningful {@link #equals} method, it should hold.</li>
* </ul>
* This is enforced at runtime by occasional checks in {@link com.intellij.util.IdempotenceChecker#checkEquivalence(Object, Object, Class)}.
* See that method's documentation for further information and advice, when a failure happens.<p></p>
*
* <b>Context-independence</b>: if you store the CachedValue in a field or user data of some object {@code X}, then its {@link CachedValueProvider}
* may only depend on X and parts of global system state that don't change while {@code X} is alive and valid (e.g. application/project components/services).
@@ -74,6 +76,8 @@ import org.jetbrains.annotations.NotNull;
* </pre>
* </ul>
* </ul>
* This is enforced at runtime by occasional checks in {@link com.intellij.util.CachedValueStabilityChecker}.
* See that class's documentation for further information and advice, when a failure happens.<p></p>
*
* <b>Recursion prevention</b>: The same cached value provider can be re-entered recursively on the same thread,
* if the computation is inherently cyclic. Note that this is likely to result in {@link StackOverflowError},
@@ -44,7 +44,7 @@ public class IdempotenceChecker {
* {@code IdempotenceChecker.checkEquivalence()} for their results as well, localizing the error.</li>
* <li>
* If it's a test, you could try reproducing and debugging it. To increase the probability of failure,
* you can temporarily add {@code Registry.getValue("platform.random.idempotence.check.rate").set(1, getTestRootDisposable())}
* you can temporarily add {@code Registry.getValue("platform.random.idempotence.check.rate").setValue(1, getTestRootDisposable())}
* to perform the idempotence check on every cache access. Note that this can make your test much slower.
* </li>
* </ul>