1
1
package org.evomaster.core.problem.rest.data
2
2
3
+ import org.evomaster.core.Lazy
3
4
import org.evomaster.core.problem.httpws.HttpWsAction
4
5
import org.evomaster.core.problem.httpws.auth.HttpWsAuthenticationInfo
5
6
import org.evomaster.core.problem.httpws.auth.HttpWsNoAuth
@@ -71,7 +72,7 @@ class RestCallAction(
71
72
*
72
73
* TODO check if it could be used to handle issue in BackwardLinkReference
73
74
*/
74
- private var weakReference : RestCallAction ? = null
75
+ private var weakReference : RestCallAction ? = null
75
76
) : HttpWsAction(auth, isCleanUp, parameters) {
76
77
77
78
companion object {
@@ -367,6 +368,8 @@ class RestCallAction(
367
368
return true // nothing to do
368
369
}
369
370
if (weakReference!! .isMounted()) {
371
+ // make sure both actions are in the same individual
372
+ Lazy .assert { this .getRoot() == weakReference!! .getRoot() }
370
373
usePreviousLocationId = weakReference!! .creationLocationId()
371
374
weakReference = null
372
375
return true
@@ -409,4 +412,22 @@ class RestCallAction(
409
412
410
413
return true
411
414
}
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
+ }
412
433
}
0 commit comments