private void populateCommandMap() { log.info("populateCommandMap called"); List<String> listClasses; Command command; Iterator<String> iterClasses; Class<?> commandClass; try { listClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { Class .forName("org.apache.jmeter.gui.action.Command") }); commands = new HashMap<String, Set<Command>>(listClasses.size()); if (listClasses.size() == 0) { log.warn("!!!!!Uh-oh, didn't find any action handlers!!!!!"); } iterClasses = listClasses.iterator(); while (iterClasses.hasNext()) { String strClassName = iterClasses.next(); if (strClassName.startsWith("org.apache.jmeter.report.gui.action")) { // log.info("classname:: " + strClassName); commandClass = Class.forName(strClassName); if (!Modifier.isAbstract(commandClass.getModifiers())) { command = (Command) commandClass.newInstance(); Iterator<String> iter = command.getActionNames().iterator(); while (iter.hasNext()) { String commandName = iter.next(); Set<Command> commandObjects = commands.get(commandName); if (commandObjects == null) { commandObjects = new HashSet<Command>(); commands.put(commandName, commandObjects); } commandObjects.add(command); } } } } } catch (HeadlessException e){ log.warn(e.toString()); } catch (Exception e) { log.error("exception finding action handlers", e); } }
private void populateCommandMap() { try { List<String> listClasses = ClassFinder.findClassesThatExtend( JMeterUtils.getSearchPaths(), // strPathsOrJars - pathnames or jarfiles to search for classes // classNames - required parent class(es) or annotations new Class[] {Class.forName("org.apache.jmeter.gui.action.Command") }, // $NON-NLS-1$ false, // innerClasses - should we include inner classes? null, // contains - classname should contain this string // Ignore the classes which are specific to the reporting tool "org.apache.jmeter.report.gui", // $NON-NLS-1$ // notContains - classname should not contain this string false); // annotations - true if classnames are annotations commands = new HashMap<String, Set<Command>>(listClasses.size()); if (listClasses.isEmpty()) { log.fatalError("!!!!!Uh-oh, didn't find any action handlers!!!!!"); throw new JMeterError("No action handlers found - check JMeterHome and libraries"); } for (String strClassName : listClasses) { Class<?> commandClass = Class.forName(strClassName); Command command = (Command) commandClass.newInstance(); for (String commandName : command.getActionNames()) { Set<Command> commandObjects = commands.get(commandName); if (commandObjects == null) { commandObjects = new HashSet<Command>(); commands.put(commandName, commandObjects); } commandObjects.add(command); } } } catch (HeadlessException e){ log.warn(e.toString()); } catch (Exception e) { log.error("exception finding action handlers", e); } }
Clone fragments detected by clone detection tool
File path: /apache-jmeter-2.11/src/reports/org/apache/jmeter/report/gui/action/ReportActionRouter.java File path: /apache-jmeter-2.11/src/core/org/apache/jmeter/gui/action/ActionRouter.java
Method name: void populateCommandMap() Method name: void populateCommandMap()
Number of AST nodes: 7 Number of AST nodes: 6
1
private void populateCommandMap() {
1
private void populateCommandMap() {
2
        log.info("populateCommandMap called");
2
        try {
3
        List<String> listClasses;
3
            List<String> listClasses = ClassFinder.findClassesThatExtend(
4
        Command command;
4
                    JMeterUtils.getSearchPaths(), // strPathsOrJars - pathnames or jarfiles to search for classes
5
        Iterator<String> iterClasses;
5
                    // classNames - required parent class(es) or annotations
6
        Class<?> commandClass;
6
                    new Class[] {Class.forName("org.apache.jmeter.gui.action.Command") }, // $NON-NLS-1$
7
        try {
7
                    false, // innerClasses - should we include inner classes?
8
            listClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { Class
8
                    null, // contains - classname should contain this string
9
                    .forName("org.apache.jmeter.gui.action.Command") });
9
                    // Ignore the classes which are specific to the reporting tool
10
            commands = new HashMap<String, Set<Command>>(listClasses.size());
10
                    "org.apache.jmeter.report.gui", // $NON-NLS-1$ // notContains - classname should not contain this string
11
            if (listClasses.size() == 0) {
11
                    false); // annotations - true if classnames are annotations
12
                log.warn("!!!!!Uh-oh, didn't find any action handlers!!!!!");
12
            commands = new HashMap<String, Set<Command>>(listClasses.size());
13
            }
13
            if (listClasses.isEmpty()) {
14
            iterClasses = listClasses.iterator();
14
                log.fatalError("!!!!!Uh-oh, didn't find any action handlers!!!!!");
15
            while (iterClasses.hasNext()) {
15
                throw new JMeterError("No action handlers found - check JMeterHome and libraries");
16
                String strClassName = iterClasses.next();
16
            }
17
                if (strClassName.startsWith("org.apache.jmeter.report.gui.action")) {
17
            for (String strClassName : listClasses) {
18
                    // log.info("classname:: " + strClassName);
18
                Class<?> commandClass = Class.forName(strClassName);
19
                    commandClass = Class.forName(strClassName);
19
                Command command = (Command) commandClass.newInstance();
20
                    if (!Modifier.isAbstract(commandClass.getModifiers())) {
20
                for (String commandName : command.getActionNames()) {
21
                        command = (Command) commandClass.newInstance();
21
                    Set<Command> commandObjects = commands.get(commandName);
22
                        Iterator<String> iter = command.getActionNames().iterator();
22
                    if (commandObjects == null) {
23
                        while (iter.hasNext()) {
23
                        commandObjects = new HashSet<Command>();
24
                            String commandName = iter.next();
24
                        commands.put(commandName, commandObjects);
25
                            Set<Command> commandObjects = commands.get(commandName);
25
                    }
26
                            if (commandObjects == null) {
26
                    commandObjects.add(command);
27
                                commandObjects = new HashSet<Command>();
27
                }
28
                                commands.put(commandName, commandObjects);
28
            }
29
                            }
29
        } catch (HeadlessException e){
30
                            commandObjects.add(command);
30
            log.warn(e.toString());
31
                        }
31
        } catch (Exception e) {
32
                    }
32
            log.error("exception finding action handlers", e);
33
                }
33
        }
34
            }
34
    }
35
        } catch (HeadlessException e){
36
            log.warn(e.toString());
37
        } catch (Exception e) {
38
            log.error("exception finding action handlers", e);
39
        }
40
    }
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.889
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    19
    while (iter.hasNext())
    10
    for (String commandName : command.getActionNames())
    20
    String commandName = iter.next();
                                                                          
    21
    Set<Command> commandObjects = commands.get(commandName);
    11
    Set<Command> commandObjects = commands.get(commandName);
    22
    if (commandObjects == null)
    12
    if (commandObjects == null)
    23
    commandObjects = new HashSet<Command>();
    13
    commandObjects = new HashSet<Command>();
    24
    commands.put(commandName, commandObjects);
    14
    commands.put(commandName, commandObjects);
    25
    commandObjects.add(command);
    15
    commandObjects.add(command);
    Precondition Violations (0)
    Row Violation