2121import org .apache .jmeter .testelement .TestElement ;
2222import org .apache .jmeter .threads .JMeterContext ;
2323import org .apache .jmeter .threads .JMeterContextService ;
24+ import org .apache .jmeter .util .JMeterUtils ;
2425
2526/**
2627 * Class that implements the Function property
2728 */
2829public class FunctionProperty extends AbstractProperty {
2930 private static final long serialVersionUID = 233L ;
31+ private static final boolean FUNCTION_CACHE_PER_ITERATION =
32+ JMeterUtils .getPropDefault ("function.cache.per.iteration" , true );
3033
3134 private transient CompoundVariable function ;
3235
3336 private int testIteration = -1 ;
3437
38+ /**
39+ * The cache will be removed in the subsequent releases.
40+ * For now, it is kept for backward compatibility.
41+ */
3542 private String cacheValue ;
3643
3744 public FunctionProperty (String name , CompoundVariable func ) {
@@ -47,7 +54,7 @@ public FunctionProperty() {
4754 public void setObjectValue (Object v ) {
4855 if (v instanceof CompoundVariable && !isRunningVersion ()) {
4956 function = (CompoundVariable ) v ;
50- } else {
57+ } else if ( FUNCTION_CACHE_PER_ITERATION ) {
5158 cacheValue = v .toString ();
5259 }
5360 }
@@ -87,7 +94,7 @@ public String getStringValue() {
8794 log .debug ("Not running version, return raw function string" );
8895 return function .getRawParameters ();
8996 }
90- if ( !ctx .isSamplingStarted ()) {
97+ if (! FUNCTION_CACHE_PER_ITERATION || !ctx .isSamplingStarted ()) {
9198 return function .execute ();
9299 }
93100 log .debug ("Running version, executing function" );
0 commit comments