View | Details | Raw Unified | Return to bug 57114
Collapse All | Expand All

(-)a/src/core/org/apache/jmeter/engine/util/CompoundVariable.java (-9 / +13 lines)
Lines 53-59 public class CompoundVariable implements Function { Link Here
53
53
54
    private boolean hasFunction, isDynamic;
54
    private boolean hasFunction, isDynamic;
55
55
56
    private String permanentResults = ""; // $NON-NLS-1$
56
    private String permanentResults;
57
57
58
    private LinkedList<Object> compiledComponents = new LinkedList<Object>();
58
    private LinkedList<Object> compiledComponents = new LinkedList<Object>();
59
59
Lines 95-102 public class CompoundVariable implements Function { Link Here
95
    }
95
    }
96
96
97
    public CompoundVariable() {
97
    public CompoundVariable() {
98
        super();
99
        isDynamic = true;
100
        hasFunction = false;
98
        hasFunction = false;
101
    }
99
    }
102
100
Lines 113-119 public class CompoundVariable implements Function { Link Here
113
    }
111
    }
114
112
115
    public String execute() {
113
    public String execute() {
116
        if (isDynamic) {
114
        if (isDynamic || permanentResults == null) {
117
            JMeterContext context = JMeterContextService.getContext();
115
            JMeterContext context = JMeterContextService.getContext();
118
            SampleResult previousResult = context.getPreviousResult();
116
            SampleResult previousResult = context.getPreviousResult();
119
            Sampler currentSampler = context.getCurrentSampler();
117
            Sampler currentSampler = context.getCurrentSampler();
Lines 137-147 public class CompoundVariable implements Function { Link Here
137
        if (compiledComponents == null || compiledComponents.size() == 0) {
135
        if (compiledComponents == null || compiledComponents.size() == 0) {
138
            return ""; // $NON-NLS-1$
136
            return ""; // $NON-NLS-1$
139
        }
137
        }
140
        boolean testDynamic = false;
141
        StringBuilder results = new StringBuilder();
138
        StringBuilder results = new StringBuilder();
142
        for (Object item : compiledComponents) {
139
        for (Object item : compiledComponents) {
143
            if (item instanceof Function) {
140
            if (item instanceof Function) {
144
                testDynamic = true;
145
                try {
141
                try {
146
                    results.append(((Function) item).execute(previousResult, currentSampler));
142
                    results.append(((Function) item).execute(previousResult, currentSampler));
147
                } catch (InvalidVariableException e) {
143
                } catch (InvalidVariableException e) {
Lines 151-164 public class CompoundVariable implements Function { Link Here
151
                    }
147
                    }
152
                }
148
                }
153
            } else if (item instanceof SimpleVariable) {
149
            } else if (item instanceof SimpleVariable) {
154
                testDynamic = true;
155
                results.append(((SimpleVariable) item).toString());
150
                results.append(((SimpleVariable) item).toString());
156
            } else {
151
            } else {
157
                results.append(item);
152
                results.append(item);
158
            }
153
            }
159
        }
154
        }
160
        if (!testDynamic) {
155
        if (!isDynamic) {
161
            isDynamic = false;
162
            permanentResults = results.toString();
156
            permanentResults = results.toString();
163
        }
157
        }
164
        return results.toString();
158
        return results.toString();
Lines 169-174 public class CompoundVariable implements Function { Link Here
169
        CompoundVariable func = new CompoundVariable();
163
        CompoundVariable func = new CompoundVariable();
170
        func.compiledComponents = (LinkedList<Object>) compiledComponents.clone();
164
        func.compiledComponents = (LinkedList<Object>) compiledComponents.clone();
171
        func.rawParameters = rawParameters;
165
        func.rawParameters = rawParameters;
166
        func.hasFunction = hasFunction;
167
        func.isDynamic = isDynamic;
172
        return func;
168
        return func;
173
    }
169
    }
174
170
Lines 194-199 public class CompoundVariable implements Function { Link Here
194
        if (compiledComponents.size() > 1 || !(compiledComponents.get(0) instanceof String)) {
190
        if (compiledComponents.size() > 1 || !(compiledComponents.get(0) instanceof String)) {
195
            hasFunction = true;
191
            hasFunction = true;
196
        }
192
        }
193
        permanentResults = null; // To be calculated and cached on first execution
194
        isDynamic = false;
195
        for (Object item : compiledComponents) {
196
            if (item instanceof Function || item instanceof SimpleVariable) {
197
                isDynamic = true;
198
                break;
199
            }
200
        }
197
    }
201
    }
198
202
199
    static Object getNamedFunction(String functionName) throws InvalidVariableException {
203
    static Object getNamedFunction(String functionName) throws InvalidVariableException {
(-)a/src/core/org/apache/jmeter/functions/AbstractFunction.java (-7 / +4 lines)
Lines 34-42 public abstract class AbstractFunction implements Function { Link Here
34
34
35
    /**
35
    /**
36
     * <p><b>
36
     * <p><b>
37
     * N.B. setParameters() and execute() are called from different threads,
37
     * N.B. execute() should be synchronized if function is operating with non-thread-safe
38
     * so both must be synchronized unless there are no parameters to save
38
     * objects (e.g. operates with files).
39
     * </b></p>
39
     * </b></p>
40
     * JMeter ensures setParameters() happens-before execute(): setParameters is executed in main thread,
41
     * and worker threads are started after that.
40
     * @see Function#execute(SampleResult, Sampler)
42
     * @see Function#execute(SampleResult, Sampler)
41
     */
43
     */
42
    @Override
44
    @Override
Lines 51-61 public abstract class AbstractFunction implements Function { Link Here
51
53
52
    /**
54
    /**
53
     *
55
     *
54
     * <p><b>
55
     * N.B. setParameters() and execute() are called from different threads,
56
     * so both must be synchronized unless there are no parameters to save
57
     * </b></p>
58
     *
59
     * @see Function#setParameters(Collection)
56
     * @see Function#setParameters(Collection)
60
     * <br/>
57
     * <br/>
61
     * Note: This is always called even if no parameters are provided
58
     * Note: This is always called even if no parameters are provided
(-)a/src/functions/org/apache/jmeter/functions/AbstractHostIPName.java (-1 / +1 lines)
Lines 71-77 abstract class AbstractHostIPName extends AbstractFunction { Link Here
71
71
72
    /** {@inheritDoc} */
72
    /** {@inheritDoc} */
73
    @Override
73
    @Override
74
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
74
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
75
        checkParameterCount(parameters, 0, 1);
75
        checkParameterCount(parameters, 0, 1);
76
        values = parameters.toArray();
76
        values = parameters.toArray();
77
    }
77
    }
(-)a/src/functions/org/apache/jmeter/functions/CSVRead.java (-4 / +8 lines)
Lines 69-82 public class CSVRead extends AbstractFunction { Link Here
69
69
70
    /** {@inheritDoc} */
70
    /** {@inheritDoc} */
71
    @Override
71
    @Override
72
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
72
    public String execute(SampleResult previousResult, Sampler currentSampler)
73
            throws InvalidVariableException {
73
            throws InvalidVariableException {
74
        String myValue = ""; //$NON-NLS-1$
74
        String myValue = ""; //$NON-NLS-1$
75
75
76
        String fileName = ((org.apache.jmeter.engine.util.CompoundVariable) values[0]).execute();
76
        String fileName = ((org.apache.jmeter.engine.util.CompoundVariable) values[0]).execute();
77
        String columnOrNext = ((org.apache.jmeter.engine.util.CompoundVariable) values[1]).execute();
77
        String columnOrNext = ((org.apache.jmeter.engine.util.CompoundVariable) values[1]).execute();
78
78
79
        log.debug("execute (" + fileName + " , " + columnOrNext + ")   ");
79
        if (log.isDebugEnabled()) {
80
            log.debug("execute (" + fileName + " , " + columnOrNext + ")   ");
81
        }
80
82
81
        // Process __CSVRead(filename,*ALIAS)
83
        // Process __CSVRead(filename,*ALIAS)
82
        if (columnOrNext.startsWith("*")) { //$NON-NLS-1$
84
        if (columnOrNext.startsWith("*")) { //$NON-NLS-1$
Lines 115-121 public class CSVRead extends AbstractFunction { Link Here
115
                    + FileWrapper.getCurrentRow(fileName) + " " + e.toString());
117
                    + FileWrapper.getCurrentRow(fileName) + " " + e.toString());
116
        }
118
        }
117
119
118
        log.debug("execute value: " + myValue);
120
        if (log.isDebugEnabled()) {
121
            log.debug("execute value: " + myValue);
122
        }
119
123
120
        return myValue;
124
        return myValue;
121
    }
125
    }
Lines 134-140 public class CSVRead extends AbstractFunction { Link Here
134
138
135
    /** {@inheritDoc} */
139
    /** {@inheritDoc} */
136
    @Override
140
    @Override
137
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
141
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
138
        log.debug("setParameter - Collection.size=" + parameters.size());
142
        log.debug("setParameter - Collection.size=" + parameters.size());
139
143
140
        values = parameters.toArray();
144
        values = parameters.toArray();
(-)a/src/functions/org/apache/jmeter/functions/CharFunction.java (-2 / +2 lines)
Lines 52-58 public class CharFunction extends AbstractFunction { Link Here
52
52
53
    /** {@inheritDoc} */
53
    /** {@inheritDoc} */
54
    @Override
54
    @Override
55
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
55
    public String execute(SampleResult previousResult, Sampler currentSampler)
56
            throws InvalidVariableException {
56
            throws InvalidVariableException {
57
57
58
        StringBuilder sb = new StringBuilder(values.length);
58
        StringBuilder sb = new StringBuilder(values.length);
Lines 72-78 public class CharFunction extends AbstractFunction { Link Here
72
72
73
    /** {@inheritDoc} */
73
    /** {@inheritDoc} */
74
    @Override
74
    @Override
75
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
75
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
76
        checkMinParameterCount(parameters, 1);
76
        checkMinParameterCount(parameters, 1);
77
        values = parameters.toArray();
77
        values = parameters.toArray();
78
    }
78
    }
(-)a/src/functions/org/apache/jmeter/functions/EscapeHtml.java (-2 / +2 lines)
Lines 64-70 public class EscapeHtml extends AbstractFunction { Link Here
64
64
65
    /** {@inheritDoc} */
65
    /** {@inheritDoc} */
66
    @Override
66
    @Override
67
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
67
    public String execute(SampleResult previousResult, Sampler currentSampler)
68
            throws InvalidVariableException {
68
            throws InvalidVariableException {
69
69
70
        String rawString = ((CompoundVariable) values[0]).execute();
70
        String rawString = ((CompoundVariable) values[0]).execute();
Lines 74-80 public class EscapeHtml extends AbstractFunction { Link Here
74
74
75
    /** {@inheritDoc} */
75
    /** {@inheritDoc} */
76
    @Override
76
    @Override
77
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
77
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
78
        checkParameterCount(parameters, 1);
78
        checkParameterCount(parameters, 1);
79
        values = parameters.toArray();
79
        values = parameters.toArray();
80
    }
80
    }
(-)a/src/functions/org/apache/jmeter/functions/EscapeOroRegexpChars.java (-1 / +1 lines)
Lines 64-70 public class EscapeOroRegexpChars extends AbstractFunction { Link Here
64
64
65
    /** {@inheritDoc} */
65
    /** {@inheritDoc} */
66
    @Override
66
    @Override
67
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
67
    public String execute(SampleResult previousResult, Sampler currentSampler)
68
            throws InvalidVariableException {
68
            throws InvalidVariableException {
69
69
70
        String valueToEscape = values[0].execute();       
70
        String valueToEscape = values[0].execute();       
(-)a/src/functions/org/apache/jmeter/functions/EvalFunction.java (-2 / +2 lines)
Lines 58-64 public class EvalFunction extends AbstractFunction { Link Here
58
58
59
    /** {@inheritDoc} */
59
    /** {@inheritDoc} */
60
    @Override
60
    @Override
61
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
61
    public String execute(SampleResult previousResult, Sampler currentSampler)
62
            throws InvalidVariableException {
62
            throws InvalidVariableException {
63
        String parameter = ((CompoundVariable) values[0]).execute();
63
        String parameter = ((CompoundVariable) values[0]).execute();
64
        CompoundVariable cv = new CompoundVariable(parameter);
64
        CompoundVariable cv = new CompoundVariable(parameter);
Lines 67-73 public class EvalFunction extends AbstractFunction { Link Here
67
67
68
    /** {@inheritDoc} */
68
    /** {@inheritDoc} */
69
    @Override
69
    @Override
70
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
70
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
71
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
71
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
72
        values = parameters.toArray();
72
        values = parameters.toArray();
73
    }
73
    }
(-)a/src/functions/org/apache/jmeter/functions/EvalVarFunction.java (-2 / +2 lines)
Lines 63-69 public class EvalVarFunction extends AbstractFunction { Link Here
63
63
64
    /** {@inheritDoc} */
64
    /** {@inheritDoc} */
65
    @Override
65
    @Override
66
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
66
    public String execute(SampleResult previousResult, Sampler currentSampler)
67
            throws InvalidVariableException {
67
            throws InvalidVariableException {
68
        String variableName = ((CompoundVariable) values[0]).execute();
68
        String variableName = ((CompoundVariable) values[0]).execute();
69
        final JMeterVariables vars = getVariables();
69
        final JMeterVariables vars = getVariables();
Lines 78-84 public class EvalVarFunction extends AbstractFunction { Link Here
78
78
79
    /** {@inheritDoc} */
79
    /** {@inheritDoc} */
80
    @Override
80
    @Override
81
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
81
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
82
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
82
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
83
        values = parameters.toArray();
83
        values = parameters.toArray();
84
    }
84
    }
(-)a/src/functions/org/apache/jmeter/functions/FileToString.java (-2 / +2 lines)
Lines 78-84 public class FileToString extends AbstractFunction { Link Here
78
78
79
    /** {@inheritDoc} */
79
    /** {@inheritDoc} */
80
    @Override
80
    @Override
81
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
81
    public String execute(SampleResult previousResult, Sampler currentSampler)
82
            throws InvalidVariableException {
82
            throws InvalidVariableException {
83
83
84
        String fileName = ((CompoundVariable) values[0]).execute();
84
        String fileName = ((CompoundVariable) values[0]).execute();
Lines 124-130 public class FileToString extends AbstractFunction { Link Here
124
124
125
    /** {@inheritDoc} */
125
    /** {@inheritDoc} */
126
    @Override
126
    @Override
127
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
127
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
128
        checkParameterCount(parameters, MIN_PARAM_COUNT, MAX_PARAM_COUNT);
128
        checkParameterCount(parameters, MIN_PARAM_COUNT, MAX_PARAM_COUNT);
129
        values = parameters.toArray();
129
        values = parameters.toArray();
130
    }
130
    }
(-)a/src/functions/org/apache/jmeter/functions/IntSum.java (-2 / +2 lines)
Lines 55-61 public class IntSum extends AbstractFunction { Link Here
55
55
56
    /** {@inheritDoc} */
56
    /** {@inheritDoc} */
57
    @Override
57
    @Override
58
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
58
    public String execute(SampleResult previousResult, Sampler currentSampler)
59
            throws InvalidVariableException {
59
            throws InvalidVariableException {
60
60
61
        JMeterVariables vars = getVariables();
61
        JMeterVariables vars = getVariables();
Lines 87-93 public class IntSum extends AbstractFunction { Link Here
87
87
88
    /** {@inheritDoc} */
88
    /** {@inheritDoc} */
89
    @Override
89
    @Override
90
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
90
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
91
        checkMinParameterCount(parameters, 2);
91
        checkMinParameterCount(parameters, 2);
92
        values = parameters.toArray();
92
        values = parameters.toArray();
93
    }
93
    }
(-)a/src/functions/org/apache/jmeter/functions/IterationCounter.java (-5 / +6 lines)
Lines 68-78 public class IterationCounter extends AbstractFunction { Link Here
68
68
69
    /** {@inheritDoc} */
69
    /** {@inheritDoc} */
70
    @Override
70
    @Override
71
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
71
    public String execute(SampleResult previousResult, Sampler currentSampler)
72
            throws InvalidVariableException {
72
            throws InvalidVariableException {
73
73
74
        globalCounter++;
75
76
        JMeterVariables vars = getVariables();
74
        JMeterVariables vars = getVariables();
77
75
78
        boolean perThread = Boolean.parseBoolean(((CompoundVariable) variables[0]).execute());
76
        boolean perThread = Boolean.parseBoolean(((CompoundVariable) variables[0]).execute());
Lines 90-96 public class IterationCounter extends AbstractFunction { Link Here
90
            perThreadInt.set(Integer.valueOf(threadCounter));
88
            perThreadInt.set(Integer.valueOf(threadCounter));
91
            counterString = String.valueOf(threadCounter);
89
            counterString = String.valueOf(threadCounter);
92
        } else {
90
        } else {
93
            counterString = String.valueOf(globalCounter);
91
            synchronized (this) {
92
                globalCounter++;
93
                counterString = String.valueOf(globalCounter);
94
            }
94
        }
95
        }
95
96
96
        // vars will be null on Test Plan
97
        // vars will be null on Test Plan
Lines 102-108 public class IterationCounter extends AbstractFunction { Link Here
102
103
103
    /** {@inheritDoc} */
104
    /** {@inheritDoc} */
104
    @Override
105
    @Override
105
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
106
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
106
        checkParameterCount(parameters, 1, 2);
107
        checkParameterCount(parameters, 1, 2);
107
        variables = parameters.toArray();
108
        variables = parameters.toArray();
108
    }
109
    }
(-)a/src/functions/org/apache/jmeter/functions/JavaScript.java (-2 / +2 lines)
Lines 59-65 public class JavaScript extends AbstractFunction { Link Here
59
59
60
    /** {@inheritDoc} */
60
    /** {@inheritDoc} */
61
    @Override
61
    @Override
62
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
62
    public String execute(SampleResult previousResult, Sampler currentSampler)
63
            throws InvalidVariableException {
63
            throws InvalidVariableException {
64
64
65
        JMeterContext jmctx = JMeterContextService.getContext();
65
        JMeterContext jmctx = JMeterContextService.getContext();
Lines 105-111 public class JavaScript extends AbstractFunction { Link Here
105
105
106
    /** {@inheritDoc} */
106
    /** {@inheritDoc} */
107
    @Override
107
    @Override
108
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
108
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
109
        checkParameterCount(parameters, 1, 2);
109
        checkParameterCount(parameters, 1, 2);
110
        values = parameters.toArray();
110
        values = parameters.toArray();
111
    }
111
    }
(-)a/src/functions/org/apache/jmeter/functions/Jexl2Function.java (-2 / +2 lines)
Lines 60-66 public class Jexl2Function extends AbstractFunction implements ThreadListener { Link Here
60
60
61
    /** {@inheritDoc} */
61
    /** {@inheritDoc} */
62
    @Override
62
    @Override
63
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
63
    public String execute(SampleResult previousResult, Sampler currentSampler)
64
            throws InvalidVariableException
64
            throws InvalidVariableException
65
    {
65
    {
66
        String str = ""; //$NON-NLS-1$
66
        String str = ""; //$NON-NLS-1$
Lines 139-145 public class Jexl2Function extends AbstractFunction implements ThreadListener { Link Here
139
139
140
    /** {@inheritDoc} */
140
    /** {@inheritDoc} */
141
    @Override
141
    @Override
142
    public synchronized void setParameters(Collection<CompoundVariable> parameters)
142
    public void setParameters(Collection<CompoundVariable> parameters)
143
            throws InvalidVariableException
143
            throws InvalidVariableException
144
    {
144
    {
145
        checkParameterCount(parameters, 1, 2);
145
        checkParameterCount(parameters, 1, 2);
(-)a/src/functions/org/apache/jmeter/functions/JexlFunction.java (-2 / +2 lines)
Lines 58-64 public class JexlFunction extends AbstractFunction { Link Here
58
58
59
    /** {@inheritDoc} */
59
    /** {@inheritDoc} */
60
    @Override
60
    @Override
61
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
61
    public String execute(SampleResult previousResult, Sampler currentSampler)
62
            throws InvalidVariableException
62
            throws InvalidVariableException
63
    {
63
    {
64
        String str = ""; //$NON-NLS-1$
64
        String str = ""; //$NON-NLS-1$
Lines 123-129 public class JexlFunction extends AbstractFunction { Link Here
123
123
124
    /** {@inheritDoc} */
124
    /** {@inheritDoc} */
125
    @Override
125
    @Override
126
    public synchronized void setParameters(Collection<CompoundVariable> parameters)
126
    public void setParameters(Collection<CompoundVariable> parameters)
127
            throws InvalidVariableException
127
            throws InvalidVariableException
128
    {
128
    {
129
        checkParameterCount(parameters, 1, 2);
129
        checkParameterCount(parameters, 1, 2);
(-)a/src/functions/org/apache/jmeter/functions/LogFunction.java (-1 / +2 lines)
Lines 78-83 public class LogFunction extends AbstractFunction { Link Here
78
    @Override
78
    @Override
79
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
79
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
80
            throws InvalidVariableException {
80
            throws InvalidVariableException {
81
        // The method is synchronized to avoid interference of messages from multiple threads
81
        String stringToLog = ((CompoundVariable) values[0]).execute();
82
        String stringToLog = ((CompoundVariable) values[0]).execute();
82
83
83
        String priorityString;
84
        String priorityString;
Lines 162-168 public class LogFunction extends AbstractFunction { Link Here
162
163
163
    /** {@inheritDoc} */
164
    /** {@inheritDoc} */
164
    @Override
165
    @Override
165
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
166
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
166
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
167
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
167
        values = parameters.toArray();
168
        values = parameters.toArray();
168
    }
169
    }
(-)a/src/functions/org/apache/jmeter/functions/LogFunction2.java (-2 / +2 lines)
Lines 71-77 public class LogFunction2 extends AbstractFunction { Link Here
71
71
72
    /** {@inheritDoc} */
72
    /** {@inheritDoc} */
73
    @Override
73
    @Override
74
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
74
    public String execute(SampleResult previousResult, Sampler currentSampler)
75
            throws InvalidVariableException {
75
            throws InvalidVariableException {
76
        String stringToLog = ((CompoundVariable) values[0]).execute();
76
        String stringToLog = ((CompoundVariable) values[0]).execute();
77
77
Lines 98-104 public class LogFunction2 extends AbstractFunction { Link Here
98
98
99
    /** {@inheritDoc} */
99
    /** {@inheritDoc} */
100
    @Override
100
    @Override
101
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
101
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
102
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
102
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
103
        values = parameters.toArray();
103
        values = parameters.toArray();
104
    }
104
    }
(-)a/src/functions/org/apache/jmeter/functions/LongSum.java (-2 / +2 lines)
Lines 55-61 public class LongSum extends AbstractFunction { Link Here
55
55
56
    /** {@inheritDoc} */
56
    /** {@inheritDoc} */
57
    @Override
57
    @Override
58
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
58
    public String execute(SampleResult previousResult, Sampler currentSampler)
59
            throws InvalidVariableException {
59
            throws InvalidVariableException {
60
60
61
        JMeterVariables vars = getVariables();
61
        JMeterVariables vars = getVariables();
Lines 87-93 public class LongSum extends AbstractFunction { Link Here
87
87
88
    /** {@inheritDoc} */
88
    /** {@inheritDoc} */
89
    @Override
89
    @Override
90
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
90
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
91
        checkMinParameterCount(parameters, 2);
91
        checkMinParameterCount(parameters, 2);
92
        values = parameters.toArray();
92
        values = parameters.toArray();
93
    }
93
    }
(-)a/src/functions/org/apache/jmeter/functions/Property.java (-2 / +2 lines)
Lines 65-71 public class Property extends AbstractFunction { Link Here
65
65
66
    /** {@inheritDoc} */
66
    /** {@inheritDoc} */
67
    @Override
67
    @Override
68
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
68
    public String execute(SampleResult previousResult, Sampler currentSampler)
69
            throws InvalidVariableException {
69
            throws InvalidVariableException {
70
        String propertyName = ((CompoundVariable) values[0]).execute();
70
        String propertyName = ((CompoundVariable) values[0]).execute();
71
        String propertyDefault = propertyName;
71
        String propertyDefault = propertyName;
Lines 88-94 public class Property extends AbstractFunction { Link Here
88
88
89
    /** {@inheritDoc} */
89
    /** {@inheritDoc} */
90
    @Override
90
    @Override
91
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
91
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
92
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
92
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
93
        values = parameters.toArray();
93
        values = parameters.toArray();
94
    }
94
    }
(-)a/src/functions/org/apache/jmeter/functions/Property2.java (-2 / +2 lines)
Lines 69-75 public class Property2 extends AbstractFunction { Link Here
69
69
70
    /** {@inheritDoc} */
70
    /** {@inheritDoc} */
71
    @Override
71
    @Override
72
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
72
    public String execute(SampleResult previousResult, Sampler currentSampler)
73
            throws InvalidVariableException {
73
            throws InvalidVariableException {
74
        String propertyName = ((CompoundVariable) values[0]).execute();
74
        String propertyName = ((CompoundVariable) values[0]).execute();
75
75
Lines 86-92 public class Property2 extends AbstractFunction { Link Here
86
86
87
    /** {@inheritDoc} */
87
    /** {@inheritDoc} */
88
    @Override
88
    @Override
89
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
89
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
90
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
90
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
91
        values = parameters.toArray();
91
        values = parameters.toArray();
92
    }
92
    }
(-)a/src/functions/org/apache/jmeter/functions/Random.java (-2 / +2 lines)
Lines 55-61 public class Random extends AbstractFunction { Link Here
55
55
56
    /** {@inheritDoc} */
56
    /** {@inheritDoc} */
57
    @Override
57
    @Override
58
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
58
    public String execute(SampleResult previousResult, Sampler currentSampler)
59
            throws InvalidVariableException {
59
            throws InvalidVariableException {
60
60
61
61
Lines 80-86 public class Random extends AbstractFunction { Link Here
80
80
81
    /** {@inheritDoc} */
81
    /** {@inheritDoc} */
82
    @Override
82
    @Override
83
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
83
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
84
        checkParameterCount(parameters, 2, 3);
84
        checkParameterCount(parameters, 2, 3);
85
        Object[] values = parameters.toArray();
85
        Object[] values = parameters.toArray();
86
86
(-)a/src/functions/org/apache/jmeter/functions/RandomString.java (-2 / +2 lines)
Lines 69-75 public class RandomString extends AbstractFunction { Link Here
69
69
70
    /** {@inheritDoc} */
70
    /** {@inheritDoc} */
71
    @Override
71
    @Override
72
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
72
    public String execute(SampleResult previousResult, Sampler currentSampler)
73
            throws InvalidVariableException {
73
            throws InvalidVariableException {
74
74
75
        int length = Integer.parseInt(values[0].execute());
75
        int length = Integer.parseInt(values[0].execute());
Lines 112-118 public class RandomString extends AbstractFunction { Link Here
112
112
113
    /** {@inheritDoc} */
113
    /** {@inheritDoc} */
114
    @Override
114
    @Override
115
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
115
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
116
        checkParameterCount(parameters, MIN_PARAM_COUNT, MAX_PARAM_COUNT);
116
        checkParameterCount(parameters, MIN_PARAM_COUNT, MAX_PARAM_COUNT);
117
        values = parameters.toArray(new CompoundVariable[parameters.size()]);
117
        values = parameters.toArray(new CompoundVariable[parameters.size()]);
118
    }
118
    }
(-)a/src/functions/org/apache/jmeter/functions/RegexFunction.java (-2 / +4 lines)
Lines 57-62 public class RegexFunction extends AbstractFunction { Link Here
57
57
58
    private Object[] values;// Parameters are stored here
58
    private Object[] values;// Parameters are stored here
59
59
60
    // Using the same Random across threads might result in pool performance
61
    // It might make sense to use ThreadLocalRandom or ThreadLocal<Random>
60
    private static final Random rand = new Random();
62
    private static final Random rand = new Random();
61
63
62
    private static final List<String> desc = new LinkedList<String>();
64
    private static final List<String> desc = new LinkedList<String>();
Lines 86-92 public class RegexFunction extends AbstractFunction { Link Here
86
88
87
    /** {@inheritDoc} */
89
    /** {@inheritDoc} */
88
    @Override
90
    @Override
89
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
91
    public String execute(SampleResult previousResult, Sampler currentSampler)
90
            throws InvalidVariableException {
92
            throws InvalidVariableException {
91
        String valueIndex = ""; //$NON-NLS-1$
93
        String valueIndex = ""; //$NON-NLS-1$
92
        String defaultValue = ""; //$NON-NLS-1$
94
        String defaultValue = ""; //$NON-NLS-1$
Lines 242-248 public class RegexFunction extends AbstractFunction { Link Here
242
244
243
    /** {@inheritDoc} */
245
    /** {@inheritDoc} */
244
    @Override
246
    @Override
245
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
247
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
246
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
248
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
247
        values = parameters.toArray();
249
        values = parameters.toArray();
248
    }
250
    }
(-)a/src/functions/org/apache/jmeter/functions/SamplerName.java (-1 / +1 lines)
Lines 69-75 public class SamplerName extends AbstractFunction { Link Here
69
69
70
    /** {@inheritDoc} */
70
    /** {@inheritDoc} */
71
    @Override
71
    @Override
72
    public synchronized void setParameters(Collection<CompoundVariable> parameters)
72
    public void setParameters(Collection<CompoundVariable> parameters)
73
            throws InvalidVariableException {
73
            throws InvalidVariableException {
74
        checkParameterCount(parameters, 0, 1);
74
        checkParameterCount(parameters, 0, 1);
75
        values = parameters.toArray();
75
        values = parameters.toArray();
(-)a/src/functions/org/apache/jmeter/functions/SetProperty.java (-2 / +2 lines)
Lines 64-70 public class SetProperty extends AbstractFunction { Link Here
64
64
65
    /** {@inheritDoc} */
65
    /** {@inheritDoc} */
66
    @Override
66
    @Override
67
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
67
    public String execute(SampleResult previousResult, Sampler currentSampler)
68
            throws InvalidVariableException {
68
            throws InvalidVariableException {
69
        String propertyName = ((CompoundVariable) values[0]).execute();
69
        String propertyName = ((CompoundVariable) values[0]).execute();
70
70
Lines 85-91 public class SetProperty extends AbstractFunction { Link Here
85
85
86
    /** {@inheritDoc} */
86
    /** {@inheritDoc} */
87
    @Override
87
    @Override
88
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
88
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
89
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
89
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
90
        values = parameters.toArray();
90
        values = parameters.toArray();
91
    }
91
    }
(-)a/src/functions/org/apache/jmeter/functions/SplitFunction.java (-2 / +2 lines)
Lines 79-85 public class SplitFunction extends AbstractFunction { Link Here
79
79
80
    /** {@inheritDoc} */
80
    /** {@inheritDoc} */
81
    @Override
81
    @Override
82
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
82
    public String execute(SampleResult previousResult, Sampler currentSampler)
83
            throws InvalidVariableException {
83
            throws InvalidVariableException {
84
        JMeterVariables vars = getVariables();
84
        JMeterVariables vars = getVariables();
85
85
Lines 110-116 public class SplitFunction extends AbstractFunction { Link Here
110
110
111
    /** {@inheritDoc} */
111
    /** {@inheritDoc} */
112
    @Override
112
    @Override
113
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
113
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
114
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
114
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
115
        values = parameters.toArray();
115
        values = parameters.toArray();
116
    }
116
    }
(-)a/src/functions/org/apache/jmeter/functions/TestPlanName.java (-1 / +1 lines)
Lines 46-52 public class TestPlanName extends AbstractFunction { Link Here
46
46
47
    /** {@inheritDoc} */
47
    /** {@inheritDoc} */
48
    @Override
48
    @Override
49
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
49
    public String execute(SampleResult previousResult, Sampler currentSampler)
50
            throws InvalidVariableException {
50
            throws InvalidVariableException {
51
        return FileServer.getFileServer().getScriptName();
51
        return FileServer.getFileServer().getScriptName();
52
    }
52
    }
(-)a/src/functions/org/apache/jmeter/functions/TimeFunction.java (-2 / +3 lines)
Lines 75-81 public class TimeFunction extends AbstractFunction { Link Here
75
75
76
    /** {@inheritDoc} */
76
    /** {@inheritDoc} */
77
    @Override
77
    @Override
78
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
78
    public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
79
        String datetime;
79
        String datetime;
80
        if (format.length() == 0){// Default to milliseconds
80
        if (format.length() == 0){// Default to milliseconds
81
            datetime = Long.toString(System.currentTimeMillis());
81
            datetime = Long.toString(System.currentTimeMillis());
Lines 85-90 public class TimeFunction extends AbstractFunction { Link Here
85
            if (fmt == null) {
85
            if (fmt == null) {
86
                fmt = format;// Not found
86
                fmt = format;// Not found
87
            }
87
            }
88
            // TODO: avoid regexp parsing in loop
88
            if (fmt.matches("/\\d+")) { // divisor is a positive number
89
            if (fmt.matches("/\\d+")) { // divisor is a positive number
89
                long div = Long.parseLong(fmt.substring(1)); // should never case NFE
90
                long div = Long.parseLong(fmt.substring(1)); // should never case NFE
90
                datetime = Long.toString((System.currentTimeMillis() / div));
91
                datetime = Long.toString((System.currentTimeMillis() / div));
Lines 105-111 public class TimeFunction extends AbstractFunction { Link Here
105
106
106
    /** {@inheritDoc} */
107
    /** {@inheritDoc} */
107
    @Override
108
    @Override
108
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
109
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
109
110
110
        checkParameterCount(parameters, 0, 2);
111
        checkParameterCount(parameters, 0, 2);
111
112
(-)a/src/functions/org/apache/jmeter/functions/UnEscape.java (-2 / +2 lines)
Lines 54-60 public class UnEscape extends AbstractFunction { Link Here
54
54
55
    /** {@inheritDoc} */
55
    /** {@inheritDoc} */
56
    @Override
56
    @Override
57
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
57
    public String execute(SampleResult previousResult, Sampler currentSampler)
58
            throws InvalidVariableException {
58
            throws InvalidVariableException {
59
59
60
        String rawString = ((CompoundVariable) values[0]).execute();
60
        String rawString = ((CompoundVariable) values[0]).execute();
Lines 64-70 public class UnEscape extends AbstractFunction { Link Here
64
64
65
    /** {@inheritDoc} */
65
    /** {@inheritDoc} */
66
    @Override
66
    @Override
67
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
67
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
68
        checkParameterCount(parameters, 1);
68
        checkParameterCount(parameters, 1);
69
        values = parameters.toArray();
69
        values = parameters.toArray();
70
    }
70
    }
(-)a/src/functions/org/apache/jmeter/functions/UnEscapeHtml.java (-2 / +2 lines)
Lines 60-66 public class UnEscapeHtml extends AbstractFunction { Link Here
60
60
61
    /** {@inheritDoc} */
61
    /** {@inheritDoc} */
62
    @Override
62
    @Override
63
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
63
    public String execute(SampleResult previousResult, Sampler currentSampler)
64
            throws InvalidVariableException {
64
            throws InvalidVariableException {
65
65
66
        String escapedString = ((CompoundVariable) values[0]).execute();
66
        String escapedString = ((CompoundVariable) values[0]).execute();
Lines 70-76 public class UnEscapeHtml extends AbstractFunction { Link Here
70
70
71
    /** {@inheritDoc} */
71
    /** {@inheritDoc} */
72
    @Override
72
    @Override
73
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
73
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
74
        checkParameterCount(parameters, 1);
74
        checkParameterCount(parameters, 1);
75
        values = parameters.toArray();
75
        values = parameters.toArray();
76
    }
76
    }
(-)a/src/functions/org/apache/jmeter/functions/UrlDecode.java (-2 / +2 lines)
Lines 54-60 public class UrlDecode extends AbstractFunction { Link Here
54
54
55
    /** {@inheritDoc} */
55
    /** {@inheritDoc} */
56
    @Override
56
    @Override
57
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
57
    public String execute(SampleResult previousResult, Sampler currentSampler)
58
            throws InvalidVariableException {
58
            throws InvalidVariableException {
59
        String decodeString = ""; //$NON-NLS-1$
59
        String decodeString = ""; //$NON-NLS-1$
60
        try {
60
        try {
Lines 68-74 public class UrlDecode extends AbstractFunction { Link Here
68
68
69
    /** {@inheritDoc} */
69
    /** {@inheritDoc} */
70
    @Override
70
    @Override
71
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
71
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
72
        checkParameterCount(parameters, 1);
72
        checkParameterCount(parameters, 1);
73
        values = parameters.toArray();
73
        values = parameters.toArray();
74
    }
74
    }
(-)a/src/functions/org/apache/jmeter/functions/UrlEncode.java (-2 / +2 lines)
Lines 54-60 public class UrlEncode extends AbstractFunction { Link Here
54
54
55
    /** {@inheritDoc} */
55
    /** {@inheritDoc} */
56
    @Override
56
    @Override
57
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
57
    public String execute(SampleResult previousResult, Sampler currentSampler)
58
            throws InvalidVariableException {
58
            throws InvalidVariableException {
59
        String decodeString = ""; //$NON-NLS-1$
59
        String decodeString = ""; //$NON-NLS-1$
60
        try {
60
        try {
Lines 68-74 public class UrlEncode extends AbstractFunction { Link Here
68
68
69
    /** {@inheritDoc} */
69
    /** {@inheritDoc} */
70
    @Override
70
    @Override
71
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
71
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
72
        checkParameterCount(parameters, 1);
72
        checkParameterCount(parameters, 1);
73
        values = parameters.toArray();
73
        values = parameters.toArray();
74
    }
74
    }
(-)a/src/functions/org/apache/jmeter/functions/Variable.java (-3 / +2 lines)
Lines 60-66 public class Variable extends AbstractFunction { Link Here
60
60
61
    /** {@inheritDoc} */
61
    /** {@inheritDoc} */
62
    @Override
62
    @Override
63
    public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
63
    public String execute(SampleResult previousResult, Sampler currentSampler)
64
            throws InvalidVariableException {
64
            throws InvalidVariableException {
65
        String variableName = ((CompoundVariable) values[0]).execute();
65
        String variableName = ((CompoundVariable) values[0]).execute();
66
        String variableValue = getVariables().get(variableName);
66
        String variableValue = getVariables().get(variableName);
Lines 70-76 public class Variable extends AbstractFunction { Link Here
70
70
71
    /** {@inheritDoc} */
71
    /** {@inheritDoc} */
72
    @Override
72
    @Override
73
    public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
73
    public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
74
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
74
        checkParameterCount(parameters, MIN_PARAMETER_COUNT, MAX_PARAMETER_COUNT);
75
        values = parameters.toArray();
75
        values = parameters.toArray();
76
    }
76
    }
77
- 

Return to bug 57114