if (urlConnection == null) { urlConnection = url.openConnection(); if (urlConnection instanceof HttpURLConnection) { HttpURLConnection httpURLConnection = (HttpURLConnection)urlConnection; httpURLConnection.setRequestMethod("HEAD"); httpURLConnection.getResponseCode(); } } if (urlConnection.getHeaderField("content-length") != null) { result.put(URIConverter.ATTRIBUTE_LENGTH, urlConnection.getContentLength()); }
if (urlConnection == null) { urlConnection = url.openConnection(); if (urlConnection instanceof HttpURLConnection) { HttpURLConnection httpURLConnection = (HttpURLConnection)urlConnection; httpURLConnection.setRequestMethod("HEAD"); httpURLConnection.getResponseCode(); } } if (urlConnection.getHeaderField("last-modified") != null) { result.put(URIConverter.ATTRIBUTE_TIME_STAMP, urlConnection.getLastModified()); }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/resource/impl/URIHandlerImpl.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/resource/impl/URIHandlerImpl.java
Method name: Map getAttributes(URI, Map) Method name: Map getAttributes(URI, Map)
Number of AST nodes: 8 Number of AST nodes: 8
1
if (urlConnection == null)
1
if (urlConnection == null)
2
        {
2
        {
3
          urlConnection = url.openConnection();
3
          urlConnection = url.openConnection();
4
          if (urlConnection instanceof HttpURLConnection)
4
          if (urlConnection instanceof HttpURLConnection)
5
          {
5
          {
6
            HttpURLConnection httpURLConnection = (HttpURLConnection)urlConnection;
6
            HttpURLConnection httpURLConnection = (HttpURLConnection)urlConnection;
7
            httpURLConnection.setRequestMethod("HEAD");
7
            httpURLConnection.setRequestMethod("HEAD");
8
            httpURLConnection.getResponseCode();
8
            httpURLConnection.getResponseCode();
9
          }
9
          }
10
        }
10
        }
11
        if (urlConnection.getHeaderField("content-length") != null)
11
        if (urlConnection.getHeaderField("last-modified") != null)
12
        {
12
        {
13
          result.put(URIConverter.ATTRIBUTE_LENGTH, urlConnection.getContentLength());
13
          result.put(URIConverter.ATTRIBUTE_TIME_STAMP, urlConnection.getLastModified());
14
        }
14
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.4
Clones locationClones are in the same method
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    27
    if (urlConnection == null)
    18
    if (urlConnection == null)
    28
    urlConnection = url.openConnection();
    19
    urlConnection = url.openConnection();
    29
    if (urlConnection instanceof HttpURLConnection)
    20
    if (urlConnection instanceof HttpURLConnection)
    30
    HttpURLConnection httpURLConnection = (HttpURLConnection)urlConnection;
    21
    HttpURLConnection httpURLConnection = (HttpURLConnection)urlConnection;
    31
    httpURLConnection.setRequestMethod("HEAD");
    22
    httpURLConnection.setRequestMethod("HEAD");
    32
    httpURLConnection.getResponseCode();
    23
    httpURLConnection.getResponseCode();
    33
    if (urlConnection.getHeaderField("content-length") != null)
    33
    if (urlConnection.getHeaderField("content-length") != null)
    24
    if (urlConnection.getHeaderField("last-modified") != null)
    Differences
    Expression1Expression2Difference
    "content-length""last-modified"LITERAL_VALUE_MISMATCH
    24
    if (urlConnection.getHeaderField("last-modified") != null)
                                                                                                                                                                        
    25
    result.put(URIConverter.ATTRIBUTE_TIME_STAMP, urlConnection.getLastModified());
    Preondition Violations
    Unmatched statement result.put(URIConverter.ATTRIBUTE_TIME_STAMP,urlConnection.getLastModified()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    25
    result.put(URIConverter.ATTRIBUTE_TIME_STAMP, urlConnection.getLastModified());
    34
    result.put(URIConverter.ATTRIBUTE_LENGTH, urlConnection.getContentLength());
    34
    result.put(URIConverter.ATTRIBUTE_LENGTH, urlConnection.getContentLength());
    Preondition Violations
    Unmatched statement result.put(URIConverter.ATTRIBUTE_LENGTH,urlConnection.getContentLength()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                  
    Precondition Violations (2)
    Row Violation
    1Unmatched statement result.put(URIConverter.ATTRIBUTE_TIME_STAMP,urlConnection.getLastModified()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement result.put(URIConverter.ATTRIBUTE_LENGTH,urlConnection.getContentLength()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted