Skip to content

Commit 67048e6

Browse files
authored
Merge branch 'master' into vulnerability-analyser
2 parents d541ecc + 931dbbd commit 67048e6

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

core/src/main/kotlin/org/evomaster/core/problem/rest/data/RestCallAction.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.evomaster.core.problem.rest.data
22

3+
import org.evomaster.core.Lazy
34
import org.evomaster.core.problem.httpws.HttpWsAction
45
import org.evomaster.core.problem.httpws.auth.HttpWsAuthenticationInfo
56
import org.evomaster.core.problem.httpws.auth.HttpWsNoAuth
@@ -71,7 +72,7 @@ class RestCallAction(
7172
*
7273
* TODO check if it could be used to handle issue in BackwardLinkReference
7374
*/
74-
private var weakReference: RestCallAction? = null
75+
private var weakReference: RestCallAction? = null
7576
) : HttpWsAction(auth, isCleanUp, parameters) {
7677

7778
companion object{
@@ -367,6 +368,8 @@ class RestCallAction(
367368
return true // nothing to do
368369
}
369370
if(weakReference!!.isMounted()) {
371+
//make sure both actions are in the same individual
372+
Lazy.assert { this.getRoot() == weakReference!!.getRoot() }
370373
usePreviousLocationId = weakReference!!.creationLocationId()
371374
weakReference = null
372375
return true
@@ -409,4 +412,22 @@ class RestCallAction(
409412

410413
return true
411414
}
415+
416+
/**
417+
* a copy() on an unresolved action with a weakref will crash.
418+
* this is as intended, as weakref would be meaningless when action mounted in a new individual.
419+
* however, there are cases in which we need to "duplicate" an action in an individual.
420+
* in those cases, we must keep the weakref
421+
*/
422+
fun copyKeepingSameWeakRef() : RestCallAction{
423+
if(weakReference == null){
424+
return copy() as RestCallAction
425+
}
426+
val wr = weakReference
427+
weakReference = null
428+
val copy = this.copy() as RestCallAction
429+
copy.weakReference = wr
430+
this.weakReference = wr
431+
return copy
432+
}
412433
}

core/src/main/kotlin/org/evomaster/core/problem/rest/service/RestIndividualBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class RestIndividualBuilder {
145145
"${template.path} vs ${target.path}")
146146
}
147147

148-
val res = template.copy() as RestCallAction
148+
val res = template.copyKeepingSameWeakRef()
149149

150150
res.resetLocalIdRecursively()
151151

@@ -180,7 +180,7 @@ class RestIndividualBuilder {
180180
"${previous.path} vs ${template.path}")
181181
}
182182

183-
val res = template.copy() as RestCallAction
183+
val res = template.copyKeepingSameWeakRef()
184184

185185
res.resetLocalIdRecursively()
186186

0 commit comments

Comments
 (0)