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

(-)src/core/org/apache/jmeter/threads/JMeterVariables.java (-2 / +3 lines)
Lines 19-25 Link Here
19
package org.apache.jmeter.threads;
19
package org.apache.jmeter.threads;
20
20
21
import java.util.Collections;
21
import java.util.Collections;
22
import java.util.HashMap;
23
import java.util.Iterator;
22
import java.util.Iterator;
24
import java.util.Map;
23
import java.util.Map;
25
import java.util.Set;
24
import java.util.Set;
Lines 27-38 Link Here
27
26
28
import org.apache.jmeter.util.JMeterUtils;
27
import org.apache.jmeter.util.JMeterUtils;
29
28
29
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
30
30
/**
31
/**
31
 * Class which defines JMeter variables.
32
 * Class which defines JMeter variables.
32
 * These are similar to properties, but they are local to a single thread.
33
 * These are similar to properties, but they are local to a single thread.
33
 */
34
 */
34
public class JMeterVariables {
35
public class JMeterVariables {
35
    private final Map<String, Object> variables = new HashMap<String, Object>();
36
    private final Map<String, Object> variables = new ConcurrentReaderHashMap();
36
37
37
    private int iteration = 0;
38
    private int iteration = 0;
38
39
(-)build.properties (+5 lines)
Lines 91-96 Link Here
91
commons-net.loc             = ${maven2.repo}/commons-net/commons-net/3.0.1
91
commons-net.loc             = ${maven2.repo}/commons-net/commons-net/3.0.1
92
commons-net.md5             = 920c3efc7f8d4d887936ddc3fc9a8316
92
commons-net.md5             = 920c3efc7f8d4d887936ddc3fc9a8316
93
93
94
concurrent.jar             = concurrent-1.3.4.jar
95
concurrent.loc             = ${maven2.repo}/concurrent/concurrent/1.3.4
96
concurrent.md5             = f29b9d930d3426ebc56919eba10fbd4d
97
98
94
excalibur-datasource.jar    = excalibur-datasource-1.1.1.jar
99
excalibur-datasource.jar    = excalibur-datasource-1.1.1.jar
95
excalibur-datasource.loc    = ${maven2.repo}/excalibur-datasource/excalibur-datasource/1.1.1
100
excalibur-datasource.loc    = ${maven2.repo}/excalibur-datasource/excalibur-datasource/1.1.1
96
excalibur-datasource.md5    = 59A9EDFF1005D70DFA638CF3A4D3AD6D
101
excalibur-datasource.md5    = 59A9EDFF1005D70DFA638CF3A4D3AD6D
(-)eclipse.classpath (+1 lines)
Lines 53-58 Link Here
53
	<classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
53
	<classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
54
	<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
54
	<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
55
	<classpathentry kind="lib" path="lib/commons-net-3.0.1.jar"/>
55
	<classpathentry kind="lib" path="lib/commons-net-3.0.1.jar"/>
56
	<classpathentry kind="lib" path="lib/concurrent-1.3.4.jar"/>
56
	<classpathentry kind="lib" path="lib/excalibur-datasource-1.1.1.jar"/>
57
	<classpathentry kind="lib" path="lib/excalibur-datasource-1.1.1.jar"/>
57
	<classpathentry kind="lib" path="lib/excalibur-instrument-1.0.jar"/>
58
	<classpathentry kind="lib" path="lib/excalibur-instrument-1.0.jar"/>
58
	<classpathentry kind="lib" path="lib/excalibur-logger-1.1.jar"/>
59
	<classpathentry kind="lib" path="lib/excalibur-logger-1.1.jar"/>
(-)src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java (-27 / +48 lines)
Lines 30-35 Link Here
30
import java.net.URL;
30
import java.net.URL;
31
import java.util.ArrayList;
31
import java.util.ArrayList;
32
import java.util.Date;
32
import java.util.Date;
33
import java.util.concurrent.locks.ReentrantLock;
33
34
34
import org.apache.commons.httpclient.cookie.CookiePolicy;
35
import org.apache.commons.httpclient.cookie.CookiePolicy;
35
import org.apache.commons.httpclient.cookie.CookieSpec;
36
import org.apache.commons.httpclient.cookie.CookieSpec;
Lines 101-106 Link Here
101
102
102
    public static final String DEFAULT_POLICY = CookiePolicy.BROWSER_COMPATIBILITY;
103
    public static final String DEFAULT_POLICY = CookiePolicy.BROWSER_COMPATIBILITY;
103
104
105
    private final ReentrantLock COOKIE_MANAGER_UPDATE_LOCK = new ReentrantLock();
106
104
    public CookieManager() {
107
    public CookieManager() {
105
        clearCookies(); // Ensure that there is always a collection available
108
        clearCookies(); // Ensure that there is always a collection available
106
    }
109
    }
Lines 153-158 Link Here
153
        writer.println("# JMeter generated Cookie file");// $NON-NLS-1$
156
        writer.println("# JMeter generated Cookie file");// $NON-NLS-1$
154
        PropertyIterator cookies = getCookies().iterator();
157
        PropertyIterator cookies = getCookies().iterator();
155
        long now = System.currentTimeMillis();
158
        long now = System.currentTimeMillis();
159
        // No need for sync as not called during test plan
156
        while (cookies.hasNext()) {
160
        while (cookies.hasNext()) {
157
            Cookie cook = (Cookie) cookies.next().getObjectValue();
161
            Cookie cook = (Cookie) cookies.next().getObjectValue();
158
            final long expiresMillis = cook.getExpiresMillis();
162
            final long expiresMillis = cook.getExpiresMillis();
Lines 183-188 Link Here
183
        // N.B. this must agree with the save() and cookieToString() methods
187
        // N.B. this must agree with the save() and cookieToString() methods
184
        String line;
188
        String line;
185
        try {
189
        try {
190
            // No need for sync as not called during load test
186
            final CollectionProperty cookies = getCookies();
191
            final CollectionProperty cookies = getCookies();
187
            while ((line = reader.readLine()) != null) {
192
            while ((line = reader.readLine()) != null) {
188
                try {
193
                try {
Lines 265-275 Link Here
265
            if (log.isDebugEnabled()) {
270
            if (log.isDebugEnabled()) {
266
                log.debug("Add cookie to store " + c.toString());
271
                log.debug("Add cookie to store " + c.toString());
267
            }
272
            }
268
            getCookies().addItem(c);
273
            try {
274
                COOKIE_MANAGER_UPDATE_LOCK.lock();
275
                getCookies().addItem(c);
276
            } finally {
277
                COOKIE_MANAGER_UPDATE_LOCK.unlock();
278
            }
269
            if (SAVE_COOKIES)  {
279
            if (SAVE_COOKIES)  {
270
                JMeterContext context = getThreadContext();
280
                JMeterContext context = getThreadContext();
271
                if (context.isSamplingStarted()) {
281
                if (context.isSamplingStarted()) {
272
                    context.getVariables().put(COOKIE_NAME_PREFIX+cn, cv);
282
                        context.getVariables().put(COOKIE_NAME_PREFIX+cn, cv);                        
273
                }
283
                }
274
            }
284
            }
275
        }
285
        }
Lines 332-351 Link Here
332
     *
342
     *
333
     */
343
     */
334
    public org.apache.commons.httpclient.Cookie[] getCookiesForUrl(URL url){
344
    public org.apache.commons.httpclient.Cookie[] getCookiesForUrl(URL url){
335
        CollectionProperty jar=getCookies();
345
        org.apache.commons.httpclient.Cookie[] cookies= null;
336
        org.apache.commons.httpclient.Cookie cookies[]=
346
        try {
337
            new org.apache.commons.httpclient.Cookie[jar.size()];
347
            COOKIE_MANAGER_UPDATE_LOCK.lock();
338
        int i=0;
348
            CollectionProperty jar=getCookies();
339
        for (PropertyIterator iter = getCookies().iterator(); iter.hasNext();) {
349
            cookies =
340
            Cookie jmcookie = (Cookie) iter.next().getObjectValue();
350
                new org.apache.commons.httpclient.Cookie[jar.size()];
341
            // Set to running version, to allow function evaluation for the cookie values (bug 28715)
351
            int i=0;
342
            if (ALLOW_VARIABLE_COOKIES) {
352
            for (PropertyIterator iter = getCookies().iterator(); iter.hasNext();) {
343
                jmcookie.setRunningVersion(true);
353
                Cookie jmcookie = (Cookie) iter.next().getObjectValue();
344
            }
354
                // Set to running version, to allow function evaluation for the cookie values (bug 28715)
345
            cookies[i++] = makeCookie(jmcookie);
355
                if (ALLOW_VARIABLE_COOKIES) {
346
            if (ALLOW_VARIABLE_COOKIES) {
356
                    jmcookie.setRunningVersion(true);
347
                jmcookie.setRunningVersion(false);
357
                }
358
                cookies[i++] = makeCookie(jmcookie);
359
                if (ALLOW_VARIABLE_COOKIES) {
360
                    jmcookie.setRunningVersion(false);
361
                }
348
            }
362
            }
363
        } finally {
364
            COOKIE_MANAGER_UPDATE_LOCK.unlock();
349
        }
365
        }
350
        String host = url.getHost();
366
        String host = url.getHost();
351
        String protocol = url.getProtocol();
367
        String protocol = url.getProtocol();
Lines 461-479 Link Here
461
477
462
    private void removeMatchingCookies(Cookie newCookie){
478
    private void removeMatchingCookies(Cookie newCookie){
463
        // Scan for any matching cookies
479
        // Scan for any matching cookies
464
        PropertyIterator iter = getCookies().iterator();
480
        try {
465
        while (iter.hasNext()) {
481
            COOKIE_MANAGER_UPDATE_LOCK.lock();
466
            Cookie cookie = (Cookie) iter.next().getObjectValue();
482
            PropertyIterator iter = getCookies().iterator();
467
            if (cookie == null) {// TODO is this possible?
483
            while (iter.hasNext()) {
468
                continue;
484
                Cookie cookie = (Cookie) iter.next().getObjectValue();
469
            }
485
                if (cookie == null) {// TODO is this possible?
470
            if (match(cookie,newCookie)) {
486
                    continue;
471
                if (log.isDebugEnabled()) {
472
                    log.debug("New Cookie = " + newCookie.toString()
473
                              + " removing matching Cookie " + cookie.toString());
474
                }
487
                }
475
                iter.remove();
488
                if (match(cookie,newCookie)) {
476
            }
489
                    if (log.isDebugEnabled()) {
490
                        log.debug("New Cookie = " + newCookie.toString()
491
                                  + " removing matching Cookie " + cookie.toString());
492
                    }
493
                    iter.remove();
494
                }
495
            }   
496
        } finally {
497
            COOKIE_MANAGER_UPDATE_LOCK.unlock();
477
        }
498
        }
478
    }
499
    }
479
500
(-)build.xml (+3 lines)
Lines 333-338 Link Here
333
    <include name="${lib.dir}/${commons-lang.jar}"/>
333
    <include name="${lib.dir}/${commons-lang.jar}"/>
334
    <include name="${lib.dir}/${commons-logging.jar}"/>
334
    <include name="${lib.dir}/${commons-logging.jar}"/>
335
    <include name="${lib.dir}/${commons-net.jar}"/>
335
    <include name="${lib.dir}/${commons-net.jar}"/>
336
    <include name="${lib.dir}/${concurrent.jar}"/>
336
    <include name="${lib.dir}/${excalibur-datasource.jar}"/>
337
    <include name="${lib.dir}/${excalibur-datasource.jar}"/>
337
    <include name="${lib.dir}/${excalibur-instrument.jar}"/>
338
    <include name="${lib.dir}/${excalibur-instrument.jar}"/>
338
    <include name="${lib.dir}/${excalibur-logger.jar}"/>
339
    <include name="${lib.dir}/${excalibur-logger.jar}"/>
Lines 393-398 Link Here
393
    <pathelement location="${lib.dir}/${commons-lang.jar}"/>
394
    <pathelement location="${lib.dir}/${commons-lang.jar}"/>
394
    <pathelement location="${lib.dir}/${commons-logging.jar}"/>
395
    <pathelement location="${lib.dir}/${commons-logging.jar}"/>
395
    <pathelement location="${lib.dir}/${commons-net.jar}"/>
396
    <pathelement location="${lib.dir}/${commons-net.jar}"/>
397
    <pathelement location="${lib.dir}/${concurrent.jar}"/>
396
    <pathelement location="${lib.dir}/${excalibur-datasource.jar}"/>
398
    <pathelement location="${lib.dir}/${excalibur-datasource.jar}"/>
397
    <pathelement location="${lib.dir}/${excalibur-instrument.jar}"/>
399
    <pathelement location="${lib.dir}/${excalibur-instrument.jar}"/>
398
    <pathelement location="${lib.dir}/${excalibur-logger.jar}"/>
400
    <pathelement location="${lib.dir}/${excalibur-logger.jar}"/>
Lines 2173-2178 Link Here
2173
        <process_jarfile jarname="commons-lang"/>
2175
        <process_jarfile jarname="commons-lang"/>
2174
        <process_jarfile jarname="commons-logging"/>
2176
        <process_jarfile jarname="commons-logging"/>
2175
        <process_jarfile jarname="commons-net"/>
2177
        <process_jarfile jarname="commons-net"/>
2178
        <process_jarfile jarname="concurrent"/>
2176
        <process_jarfile jarname="excalibur-datasource"/>
2179
        <process_jarfile jarname="excalibur-datasource"/>
2177
        <process_jarfile jarname="excalibur-instrument"/>
2180
        <process_jarfile jarname="excalibur-instrument"/>
2178
        <process_jarfile jarname="excalibur-logger"/>
2181
        <process_jarfile jarname="excalibur-logger"/>

Return to bug 51919