CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Line
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 358
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 408
            ps.setString(1, locale.toString());
            rs = ps.executeQuery();
            if (rs.next()) {
                size = rs.getInt(1);
            }
            rs.close();
            con.commit();
        } catch (SQLException e) {
            log.error(DB_ERROR, e);
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException ex) {
                }
            }
        } finally {
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                }
            }
            if (con != null) {
                try {
                    con.close();
                } catch (SQLException e) {
                }
            }
        }

        return size;
    }

    /**
     * Release all the ressources and close the buffer.
     */
    public void dispose() {

File Line
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 361
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 501
                set.add(rs.getString(1));
            }
            rs.close();
            con.commit();
        } catch (SQLException e) {
            log.error(DB_ERROR, e);
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException ex) {
                }
            }
        } finally {
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                }
            }
            if (con != null) {
                try {
                    con.close();
                } catch (SQLException e) {
                }
            }
        }

        return set;

File Line
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 363
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 458
            ps.execute();
            con.commit();

        } catch (SQLException e) {
            log.error(DB_ERROR, e);
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException ex) {
                }
            }
        } finally {
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                }
            }
            if (con != null) {
                try {
                    con.close();
                } catch (SQLException e) {
                }
            }
        }

File Line
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 201
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 364
            con.commit();
        } catch (SQLException e) {
            log.error(DB_ERROR, e);
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException ex) {
                }
            }
        } finally {
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                }
            }
            if (con != null) {
                try {
                    con.close();
                } catch (SQLException e) {
                }
            }
        }

        return size;

File Line
com\octo\captcha\engine\bufferedengine\QuartzBufferedEngineContainerTest.java 32
com\octo\captcha\engine\bufferedengine\QuartzBufferedEngineContainerTest.java 54
        Resource ressource = new ClassPathResource("testNoBufferedCaptchaQuartzBufferedEngine.xml");
        ConfigurableBeanFactory bf = new XmlBeanFactory(ressource);
        BufferedEngineContainer container = (BufferedEngineContainer) bf.getBean("container");
        Object scheduler = bf.getBean("quartz");
        Thread.sleep(10000);
        for (int i = 0; i < 100; i++) {
            assertNotNull(container.getNextCaptcha());
        }
    }

    /**
     * @see com.octo.captcha.engine.bufferedengine.BufferedEngineContainerTestAbstract#getEngine()
     */
    public BufferedEngineContainer getEngine() {

File Line
com\octo\captcha\engine\bufferedengine\MockedBufferedEngineContainerTest.java 68
com\octo\captcha\engine\bufferedengine\MockedBufferedEngineContainerTest.java 73
        assertEquals("volatil buffer should be updated", maxVolatil, engine.getVolatileBuffer().size());
        engine.swapCaptchasFromPersistentToVolatileMemory();
        assertEquals("volatil buffer should be filled", maxVolatil, engine.getVolatileBuffer().size());
        assertEquals("pers buffer should be updated", feed - 2 * swap - 2, engine.getPersistentBuffer().size());
        engine.feedPersistentBuffer();

File Line
com\octo\captcha\engine\bufferedengine\ContainerConfigurationTest.java 55
com\octo\captcha\engine\bufferedengine\ContainerConfigurationTest.java 66
    public void testServeOnlyConfiguredLocales() {
        HashMap localRatio2 = new HashMap(3);
        localRatio2.put(Locale.GERMAN, new Double(0.1));
        localRatio2.put(Locale.CHINA, new Double(0.8));
        localRatio2.put(Locale.ITALY, new Double(0.1));

File Line
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 209
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBufferTest.java 67
            }
        } finally {
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                }
            }
            if (con != null) {
                try {
                    con.close();
                } catch (SQLException e) {
                }
            }
        }

File Line
com\octo\captcha\engine\bufferedengine\buffer\CaptchaBufferTestAbstract.java 129
com\octo\captcha\engine\bufferedengine\buffer\CaptchaBufferTestAbstract.java 157
    public void testPutAllCaptchaCollectionLocale() {
        buffer = getBuffer();
        ArrayList listToStore = new ArrayList(SIZE);

        for (int i = 0; i < SIZE; ++i) {
            listToStore.add(engine.getNextCaptcha());
        }
        buffer.putAllCaptcha(listToStore, Locale.GERMAN);

File Line
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 211
com\octo\captcha\engine\bufferedengine\buffer\DatabaseCaptchaBuffer.java 326
            } finally {
                if (ps != null) {
                    try {
                        ps.close();
                    } catch (SQLException e) {
                    }
                }
                if (con != null) {
                    try {
                        con.close();
                    } catch (SQLException e) {
                    }
                }
            }