mirror of https://github.com/apache/jmeter.git
ArrayIndexOutOfBoundsException if "sample_variable" is set in client but not server
Bugzilla Id: 54685
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1461911 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: ec09573639
This commit is contained in:
parent
8499e2b457
commit
82432c9a43
|
|
@ -0,0 +1,2 @@
|
|||
label,responseCode,responseMessage,threadName,dataType,success,bytes,"REFERENCE","JSESSIONID"
|
||||
"sample_variables=REFERENCE,JSESSIONID REFERENCE=reference JSESSIONID=jsessionId",,,Thread Group 1-1,,true,0,reference,jsessionId
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jmeterTestPlan version="1.2" properties="2.5" jmeter="2.9-SNAPSHOT.20130327">
|
||||
<hashTree>
|
||||
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Bug54685" enabled="true">
|
||||
<stringProp name="TestPlan.comments"></stringProp>
|
||||
<boolProp name="TestPlan.functional_mode">false</boolProp>
|
||||
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
|
||||
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||
<collectionProp name="Arguments.arguments">
|
||||
<elementProp name="REFERENCE" elementType="Argument">
|
||||
<stringProp name="Argument.name">REFERENCE</stringProp>
|
||||
<stringProp name="Argument.value">reference</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="JSESSIONID" elementType="Argument">
|
||||
<stringProp name="Argument.name">JSESSIONID</stringProp>
|
||||
<stringProp name="Argument.value">jsessionId</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
</collectionProp>
|
||||
</elementProp>
|
||||
<stringProp name="TestPlan.user_define_classpath"></stringProp>
|
||||
</TestPlan>
|
||||
<hashTree>
|
||||
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
|
||||
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
|
||||
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
|
||||
<boolProp name="LoopController.continue_forever">false</boolProp>
|
||||
<stringProp name="LoopController.loops">1</stringProp>
|
||||
</elementProp>
|
||||
<stringProp name="ThreadGroup.num_threads">1</stringProp>
|
||||
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
|
||||
<longProp name="ThreadGroup.start_time">1364309240000</longProp>
|
||||
<longProp name="ThreadGroup.end_time">1364309240000</longProp>
|
||||
<boolProp name="ThreadGroup.scheduler">false</boolProp>
|
||||
<stringProp name="ThreadGroup.duration"></stringProp>
|
||||
<stringProp name="ThreadGroup.delay"></stringProp>
|
||||
</ThreadGroup>
|
||||
<hashTree>
|
||||
<JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java Request" enabled="true">
|
||||
<elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
|
||||
<collectionProp name="Arguments.arguments">
|
||||
<elementProp name="Sleep_Time" elementType="Argument">
|
||||
<stringProp name="Argument.name">Sleep_Time</stringProp>
|
||||
<stringProp name="Argument.value">100</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="Sleep_Mask" elementType="Argument">
|
||||
<stringProp name="Argument.name">Sleep_Mask</stringProp>
|
||||
<stringProp name="Argument.value">0xFF</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="Label" elementType="Argument">
|
||||
<stringProp name="Argument.name">Label</stringProp>
|
||||
<stringProp name="Argument.value">sample_variables=${__P(sample_variables,'undef')} REFERENCE=${REFERENCE} JSESSIONID=${JSESSIONID}</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="ResponseCode" elementType="Argument">
|
||||
<stringProp name="Argument.name">ResponseCode</stringProp>
|
||||
<stringProp name="Argument.value"></stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="ResponseMessage" elementType="Argument">
|
||||
<stringProp name="Argument.name">ResponseMessage</stringProp>
|
||||
<stringProp name="Argument.value"></stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="Status" elementType="Argument">
|
||||
<stringProp name="Argument.name">Status</stringProp>
|
||||
<stringProp name="Argument.value">OK</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="SamplerData" elementType="Argument">
|
||||
<stringProp name="Argument.name">SamplerData</stringProp>
|
||||
<stringProp name="Argument.value"></stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="ResultData" elementType="Argument">
|
||||
<stringProp name="Argument.name">ResultData</stringProp>
|
||||
<stringProp name="Argument.value"></stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
</collectionProp>
|
||||
</elementProp>
|
||||
<stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest</stringProp>
|
||||
</JavaSampler>
|
||||
<hashTree/>
|
||||
</hashTree>
|
||||
<ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="View Results in Table" enabled="true">
|
||||
<boolProp name="ResultCollector.error_logging">false</boolProp>
|
||||
<objProp>
|
||||
<name>saveConfig</name>
|
||||
<value class="SampleSaveConfiguration">
|
||||
<time>false</time>
|
||||
<latency>false</latency>
|
||||
<timestamp>false</timestamp>
|
||||
<success>true</success>
|
||||
<label>true</label>
|
||||
<code>true</code>
|
||||
<message>true</message>
|
||||
<threadName>true</threadName>
|
||||
<dataType>true</dataType>
|
||||
<encoding>false</encoding>
|
||||
<assertions>true</assertions>
|
||||
<subresults>true</subresults>
|
||||
<responseData>false</responseData>
|
||||
<samplerData>false</samplerData>
|
||||
<xml>false</xml>
|
||||
<fieldNames>true</fieldNames>
|
||||
<responseHeaders>false</responseHeaders>
|
||||
<requestHeaders>false</requestHeaders>
|
||||
<responseDataOnError>false</responseDataOnError>
|
||||
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
|
||||
<assertionsResultsToSave>0</assertionsResultsToSave>
|
||||
<bytes>true</bytes>
|
||||
</value>
|
||||
</objProp>
|
||||
<stringProp name="filename">Bug54685.csv</stringProp>
|
||||
</ResultCollector>
|
||||
<hashTree/>
|
||||
<ResultCollector guiclass="SimpleDataWriter" testclass="ResultCollector" testname="Simple Data Writer" enabled="true">
|
||||
<boolProp name="ResultCollector.error_logging">false</boolProp>
|
||||
<objProp>
|
||||
<name>saveConfig</name>
|
||||
<value class="SampleSaveConfiguration">
|
||||
<time>false</time>
|
||||
<latency>false</latency>
|
||||
<timestamp>false</timestamp>
|
||||
<success>true</success>
|
||||
<label>true</label>
|
||||
<code>true</code>
|
||||
<message>true</message>
|
||||
<threadName>true</threadName>
|
||||
<dataType>true</dataType>
|
||||
<encoding>false</encoding>
|
||||
<assertions>true</assertions>
|
||||
<subresults>true</subresults>
|
||||
<responseData>false</responseData>
|
||||
<samplerData>false</samplerData>
|
||||
<xml>true</xml>
|
||||
<fieldNames>false</fieldNames>
|
||||
<responseHeaders>false</responseHeaders>
|
||||
<requestHeaders>false</requestHeaders>
|
||||
<responseDataOnError>false</responseDataOnError>
|
||||
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
|
||||
<assertionsResultsToSave>0</assertionsResultsToSave>
|
||||
<bytes>true</bytes>
|
||||
</value>
|
||||
</objProp>
|
||||
<stringProp name="filename">Bug54685.xml</stringProp>
|
||||
</ResultCollector>
|
||||
<hashTree/>
|
||||
</hashTree>
|
||||
</hashTree>
|
||||
</jmeterTestPlan>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testResults version="1.2">
|
||||
<sample s="true" lb="sample_variables=REFERENCE,JSESSIONID REFERENCE=reference JSESSIONID=jsessionId" rc="" rm="" tn="Thread Group 1-1" dt="" by="0" REFERENCE="reference" JSESSIONID="jsessionId"/>
|
||||
|
||||
</testResults>
|
||||
26
build.xml
26
build.xml
|
|
@ -2341,7 +2341,7 @@ run JMeter unless all the JMeter jars are added.
|
|||
<antcall target="batchtest">
|
||||
<param name="remote" value="-Rlocalhost:${rmi_port}"/>
|
||||
<param name="taskname" value="client"/>
|
||||
<param name="batchtest.name" value="BatchTestLocalRemote"/>
|
||||
<!-- Default the test name so we can override with a parameter -->
|
||||
</antcall>
|
||||
</sequential>
|
||||
</parallel>
|
||||
|
|
@ -2373,6 +2373,12 @@ run JMeter unless all the JMeter jars are added.
|
|||
<property name="batchtest.inp" location="${basedir}/bin/testfiles"/>
|
||||
<property name="batchtest.out" location="${basedir}/bin"/>
|
||||
<property name="batchtest.name" value="BatchTestLocal"/>
|
||||
<!--
|
||||
Allow variable to be set on the command line
|
||||
Cannot omit value because that causes a warning message
|
||||
-->
|
||||
<property name="batchtest.variable" value="dummy"/>
|
||||
<property name="batchtest.value" value="dummy"/>
|
||||
|
||||
<!-- Fix the EOL in case the file was derived from the "wrong" archive type -->
|
||||
<fixcrlf srcdir="${batchtest.inp}" includes="${batchtest.name}.csv"/>
|
||||
|
|
@ -2429,6 +2435,7 @@ run JMeter unless all the JMeter jars are added.
|
|||
<arg value="-Gmodule=Module"/>
|
||||
<!-- Check property can be used for filenames in local/remote tests (no need to defined as -G) -->
|
||||
<arg value="-JCSVFILE=${batchtest.name}.csv"/>
|
||||
<arg value="-J${batchtest.variable}=${batchtest.value}"/>
|
||||
</java>
|
||||
|
||||
<checkfile type="output" file="${batchtest.out}${file.separator}${batchtest.name}.csv"/>
|
||||
|
|
@ -2481,6 +2488,7 @@ run JMeter unless all the JMeter jars are added.
|
|||
</antcall>
|
||||
<antcall target="batchtest">
|
||||
<!-- variable in IPSource failed HTTP request if "Concurrent Pool Size" is enabled -->
|
||||
<!-- N.B. requires access to jmeter.apache.org -->
|
||||
<param name="batchtest.name" value="Bug52310"/>
|
||||
</antcall>
|
||||
<antcall target="batchtest">
|
||||
|
|
@ -2492,6 +2500,22 @@ run JMeter unless all the JMeter jars are added.
|
|||
<!-- IncludeController : NullPointerException loading script in non-GUI mode if Includers use same element name -->
|
||||
<param name="batchtest.name" value="Bug50898"/>
|
||||
</antcall>
|
||||
|
||||
<antcall target="batchtest">
|
||||
<!-- ArrayIndexOutOfBoundsException if "sample_variable" is set in client but not server -->
|
||||
<!-- This is unaffected by the bug; it just checks the script works OK in local mode -->
|
||||
<param name="batchtest.name" value="Bug54685"/>
|
||||
<param name="batchtest.variable" value="sample_variables"/>
|
||||
<param name="batchtest.value" value="REFERENCE,JSESSIONID"/>
|
||||
</antcall>
|
||||
|
||||
<antcall target="batchtestserver">
|
||||
<!-- ArrayIndexOutOfBoundsException if "sample_variable" is set in client but not server -->
|
||||
<!-- This is the actual test -->
|
||||
<param name="batchtest.name" value="Bug54685"/>
|
||||
<param name="batchtest.variable" value="sample_variables"/>
|
||||
<param name="batchtest.value" value="REFERENCE,JSESSIONID"/>
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<!-- Run all batch tests; used by test target -->
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.util.Properties;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.apache.jmeter.JMeter;
|
||||
import org.apache.jmeter.samplers.SampleEvent;
|
||||
import org.apache.jmeter.testbeans.TestBean;
|
||||
import org.apache.jmeter.testbeans.TestBeanHelper;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
|
|
@ -302,6 +303,12 @@ public class StandardJMeterEngine implements JMeterEngine, Runnable {
|
|||
log.info("Running the test!");
|
||||
running = true;
|
||||
|
||||
/*
|
||||
* Ensure that the sample variables are correctly initialised for each run.
|
||||
* TODO is this the best way to do this? should it be done elsewhere ?
|
||||
*/
|
||||
SampleEvent.initSampleVariables();
|
||||
|
||||
JMeterContextService.startTest();
|
||||
try {
|
||||
PreCompiler compiler = new PreCompiler();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.jmeter.samplers;
|
|||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.jmeter.threads.JMeterVariables;
|
||||
import org.apache.jmeter.util.JMeterUtils;
|
||||
|
|
@ -37,16 +38,18 @@ public class SampleEvent implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 232L;
|
||||
|
||||
/** The property {@value} is used to define additional variables to be saved */
|
||||
public static final String SAMPLE_VARIABLES = "sample_variables"; // $NON-NLS-1$
|
||||
|
||||
public static final String HOSTNAME;
|
||||
|
||||
// List of variable names to be saved in JTL files
|
||||
private static final String[] variableNames;
|
||||
private static volatile String[] variableNames = new String[0];
|
||||
|
||||
// The values. Entries may be null, but there will be the correct number.
|
||||
private final String[] values;
|
||||
|
||||
// The hostname cannot change during a run, so safe to cache it just once
|
||||
static {
|
||||
String hn="";
|
||||
try {
|
||||
|
|
@ -55,15 +58,18 @@ public class SampleEvent implements Serializable {
|
|||
log.error("Cannot obtain local host name "+e);
|
||||
}
|
||||
HOSTNAME=hn;
|
||||
|
||||
String vars = JMeterUtils.getProperty(SAMPLE_VARIABLES);
|
||||
variableNames=vars != null ? vars.split(",") : new String[0];
|
||||
int varCount=variableNames.length;
|
||||
if (varCount>0){
|
||||
log.info(varCount + " sample_variables have been declared: "+vars);
|
||||
}
|
||||
initSampleVariables();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the additional variable names to be saved
|
||||
* from the value in the {@link #SAMPLE_VARIABLES} property
|
||||
*/
|
||||
public static void initSampleVariables() {
|
||||
String vars = JMeterUtils.getProperty(SAMPLE_VARIABLES);
|
||||
variableNames=vars != null ? vars.split(",") : new String[0];
|
||||
log.info("List of sample_variables: " + Arrays.toString(variableNames));
|
||||
}
|
||||
|
||||
private final SampleResult result;
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ This does not affect JMeter operation.
|
|||
<h3>Listeners</h3>
|
||||
<ul>
|
||||
<li><bugzilla>54589</bugzilla> - View Results Tree have a lot of Garbage characters if html page uses double-byte charset</li>
|
||||
<li><bugzilla>5473</bugzilla> - StringIndexOutOfBoundsException at SampleResult.getSampleLabel() if key_on_threadname=false when using Statistical mode</li>
|
||||
<li><bugzilla>54753</bugzilla> - StringIndexOutOfBoundsException at SampleResult.getSampleLabel() if key_on_threadname=false when using Statistical mode</li>
|
||||
<li><bugzilla>54865</bugzilla> - ArrayIndexOutOfBoundsException if "sample_variable" is set in client but not server</li>
|
||||
</ul>
|
||||
|
||||
<h3>Timers, Assertions, Config, Pre- & Post-Processors</h3>
|
||||
|
|
|
|||
Loading…
Reference in New Issue