Iterator iter = coll.entrySet().iterator(); Map newColl = null; while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); Object item = entry.getKey(); Object prop = entry.getValue(); if (newColl == null) { try { newColl = (Map) coll.getClass().newInstance(); } catch (Exception e) { log.error("Bad collection", e); return coll; } } newColl.put(item, convertObject(prop)); } if (newColl != null) { return newColl; } else { return coll; }
Iterator iter = coll.iterator(); Collection newColl = null; while (iter.hasNext()) { Object item = iter.next(); if (newColl == null) { try { newColl = (Collection) coll.getClass().newInstance(); } catch (Exception e) { log.error("Bad collection", e); return coll; } } newColl.add(convertObject(item)); } if (newColl != null) { return newColl; } else { return coll; }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/testelement/property/AbstractProperty.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/testelement/property/AbstractProperty.java
Method name: Map normalizeMap(Map) Method name: Collection normalizeList(Collection)
Number of AST nodes: 13 Number of AST nodes: 11
1
Iterator iter = coll.entrySet().iterator();
1
Iterator iter = coll.iterator();
2
		Map newColl = null;
2
		Collection newColl = null;
3
		while (iter.hasNext()) {
3
		while (iter.hasNext()) {
4
			Map.Entry entry = (Map.Entry) iter.next();
4
			
5
            Object item = entry.getKey();
6
			Object prop = entry.getValue();
5
Object item = iter.next();
7
			if (newColl == null) {
6
			if (newColl == null) {
8
				try {
7
				try {
9
					newColl = (Map) coll.getClass().newInstance();
8
					newColl = (Collection) coll.getClass().newInstance();
10
				} catch (Exception e) {
9
				} catch (Exception e) {
11
					log.error("Bad collection", e);
10
					log.error("Bad collection", e);
12
					return coll;
11
					return coll;
13
				}
12
				}
14
			}
13
			}
15
			newColl.put(item, convertObject(prop));
14
			newColl.add(convertObject(item));
16
		}
15
		}
17
		if (newColl != null) {
16
		if (newColl != null) {
18
			return newColl;
17
			return newColl;
19
		} else {
18
		} else {
20
			return coll;
19
			return coll;
21
		}
20
		}
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons1