EA-232885: Fix possible null pointer exception

GitOrigin-RevId: a00d121598957b5365fb3b779fb83f8e180edf5f
This commit is contained in:
Andrey Lisin
2020-10-30 15:20:08 +03:00
committed by intellij-monorepo-bot
parent 4a41d94de5
commit 90af4fff87

View File

@@ -792,8 +792,17 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
}
private void showFailedTestInfoIfNecessary(@NotNull PyStackFrame frame) throws PyDebuggerException {
PyExecutionStack executionStack = ((PyExecutionStack)getSession().getSuspendContext().getActiveExecutionStack());
if (executionStack == null || !isFailedTestStop(executionStack.getThreadInfo())) return;
PyExecutionStack pyExecutionStack = null;
XDebugSession session = getSession();
if (session != null) {
XSuspendContext suspendContext = session.getSuspendContext();
if (suspendContext != null) {
XExecutionStack executionStack = suspendContext.getActiveExecutionStack();
pyExecutionStack = executionStack != null ? (PyExecutionStack)executionStack : null;
}
}
if (pyExecutionStack == null || !isFailedTestStop(pyExecutionStack.getThreadInfo())) return;
XValueChildrenList values = getFrameFromCache(frame);
if (values == null) return;
@@ -814,14 +823,14 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
errorMessage = errorMessage.replaceFirst(" :: ", "");
}
PyThreadInfo threadInfo = executionStack.getThreadInfo();
PyThreadInfo threadInfo = pyExecutionStack.getThreadInfo();
List<PyStackFrameInfo> threadFrames = threadInfo.getFrames();
boolean isTestSetUpFail = false;
if (threadFrames != null && (threadFrames.size() == 1 || threadFrames.size() > 1 && PyUnitTestsDebuggingService.isErrorInTestSetUpOrTearDown(threadFrames))) {
isTestSetUpFail = true;
}
getProject().getService(PyUnitTestsDebuggingService.class).showFailedTestInlay(
getSession(), frame, exceptionType, errorMessage, isTestSetUpFail);
session, frame, exceptionType, errorMessage, isTestSetUpFail);
}
}