Skip to content

Commit

Permalink
Npe fix in Instrumented Process (#1766)
Browse files Browse the repository at this point in the history
[utbot-rider]
Npe fix in for #1292 -
#1292 (comment),
but this is not fix
  • Loading branch information
Domonion authored Feb 2, 2023
1 parent 2a446d6 commit ee394c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ object UtExecutionInstrumentation : Instrumentation<UtConcreteExecutionResult> {
// invariants:
// 1. phase must always complete if started as static reset relies on it
// 2. phase must be fast as there are no incremental changes
postprocessingPhase.savedStatics = preparationPhase.start {
postprocessingPhase.setStaticFields(preparationPhase.start {
val result = setStaticFields(statics)
resetTrace()
result
}
})

// invocation
val concreteResult = executePhaseInTimeout(invocationPhase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ class PostprocessingPhase : ExecutionPhase {

private var savedStaticsInstance: Map<FieldId, Any?>? = null

var savedStatics: Map<FieldId, Any?>
get() = savedStaticsInstance!!
set(value) {
savedStaticsInstance = value
}
fun setStaticFields(savedStatics: Map<FieldId, Any?>) {
savedStaticsInstance = savedStatics
}

override fun wrapError(e: Throwable): ExecutionPhaseException = ExecutionPhaseError(this.javaClass.simpleName, e)

fun resetStaticFields() {
savedStatics.forEach { (fieldId, value) ->
savedStaticsInstance?.forEach { (fieldId, value) ->
fieldId.jField.run {
withAccessibility {
set(null, value)
Expand Down

0 comments on commit ee394c0

Please sign in to comment.