if (lastJFCDirectory == null) { String start = JMeterUtils.getPropDefault("user.dir", "");//$NON-NLS-1$//$NON-NLS-2$ if (start.length() > 0) { jfc = new JFileChooser(new File(start)); } lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath(); } String ext = ".jmx";//$NON-NLS-1$ if (filename != null) { jfc.setSelectedFile(new File(lastJFCDirectory, filename)); int i = -1; if ((i = filename.lastIndexOf(".")) > -1) {//$NON-NLS-1$ ext = filename.substring(i); } } clearFileFilters(); if (extensions != null) { jfc.addChoosableFileFilter(new JMeterFileFilter(extensions)); } else { jfc.addChoosableFileFilter(new JMeterFileFilter(new String[] { ext })); } int retVal = jfc.showSaveDialog(GuiPackage.getInstance().getMainFrame()); lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath(); if (retVal == JFileChooser.APPROVE_OPTION) { return jfc; } return null;
if (lastJFCDirectory == null) { String start = JMeterUtils.getPropDefault("user.dir", ""); if (!start.equals("")) { jfc = new JFileChooser(new File(start)); } lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath(); } String ext = ".jmx"; if (filename != null) { jfc.setSelectedFile(new File(lastJFCDirectory, filename)); int i = -1; if ((i = filename.lastIndexOf(".")) > -1) { ext = filename.substring(i); } } clearFileFilters(); if (extensions != null) { jfc.addChoosableFileFilter(new JMeterFileFilter(extensions)); } else { jfc.addChoosableFileFilter(new JMeterFileFilter(new String[] { ext })); } int retVal = jfc.showSaveDialog(ReportGuiPackage.getInstance().getMainFrame()); lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath(); if (retVal == JFileChooser.APPROVE_OPTION) { return jfc; } else { return null; }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/FileDialoger.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/ReportFileDialoger.java
Method name: JFileChooser promptToSaveFile(String, String[]) Method name: JFileChooser promptToSaveFile(String, String[])
Number of AST nodes: 20 Number of AST nodes: 20
1
if (lastJFCDirectory == null) {
1
if (lastJFCDirectory == null) {
2
			String start = JMeterUtils.getPropDefault("user.dir", "");//$NON-NLS-1$//$NON-NLS-2$
2
			String start = JMeterUtils.getPropDefault("user.dir", "");
3
			if (start.length() > 0) {
3
			if (!start.equals("")) {
4
				jfc = new JFileChooser(new File(start));
4
				jfc = new JFileChooser(new File(start));
5
			}
5
			}
6
			lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
6
			lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
7
		}
7
		}
8
		String ext = ".jmx";//$NON-NLS-1$
8
		String ext = ".jmx";
9
		if (filename != null) {
9
		if (filename != null) {
10
			jfc.setSelectedFile(new File(lastJFCDirectory, filename));
10
			jfc.setSelectedFile(new File(lastJFCDirectory, filename));
11
			int i = -1;
11
			int i = -1;
12
			if ((i = filename.lastIndexOf(".")) > -1) {//$NON-NLS-1$
12
			if ((i = filename.lastIndexOf(".")) > -1) {
13
				ext = filename.substring(i);
13
				ext = filename.substring(i);
14
			}
14
			}
15
		}
15
		}
16
		clearFileFilters();
16
		clearFileFilters();
17
		if (extensions != null) {
17
		if (extensions != null) {
18
			jfc.addChoosableFileFilter(new JMeterFileFilter(extensions));
18
			jfc.addChoosableFileFilter(new JMeterFileFilter(extensions));
19
		} else {
19
		} else {
20
			jfc.addChoosableFileFilter(new JMeterFileFilter(new String[] { ext }));
20
			jfc.addChoosableFileFilter(new JMeterFileFilter(new String[] { ext }));
21
		}
21
		}
22
		int retVal = jfc.showSaveDialog(GuiPackage.getInstance().getMainFrame());
22
		int retVal = jfc.showSaveDialog(ReportGuiPackage.getInstance().getMainFrame());
23
		lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
23
		lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
24
		if (retVal == JFileChooser.APPROVE_OPTION) {
24
		if (retVal == JFileChooser.APPROVE_OPTION) {
25
			return jfc;
25
			return jfc;
26
		}
26
		} else {
27
		return null;
27
			return null;
28
		}
Summary
Number of common nesting structure subtrees2
Number of refactorable cases0
Number of non-refactorable cases2
Time elapsed for finding largest common nesting structure subtrees (ms)1.6
Clones locationClones are in different classes
Number of node comparisons62
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    2
    String start = JMeterUtils.getPropDefault("user.dir", "");
                                                                                                                        
                                                                                                                            
    8
    jfc.setSelectedFile(new File(lastJFCDirectory, filename));
                            
    9
    int i = -1;
    3
    if (start.length() > 0)
    3
    if (start.length() > 0)
    10
    if ((i = filename.lastIndexOf(".")) > -1)
    Differences
    Expression1Expression2Difference
    start.length()(i=filename.lastIndexOf("."))TYPE_COMPATIBLE_REPLACEMENT
    0-1TYPE_COMPATIBLE_REPLACEMENT
    10
    if ((i = filename.lastIndexOf(".")) > -1)
    4
    jfc = new JFileChooser(new File(start));
                                                                                      
                                                                
    11
    ext = filename.substring(i);
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables , while Clone fragment #2 returns variables i
  2. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)4.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    6
    String ext = ".jmx";
    6
    String ext = ".jmx";
    7
    if (filename != null)
    7
    if (filename != null)
    8
    jfc.setSelectedFile(new File(lastJFCDirectory, filename));
    8
    jfc.setSelectedFile(new File(lastJFCDirectory, filename));
    9
    int i = -1;
    9
    int i = -1;
    10
    if ((i = filename.lastIndexOf(".")) > -1)
    10
    if ((i = filename.lastIndexOf(".")) > -1)
    11
    ext = filename.substring(i);
    11
    ext = filename.substring(i);
    12
    clearFileFilters();
    12
    clearFileFilters();
    13
    if (extensions != null)
    13
    if (extensions != null)
    14
    jfc.addChoosableFileFilter(new JMeterFileFilter(extensions));
    14
    jfc.addChoosableFileFilter(new JMeterFileFilter(extensions));
    else
    else
    15
    jfc.addChoosableFileFilter(new JMeterFileFilter(new String[] {ext}));
    15
    jfc.addChoosableFileFilter(new JMeterFileFilter(new String[] {ext}));
    16
    int retVal = jfc.showSaveDialog(GuiPackage.getInstance().getMainFrame());
    16
    int retVal = jfc.showSaveDialog(GuiPackage.getInstance().getMainFrame());
    16
    int retVal = jfc.showSaveDialog(ReportGuiPackage.getInstance().getMainFrame());
    Differences
    Expression1Expression2Difference
    org.apache.jmeter.gui.GuiPackageorg.apache.jmeter.gui.ReportGuiPackageVARIABLE_TYPE_MISMATCH
    org.apache.jmeter.gui.GuiPackageorg.apache.jmeter.gui.ReportGuiPackageVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.jmeter.gui.GuiPackage of variable GuiPackage.getInstance() does not match with type org.apache.jmeter.gui.ReportGuiPackage of variable ReportGuiPackage.getInstance()
    • Make classes org.apache.jmeter.gui.GuiPackage and org.apache.jmeter.gui.ReportGuiPackage extend a common superclass
    Type org.apache.jmeter.gui.GuiPackage of variable GuiPackage does not match with type org.apache.jmeter.gui.ReportGuiPackage of variable ReportGuiPackage
    • Make classes org.apache.jmeter.gui.GuiPackage and org.apache.jmeter.gui.ReportGuiPackage extend a common superclass
    16
    int retVal = jfc.showSaveDialog(ReportGuiPackage.getInstance().getMainFrame());
    17
    lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
    17
    lastJFCDirectory = jfc.getCurrentDirectory().getAbsolutePath();
    18
    if (retVal == JFileChooser.APPROVE_OPTION)
    18
    if (retVal == JFileChooser.APPROVE_OPTION)
    19
    return jfc;
    19
    return jfc;
            
    else
                                    
    20
    return null;
    Preondition Violations
    Unmatched return null;
    20
    return null;
    Precondition Violations (3)
    Row Violation
    1Type org.apache.jmeter.gui.GuiPackage of variable GuiPackage.getInstance() does not match with type org.apache.jmeter.gui.ReportGuiPackage of variable ReportGuiPackage.getInstance()
    2Type org.apache.jmeter.gui.GuiPackage of variable GuiPackage does not match with type org.apache.jmeter.gui.ReportGuiPackage of variable ReportGuiPackage
    3Unmatched return null;