207-1-2

if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } ServletUtilities.createTempDir(); String prefix = ServletUtilities.tempFilePrefix; if (session == null) { prefix = ServletUtilities.tempOneTimeFilePrefix; } File tempFile = File.createTempFile(prefix, ".png", new File(System.getProperty("java.io.tmpdir"))); ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info); if (session != null) { ServletUtilities.registerChartForDeletion(tempFile, session); } return tempFile.getName();
if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } ServletUtilities.createTempDir(); String prefix = ServletUtilities.tempFilePrefix; if (session == null) { prefix = ServletUtilities.tempOneTimeFilePrefix; } File tempFile = File.createTempFile(prefix, ".jpeg", new File(System.getProperty("java.io.tmpdir"))); ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info); if (session != null) { ServletUtilities.registerChartForDeletion(tempFile, session); } return tempFile.getName();

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/servlet/ServletUtilities.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/servlet/ServletUtilities.java
Method name: `String saveChartAsPNG(JFreeChart, int, int, ChartRenderingInfo, HttpSession)` |  | Method name: `String saveChartAsJPEG(JFreeChart, int, int, ChartRenderingInfo, HttpSession)`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    if (chart == null) {↵

1

    if (chart == null) {↵

2

                throw new IllegalArgumentException("Null 'chart' argument.");   ↵

2

                throw new IllegalArgumentException("Null 'chart' argument.");   ↵

3

            }↵

3

            }↵

4

            ↵

4

            ServletUtilities.createTempDir();↵

5

            ServletUtilities.createTempDir();↵

5

            String prefix = ServletUtilities.tempFilePrefix;↵

6

            String prefix = ServletUtilities.tempFilePrefix;↵

6

            if (session == null) {↵

7

            if (session == null) {↵

7

                prefix = ServletUtilities.tempOneTimeFilePrefix;↵

8

                prefix = ServletUtilities.tempOneTimeFilePrefix;   ↵

8

            }↵

9

            }↵

9

            File tempFile = File.createTempFile(prefix, ".png", ↵

10

            File tempFile = File.createTempFile(prefix, ".jpeg", ↵

10

                    new File(System.getProperty("java.io.tmpdir")));↵

11

                    new File(System.getProperty("java.io.tmpdir")));↵

11

            ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info);↵

12

            ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info);↵

12

            if (session != null) {↵

13

            if (session != null) {↵

13

                ServletUtilities.registerChartForDeletion(tempFile, session);↵

14

                ServletUtilities.registerChartForDeletion(tempFile, session);↵

14

            }↵

15

            }↵

15

            return tempFile.getName();

16

            return tempFile.getName();

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.4
Clones location | Clones are declared in the same class
Number of node comparisons | 44

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 11
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 10.7
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (chart == null)

   1

       if (chart == null)

   2

       throw new IllegalArgumentException("Null 'chart' argument.");

   2

       throw new IllegalArgumentException("Null 'chart' argument.");

   3

       ServletUtilities.createTempDir();

   3

       ServletUtilities.createTempDir();

   4

       String prefix = ServletUtilities.tempFilePrefix;

   4

       String prefix = ServletUtilities.tempFilePrefix;

   5

       if (session == null)

   5

       if (session == null)

   6

       prefix = ServletUtilities.tempOneTimeFilePrefix;

   6

       prefix = ServletUtilities.tempOneTimeFilePrefix;

   7

       File tempFile = File.createTempFile(prefix, ".png", new File(System.getProperty("java.io.tmpdir")));

   7 | File tempFile = File.createTempFile(prefix, ".png", new File(System.getProperty("java.io.tmpdir")));
   7 | File tempFile = File.createTempFile(prefix, ".jpeg", new File(System.getProperty("java.io.tmpdir")));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   ".png" | ".jpeg" | LITERAL_VALUE_MISMATCH

   7

       File tempFile = File.createTempFile(prefix, ".jpeg", new File(System.getProperty("java.io.tmpdir")));

   8

       ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info);

   8 | ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info);
   8 | ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   saveChartAsPNG | saveChartAsJPEG | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression ChartUtilities.saveChartAsPNG(tempFile,chart,width,height,info) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression ChartUtilities.saveChartAsJPEG(tempFile,chart,width,height,info) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression ChartUtilities.saveChartAsPNG(tempFile,chart,width,height,info) is a void method call, and thus it cannot be parameterized
   Expression ChartUtilities.saveChartAsJPEG(tempFile,chart,width,height,info) is a void method call, and thus it cannot be parameterized

   8

       ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info);

   9

       if (session != null)

   9

       if (session != null)

   10

       ServletUtilities.registerChartForDeletion(tempFile, session);

   10

       ServletUtilities.registerChartForDeletion(tempFile, session);

   11

       return tempFile.getName();

   11

       return tempFile.getName();

   Precondition Violations (4)
   Row | Violation
   --- | ---
   1 | Expression ChartUtilities.saveChartAsPNG(tempFile,chart,width,height,info) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression ChartUtilities.saveChartAsJPEG(tempFile,chart,width,height,info) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression ChartUtilities.saveChartAsPNG(tempFile,chart,width,height,info) is a void method call, and thus it cannot be parameterized
   4 | Expression ChartUtilities.saveChartAsJPEG(tempFile,chart,width,height,info) is a void method call, and thus it cannot be parameterized