LeakHunter: take read action when evaluating toString, some PSI elements require that

This commit is contained in:
peter
2016-02-05 10:35:18 +01:00
parent 0460174b3a
commit 95760201ee
@@ -15,6 +15,8 @@
*/
package com.intellij.util;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.concurrency.AtomicFieldUpdater;
import com.intellij.util.containers.FList;
@@ -156,6 +158,7 @@ public class DebugReflectionUtil {
String result = "";
while (backLink != null) {
String valueStr;
AccessToken token = ReadAction.start();
try {
valueStr = backLink.value instanceof FList
? "FList (size="+((FList)backLink.value).size()+")" :
@@ -166,6 +169,9 @@ public class DebugReflectionUtil {
catch (Throwable e) {
valueStr = "(" + e.getMessage() + " while computing .toString())";
}
finally {
token.finish();
}
Field field = backLink.field;
String fieldName = field == null ? "?" : field.getDeclaringClass().getName()+"."+field.getName();
result += "via '" + fieldName + "'; Value: '" + valueStr + "' of " + backLink.value.getClass() + "\n";