Author: pmouawad
Date: Sat Feb 13 20:40:18 2016
New Revision: 1730267
URL: http://svn.apache.org/viewvc?rev=1730267&view=rev
Log:
Removing unnecessary continues and a few other tidy ups
Patch by Graham Russel
#resolve #121
Modified:
jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
jmeter/trunk/src/core/org/apache/jmeter/engine/util/FunctionParser.java
jmeter/trunk/src/core/org/apache/jmeter/gui/tree/JMeterTreeNode.java
jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
Modified:
jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
(original)
+++
jmeter/trunk/src/components/org/apache/jmeter/control/gui/ModuleControllerGui.java
Sat Feb 13 20:40:18 2016
@@ -73,9 +73,6 @@ import org.apache.jorphan.gui.layout.Ver
*
*/
public class ModuleControllerGui extends AbstractControllerGui implements
ActionListener {
- /**
- *
- */
private static final long serialVersionUID = -4195441608252523573L;
private static final String SEPARATOR = " > ";
@@ -124,18 +121,14 @@ public class ModuleControllerGui extends
if (lastSelected != null && lastSelected.getUserObject()
instanceof JMeterTreeNode) {
tn = (JMeterTreeNode) lastSelected.getUserObject();
}
- if(tn != null && isTestElementAllowed(tn.getTestElement())) {
- return true;
- }
-
- return false;
+ return tn != null && isTestElementAllowed(tn.getTestElement());
}
@Override
public void setSelectionPath(TreePath path) {
DefaultMutableTreeNode lastSelected = (DefaultMutableTreeNode)
path.getLastPathComponent();
- if(isSelectedPathAllowed(lastSelected)) {
+ if (isSelectedPathAllowed(lastSelected)) {
super.setSelectionPath(path);
}
}
@@ -163,7 +156,6 @@ public class ModuleControllerGui extends
super.addSelectionPaths(paths);
}
}
-
};
tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
moduleToRunTreeNodes.setSelectionModel(tsm);
@@ -177,7 +169,7 @@ public class ModuleControllerGui extends
init();
- // the listener is used to hide the error messsage when a target
element is selected
+ // the listener is used to hide the error message when a target
element is selected
TreeSelectionListener tsl = new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
@@ -246,15 +238,15 @@ public class ModuleControllerGui extends
public void modifyTestElement(TestElement element) {
configureTestElement(element);
JMeterTreeNode tn = null;
- DefaultMutableTreeNode lastSelected = (DefaultMutableTreeNode)
this.moduleToRunTreeNodes.getLastSelectedPathComponent();
+ DefaultMutableTreeNode lastSelected =
+ (DefaultMutableTreeNode)
this.moduleToRunTreeNodes.getLastSelectedPathComponent();
if (lastSelected != null && lastSelected.getUserObject() instanceof
JMeterTreeNode) {
tn = (JMeterTreeNode) lastSelected.getUserObject();
}
if (tn != null) {
selected = tn;
- //prevent from selecting thread group or test plan elements
- if (selected != null
- && isTestElementAllowed(selected.getTestElement())) {
+ // prevent from selecting thread group or test plan elements
+ if (isTestElementAllowed(selected.getTestElement())) {
((ModuleController) element).setSelectedNode(selected);
}
}
@@ -262,13 +254,10 @@ public class ModuleControllerGui extends
// check if a given test element can be selected as the target of a module
controller
private static boolean isTestElementAllowed(TestElement testElement) {
- if (testElement != null
+ return testElement != null
&& !(testElement instanceof AbstractThreadGroup)
- && !(testElement instanceof TestPlan)) {
- return true;
- }
-
- return false;
+ && !(testElement instanceof TestPlan);
+
}
/** {@inheritDoc}} */
@@ -278,7 +267,6 @@ public class ModuleControllerGui extends
selected = null;
}
-
/** {@inheritDoc}} */
@Override
public JPopupMenu createPopupMenu() {
@@ -331,9 +319,10 @@ public class ModuleControllerGui extends
*
* @return path of a found element
*/
- private TreeNode[] findPathInTreeModel(int level, TreeNode[] testPlanPath,
DefaultMutableTreeNode parent)
+ private TreeNode[] findPathInTreeModel(
+ int level, TreeNode[] testPlanPath, DefaultMutableTreeNode parent)
{
- if(level >= testPlanPath.length) {
+ if (level >= testPlanPath.length) {
return EMPTY_TREE_NODES;
}
int childCount = parent.getChildCount();
@@ -344,13 +333,11 @@ public class ModuleControllerGui extends
DefaultMutableTreeNode child = (DefaultMutableTreeNode)
parent.getChildAt(i);
JMeterTreeNode childUserObj = (JMeterTreeNode)
child.getUserObject();
- if(!childUserObj.equals(searchedTreeNode)){
- continue;
- } else {
- if(level == (testPlanPath.length - 1)){
+ if (childUserObj.equals(searchedTreeNode)) {
+ if (level == (testPlanPath.length - 1)) {
return child.getPath();
} else {
- return findPathInTreeModel(level+1, testPlanPath, child);
+ return findPathInTreeModel(level + 1, testPlanPath, child);
}
}
}
@@ -367,7 +354,7 @@ public class ModuleControllerGui extends
TreeNode[] filteredPath = new TreeNode[path.length-1];
//ignore first element of path - WorkBench, (why WorkBench is
appearing in the path ???)
- for(int i = 1; i < path.length; i++){
+ for (int i = 1; i < path.length; i++){
filteredPath[i-1] = path[i];
}
@@ -375,16 +362,13 @@ public class ModuleControllerGui extends
//treepath of test plan tree and module to run tree cannot be compared
directly - moduleToRunTreeModel.getPathToRoot()
//custom method for finding an JMeterTreeNode element in
DefaultMutableTreeNode have to be used
TreeNode[] dmtnPath = this.findPathInTreeModel(1, filteredPath, root);
- if (dmtnPath.length>0) {
+ if (dmtnPath.length > 0) {
TreePath treePath = new TreePath(dmtnPath);
moduleToRunTreeNodes.setSelectionPath(treePath);
moduleToRunTreeNodes.scrollPathToVisible(treePath);
}
}
-
- /**
- *
- */
+
private void reinitialize() {
((DefaultMutableTreeNode)
moduleToRunTreeModel.getRoot()).removeAllChildren();
@@ -425,19 +409,12 @@ public class ModuleControllerGui extends
DefaultMutableTreeNode newNode = new
DefaultMutableTreeNode(cur);
parent.add(newNode);
buildTreeNodeModel(cur, level + 1, newNode);
-
- } else if (te instanceof TestFragmentController) {
- DefaultMutableTreeNode newNode = new
DefaultMutableTreeNode(cur);
- parent.add(newNode);
- buildTreeNodeModel(cur, level + 1, newNode);
-
- } else if (te instanceof AbstractThreadGroup) {
+ } else if (te instanceof TestFragmentController
+ || te instanceof AbstractThreadGroup) {
DefaultMutableTreeNode newNode = new
DefaultMutableTreeNode(cur);
parent.add(newNode);
buildTreeNodeModel(cur, level + 1, newNode);
- }
-
- else if (te instanceof TestPlan) {
+ } else if (te instanceof TestPlan) {
((DefaultMutableTreeNode) moduleToRunTreeModel.getRoot())
.setUserObject(cur);
buildTreeNodeModel(cur, level,
@@ -453,14 +430,14 @@ public class ModuleControllerGui extends
*/
@Override
public void actionPerformed(ActionEvent e) {
- if(e.getSource()==expandButton) {
+ if (e.getSource() == expandButton) {
JMeterTreeNode tn = null;
DefaultMutableTreeNode selected = (DefaultMutableTreeNode)
this.moduleToRunTreeNodes.getLastSelectedPathComponent();
- if(selected != null && selected.getUserObject() instanceof
JMeterTreeNode){
+ if (selected != null && selected.getUserObject() instanceof
JMeterTreeNode){
tn = (JMeterTreeNode) selected.getUserObject();
}
- if(tn != null){
+ if (tn != null){
TreePath treePath = new TreePath(tn.getPath());
//changing selection in a test plan tree
GuiPackage.getInstance().getTreeListener().getJTree()
@@ -472,7 +449,6 @@ public class ModuleControllerGui extends
}
}
-
/**
* @param selected JMeterTreeNode tree node to expand
*/
@@ -497,7 +473,7 @@ public class ModuleControllerGui extends
public Component getTreeCellRendererComponent(JTree tree, Object
value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
JMeterTreeNode node = (JMeterTreeNode)((DefaultMutableTreeNode)
value).getUserObject();
- if(node != null){
+ if (node != null){
super.getTreeCellRendererComponent(tree, node.getName(),
selected, expanded, leaf, row,
hasFocus);
//print same icon as in test plan tree
Modified:
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
(original)
+++
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
Sat Feb 13 20:40:18 2016
@@ -65,11 +65,11 @@ public class JSONPostProcessor extends A
public void process() {
JMeterContext context = getThreadContext();
JMeterVariables vars = context.getVariables();
- String jsonResponse = "";
- if (isScopeVariable()){
+ String jsonResponse;
+ if (isScopeVariable()) {
jsonResponse = vars.get(getVariableName());
- if(log.isDebugEnabled()) {
- log.debug("JSON Extractor is using
variable:"+getVariableName()+" which content is:"+jsonResponse);
+ if (log.isDebugEnabled()) {
+ log.debug("JSON Extractor is using variable:" +
getVariableName() + " which content is:" + jsonResponse);
}
} else {
SampleResult previousResult = context.getPreviousResult();
@@ -77,101 +77,107 @@ public class JSONPostProcessor extends A
return;
}
jsonResponse = previousResult.getResponseDataAsString();
- if(log.isDebugEnabled()) {
- log.debug("JSON Extractor "+getName()+" working on
Response:"+jsonResponse);
+ if (log.isDebugEnabled()) {
+ log.debug("JSON Extractor " + getName() + " working on
Response:" + jsonResponse);
}
}
String[] refNames = getRefNames().split(SEPARATOR);
- String[] jsonPathExpressions =
getJsonPathExpressions().split(SEPARATOR);
+ String[] jsonPathExpressions =
getJsonPathExpressions().split(SEPARATOR);
String[] defaultValues = getDefaultValues().split(SEPARATOR);
int[] matchNumbers = getMatchNumbersAsInt(defaultValues.length);
//jsonResponse = jsonResponse.replaceAll("'", "\""); // $NON-NLS-1$
$NON-NLS-2$
- if (refNames.length != jsonPathExpressions.length ||
+ if (refNames.length != jsonPathExpressions.length ||
refNames.length != defaultValues.length) {
log.error("Number of JSON Path variables must match number of
default values and json-path expressions, check you use separator ';' if you
have many values"); // $NON-NLS-1$
- throw new
IllegalArgumentException(JMeterUtils.getResString("jsonpp_error_number_arguments_mismatch_error"));
// $NON-NLS-1$
- } else {
- for (int i = 0; i < jsonPathExpressions.length; i++) {
- int matchNumber = matchNumbers[i];
- String currentRefName = refNames[i].trim();
- String currentJsonPath = jsonPathExpressions[i].trim();
- try {
- if(jsonResponse.isEmpty()) {
+ throw new IllegalArgumentException(JMeterUtils
+
.getResString("jsonpp_error_number_arguments_mismatch_error")); // $NON-NLS-1$
+ }
+
+ for (int i = 0; i < jsonPathExpressions.length; i++) {
+ int matchNumber = matchNumbers[i];
+ String currentRefName = refNames[i].trim();
+ String currentJsonPath = jsonPathExpressions[i].trim();
+ try {
+ if (jsonResponse.isEmpty()) {
+ vars.put(currentRefName, defaultValues[i]);
+ } else {
+
+ List<String> extractedValues = localMatcher.get()
+ .extractWithJsonPath(jsonResponse,
currentJsonPath);
+ // if no values extracted, default value added
+ if (extractedValues.isEmpty()) {
vars.put(currentRefName, defaultValues[i]);
+ vars.put(currentRefName + REF_MATCH_NR, "0");
//$NON-NLS-1$
+ if (matchNumber < 0 && getComputeConcatenation()) {
+ log.debug("No value extracted, storing empty in:"
//$NON-NLS-1$
+ + currentRefName + ALL_SUFFIX);
+ vars.put(currentRefName + ALL_SUFFIX, "");
+ }
} else {
-
- List<String> extractedValues =
localMatcher.get().extractWithJsonPath(jsonResponse, currentJsonPath);
- // if no values extracted, default value added
- if (extractedValues.isEmpty()) {
- vars.put(currentRefName, defaultValues[i]);
- vars.put(currentRefName+REF_MATCH_NR, "0");
//$NON-NLS-1$
- if(matchNumber<0 && getComputeConcatenation()) {
- log.debug("No value extracted, storing empty
in :"+currentRefName + ALL_SUFFIX); //$NON-NLS-1$
- vars.put(currentRefName + ALL_SUFFIX, "");
- }
- } else {
- // if more than one value extracted, suffix with
- // "_index"
- if (extractedValues.size() > 1) {
- if(matchNumber<0) {
- // Extract all
- int index = 1;
- StringBuilder concat = new
StringBuilder(getComputeConcatenation()?extractedValues.size()*20:1);
- for (String stringExtracted :
extractedValues) {
- vars.put(currentRefName + "_" + index,
stringExtracted);
- if(getComputeConcatenation()) {
-
concat.append(stringExtracted).append(JSONPostProcessor.JSON_CONCATENATION_SEPARATOR);
- }
- index++;
+ // if more than one value extracted, suffix with
"_index"
+ if (extractedValues.size() > 1) {
+ if (matchNumber < 0) {
+ // Extract all
+ int index = 1;
+ StringBuilder concat =
+ new
StringBuilder(getComputeConcatenation()
+ ? extractedValues.size() * 20
+ : 1);
+ for (String stringExtracted : extractedValues)
{
+ vars.put(currentRefName + "_" + index,
stringExtracted);
+ if (getComputeConcatenation()) {
+ concat.append(stringExtracted)
+
.append(JSONPostProcessor.JSON_CONCATENATION_SEPARATOR);
}
- if(getComputeConcatenation()) {
- concat.setLength(concat.length()-1);
- vars.put(currentRefName + ALL_SUFFIX,
concat.toString());
+ index++;
+ }
+ if (getComputeConcatenation()) {
+ concat.setLength(concat.length() - 1);
+ vars.put(currentRefName + ALL_SUFFIX,
concat.toString());
+ }
+ } else if (matchNumber == 0) {
+ // Random extraction
+ int matchSize = extractedValues.size();
+ vars.put(currentRefName,
extractedValues.get(JMeterUtils.getRandomInt(matchSize)));
+ } else {
+ // extract at position
+ if (matchNumber > extractedValues.size()) {
+ if (log.isDebugEnabled()) {
+ log.debug("matchNumber(" + matchNumber
+ + ") exceeds number of items
found("
+ + extractedValues.size()
+ + "), default value will be
used");
}
- } else if (matchNumber == 0) {
- // Random extraction
- int matchSize = extractedValues.size();
- vars.put(currentRefName,
extractedValues.get(JMeterUtils.getRandomInt(matchSize)));
+ vars.put(currentRefName, defaultValues[i]);
} else {
- // extract at position
- if(matchNumber>extractedValues.size()) {
- if(log.isDebugEnabled()) {
-
log.debug("matchNumber("+matchNumber + ") exceeds number of items
found("+extractedValues.size()+"), default value will be used");
- }
- vars.put(currentRefName,
defaultValues[i]);
- } else {
- vars.put(currentRefName,
extractedValues.get(matchNumber-1));
- }
+ vars.put(currentRefName,
extractedValues.get(matchNumber - 1));
}
}
- else {
- // else just one value extracted
- vars.put(currentRefName,
extractedValues.get(0));
- if(matchNumber<0 && getComputeConcatenation())
{
- vars.put(currentRefName + ALL_SUFFIX,
extractedValues.get(0));
- }
+ } else {
+ // else just one value extracted
+ vars.put(currentRefName, extractedValues.get(0));
+ if (matchNumber < 0 && getComputeConcatenation()) {
+ vars.put(currentRefName + ALL_SUFFIX,
extractedValues.get(0));
}
- vars.put(currentRefName+REF_MATCH_NR,
Integer.toString(extractedValues.size()));
}
+ vars.put(currentRefName + REF_MATCH_NR,
Integer.toString(extractedValues.size()));
}
- } catch (Exception e) {
- // if something wrong, default value added
- if (log.isDebugEnabled()) {
- log.error("Error processing JSON content in "+
getName()+", message:"+e.getLocalizedMessage(),e);
- } else {
- log.error("Error processing JSON content in "+
getName()+", message:"+e.getLocalizedMessage());
-
- }
- vars.put(currentRefName, defaultValues[i]);
- continue;
}
+ } catch (Exception e) {
+ // if something wrong, default value added
+ if (log.isDebugEnabled()) {
+ log.error("Error processing JSON content in "+
getName()+", message:"+e.getLocalizedMessage(),e);
+ } else {
+ log.error("Error processing JSON content in "+
getName()+", message:"+e.getLocalizedMessage());
+
+ }
+ vars.put(currentRefName, defaultValues[i]);
}
}
}
-
public String getJsonPathExpressions() {
return getPropertyAsString(JSON_PATH_EXPRESSIONS);
}
@@ -196,7 +202,6 @@ public class JSONPostProcessor extends A
setProperty(DEFAULT_VALUES, defaultValue, ""); // $NON-NLS-1$
}
-
public boolean getComputeConcatenation() {
return getPropertyAsBoolean(COMPUTE_CONCATENATION,
COMPUTE_CONCATENATION_DEFAULT_VALUE);
}
@@ -215,7 +220,6 @@ public class JSONPostProcessor extends A
localMatcher.get().reset();
}
-
public void setMatchNumbers(String matchNumber) {
setProperty(MATCH_NUMBERS, matchNumber);
}
@@ -228,7 +232,7 @@ public class JSONPostProcessor extends A
String matchNumbersAsString = getMatchNumbers();
int[] result = new int[arraySize];
- if(JOrphanUtils.isBlank(matchNumbersAsString)) {
+ if (JOrphanUtils.isBlank(matchNumbersAsString)) {
Arrays.fill(result, 0);
} else {
String[] matchNumbersAsStringArray =
Modified:
jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
(original)
+++
jmeter/trunk/src/components/org/apache/jmeter/visualizers/RespTimeGraphVisualizer.java
Sat Feb 13 20:40:18 2016
@@ -594,7 +594,7 @@ public class RespTimeGraphVisualizer ext
@Override
public JComponent getPrintableComponent() {
- if (saveGraphToFile == true) {
+ if (saveGraphToFile) {
saveGraphToFile = false;
graphPanel.setBounds(graphPanel.getLocation().x,graphPanel.getLocation().y,
graphPanel.width,graphPanel.height);
Modified:
jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
(original)
+++
jmeter/trunk/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
Sat Feb 13 20:40:18 2016
@@ -737,7 +737,7 @@ public class StatGraphVisualizer extends
}
@Override
public JComponent getPrintableComponent() {
- if (saveGraphToFile == true) {
+ if (saveGraphToFile) {
saveGraphToFile = false;
graphPanel.setBounds(graphPanel.getLocation().x,graphPanel.getLocation().y,
graphPanel.width,graphPanel.height);
Modified:
jmeter/trunk/src/core/org/apache/jmeter/engine/util/FunctionParser.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/engine/util/FunctionParser.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/engine/util/FunctionParser.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/engine/util/FunctionParser.java Sat
Feb 13 20:40:18 2016
@@ -66,14 +66,13 @@ class FunctionParser {
if (reader.read(current) == 0) {
break;
}
- // Keep the '\' unless it is one of the escapable chars
'$' ',' or '\'
+ // Keep '\' unless it is one of the escapable chars '$'
',' or '\'
// N.B. This method is used to parse function parameters,
so must treat ',' as special
if (current[0] != '$' && current[0] != ',' && current[0]
!= '\\') {
buffer.append(previous); // i.e. '\\'
}
previous = ' ';
buffer.append(current[0]);
- continue;
} else if (current[0] == '{' && previous == '$') {// found "${"
buffer.deleteCharAt(buffer.length() - 1);
if (buffer.length() > 0) {// save leading text
@@ -87,6 +86,7 @@ class FunctionParser {
previous = current[0];
}
}
+
if (buffer.length() > 0) {
result.add(buffer.toString());
}
@@ -127,7 +127,6 @@ class FunctionParser {
}
previous = ' ';
buffer.append(current[0]);
- continue;
} else if (current[0] == '(' && previous != ' ') {
String funcName = buffer.toString();
function = CompoundVariable.getNamedFunction(funcName);
@@ -147,7 +146,6 @@ class FunctionParser {
} else { // Function does not exist, so treat as per
missing variable
buffer.append(current[0]);
}
- continue;
} else if (current[0] == '}') {// variable, or function with
no parameter list
function =
CompoundVariable.getNamedFunction(buffer.toString());
if (function instanceof Function){// ensure that
setParameters() is called.
@@ -198,7 +196,6 @@ class FunctionParser {
}
previous = ' ';
buffer.append(current[0]); // store the following character
- continue;
} else if (current[0] == ',' && functionRecursion == 0) {
CompoundVariable param = new CompoundVariable();
param.setParameters(buffer.toString());
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/tree/JMeterTreeNode.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/tree/JMeterTreeNode.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/tree/JMeterTreeNode.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/tree/JMeterTreeNode.java Sat
Feb 13 20:40:18 2016
@@ -77,14 +77,12 @@ public class JMeterTreeNode extends Defa
*/
public List<JMeterTreeNode> getPathToThreadGroup() {
List<JMeterTreeNode> nodes = new ArrayList<>();
- if(treeModel != null) {
+ if (treeModel != null) {
TreeNode[] nodesToRoot = treeModel.getPathToRoot(this);
for (TreeNode node : nodesToRoot) {
JMeterTreeNode jMeterTreeNode = (JMeterTreeNode) node;
int level = jMeterTreeNode.getLevel();
- if(level<TEST_PLAN_LEVEL) {
- continue;
- } else {
+ if (level >= TEST_PLAN_LEVEL) {
nodes.add(jMeterTreeNode);
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java Sat Feb 13
20:40:18 2016
@@ -595,13 +595,12 @@ public final class CSVSaveService {
SampleSaveConfiguration saveConfig = new
SampleSaveConfiguration(false);
int varCount = 0;
- for (int i = 0; i < parts.length; i++) {
- String label = parts[i];
+ for (String label : parts) {
if (isVariableName(label)) {
varCount++;
} else {
Functor set = (Functor) headerLabelMethods.get(label);
- set.invoke(saveConfig, new Boolean[] { Boolean.TRUE });
+ set.invoke(saveConfig, new Boolean[]{Boolean.TRUE});
}
}
@@ -701,8 +700,8 @@ public final class CSVSaveService {
}
writer.write(LINE_SEP);
}
- for (int idx = 0; idx < data.size(); idx++) {
- List<?> row = (List<?>) data.get(idx);
+ for (Object o : data) {
+ List<?> row = (List<?>) o;
for (int idy = 0; idy < row.size(); idy++) {
if (idy > 0) {
writer.write(DELIM);
@@ -905,8 +904,8 @@ public final class CSVSaveService {
if (results != null) {
// Find the first non-null message
- for (int i = 0; i < results.length; i++) {
- message = results[i].getFailureMessage();
+ for (AssertionResult result : results) {
+ message = result.getFailureMessage();
if (message != null) {
break;
}
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java
(original)
+++
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Daemon.java
Sat Feb 13 20:40:18 2016
@@ -134,8 +134,7 @@ public class Daemon extends Thread imple
thd.configure(clientSocket, target, pageEncodings,
formEncodings);
thd.start();
}
- } catch (InterruptedIOException e) {
- continue;
+ } catch (InterruptedIOException ignored) {
// Timeout occurred. Ignore, and keep looping until we're
// told to stop running.
}
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
(original)
+++
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
Sat Feb 13 20:40:18 2016
@@ -518,37 +518,37 @@ public class Proxy extends Thread {
*/
private String messageResponseHeaders(SampleResult res) {
String headers = res.getResponseHeaders();
- String [] headerLines=headers.split(NEW_LINE, 0); // drop empty
trailing content
- int contentLengthIndex=-1;
+ String[] headerLines = headers.split(NEW_LINE, 0); // drop empty
trailing content
+ int contentLengthIndex = -1;
boolean fixContentLength = false;
- for (int i=0;i<headerLines.length;i++){
- String line=headerLines[i];
- String[] parts=line.split(":\\s+",2); // $NON-NLS-1$
- if (parts.length==2){
- if
(HTTPConstants.TRANSFER_ENCODING.equalsIgnoreCase(parts[0])){
- headerLines[i]=null; // We don't want this passed on to
browser
+ for (int i = 0; i < headerLines.length; i++) {
+ String line = headerLines[i];
+ String[] parts = line.split(":\\s+", 2); // $NON-NLS-1$
+ if (parts.length == 2) {
+ if
(HTTPConstants.TRANSFER_ENCODING.equalsIgnoreCase(parts[0])) {
+ headerLines[i] = null; // We don't want this passed on to
browser
continue;
}
if
(HTTPConstants.HEADER_CONTENT_ENCODING.equalsIgnoreCase(parts[0])
&&
HTTPConstants.ENCODING_GZIP.equalsIgnoreCase(parts[1])
){
- headerLines[i]=null; // We don't want this passed on to
browser
+ headerLines[i] = null; // We don't want this passed on to
browser
fixContentLength = true;
continue;
}
if
(HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(parts[0])){
- contentLengthIndex=i;
- continue;
+ contentLengthIndex = i;
}
}
}
if (fixContentLength && contentLengthIndex>=0){// Fix the content
length
-
headerLines[contentLengthIndex]=HTTPConstants.HEADER_CONTENT_LENGTH+":
"+res.getResponseData().length;
+ headerLines[contentLengthIndex] =
+ HTTPConstants.HEADER_CONTENT_LENGTH + ": " +
res.getResponseData().length;
}
StringBuilder sb = new StringBuilder(headers.length());
for (String line : headerLines) {
- if (line != null){
+ if (line != null) {
sb.append(line).append(CRLF_STRING);
}
}
@@ -586,7 +586,7 @@ public class Proxy extends Thread {
} catch(IllegalCharsetNameException ex) {
log.warn("Unsupported charset detected in
contentType:'"+result.getContentType()+"', will continue processing with
default charset", ex);
}
- if(pageEncoding != null) {
+ if (pageEncoding != null) {
String urlWithoutQuery = getUrlWithoutQuery(result.getURL());
synchronized(pageEncodings) {
pageEncodings.put(urlWithoutQuery, pageEncoding);
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
(original)
+++
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
Sat Feb 13 20:40:18 2016
@@ -472,9 +472,9 @@ public class HTTPJavaImpl extends HTTPAb
try {
// Sampling proper - establish the connection and read the
response:
// Repeatedly try to connect:
- int retry;
+ int retry = 0;
// Start with 0 so tries at least once, and retries at most
MAX_CONN_RETRIES times
- for (retry = 0; retry <= MAX_CONN_RETRIES; retry++) {
+ for (; retry <= MAX_CONN_RETRIES; retry++) {
try {
conn = setupConnection(url, method, res);
// Attempt the connection:
@@ -492,7 +492,6 @@ public class HTTPJavaImpl extends HTTPAb
conn.disconnect();
}
setUseKeepAlive(false);
- continue; // try again
} catch (IOException e) {
log.debug("Connection failed, giving up");
throw e;
@@ -506,8 +505,7 @@ public class HTTPJavaImpl extends HTTPAb
if (method.equals(HTTPConstants.POST)) {
String postBody = sendPostData(conn);
res.setQueryString(postBody);
- }
- else if (method.equals(HTTPConstants.PUT)) {
+ } else if (method.equals(HTTPConstants.PUT)) {
String putBody = sendPutData(conn);
res.setQueryString(putBody);
}
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1730267&r1=1730266&r2=1730267&view=diff
==============================================================================
---
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
(original)
+++
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
Sat Feb 13 20:40:18 2016
@@ -1275,7 +1275,6 @@ public abstract class HTTPSamplerBase ex
} catch (ClassCastException e) { // TODO can this happen?
res.addSubResult(errorResult(new Exception(binURL + " is
not a correct URI"), new HTTPSampleResult(res)));
setParentSampleSuccess(res, false);
- continue;
}
}
// IF for download concurrent embedded resources
@@ -1562,7 +1561,7 @@ public abstract class HTTPSamplerBase ex
}
}
if (redirect >= MAX_REDIRECTS) {
- lastRes = errorResult(new IOException("Exceeeded maximum number of
redirects: " + MAX_REDIRECTS), new HTTPSampleResult(lastRes));
+ lastRes = errorResult(new IOException("Exceeded maximum number of
redirects: " + MAX_REDIRECTS), new HTTPSampleResult(lastRes));
totalRes.addSubResult(lastRes);
}