CPD Results

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

Duplications

File Line
org\apache\commons\cache\FileStash.java 162
org\apache\commons\cache\ShareableFileStash.java 78
    }

    protected byte[] getSerializedForm(Serializable val) {
        byte[] serform = null;
        if(null == val) {
            return null;
        }
        ByteArrayOutputStream byout = null;
        ObjectOutputStream out = null;
        try {
            byout = new ByteArrayOutputStream();
            out = new ObjectOutputStream(byout);
            out.writeObject(val);
            out.flush();
            serform = byout.toByteArray();
        } catch(IOException e) {
            serform = null;
        } finally {
            try {
                byout.close();
            } catch(Exception e) {
            }
            try {
                out.close();
            } catch(Exception e) {
            }
        }
        return serform;
    }

    protected synchronized Serializable readFromFile(File file) {
        ObjectInputStream oin = null;
        try {
            oin = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
            return(Serializable)(oin.readObject());
        } catch(Exception e) {
            return null;
        } finally {
            try {
                oin.close();
            } catch(Exception e) {
            }
        }
    }

File Line
org\apache\commons\cache\FileStash.java 243
org\apache\commons\cache\ShareableFileStash.java 176
        File cachefile = getFile(key,true);
        if(null == cachefile) {
            return false;
        }

        BufferedOutputStream fout = null;
        try {
            fout = new BufferedOutputStream(new FileOutputStream(cachefile));
            fout.write(serialized);
            fout.flush();
        } catch(Exception e) {
            try {
                fout.close();
            } catch(Exception ex) {
            }
            fout = null;
            try {
                cachefile.delete();
            } catch(Exception ex) {
            }
            return false;
        } finally {
            try {
                fout.close();
            } catch(Exception e) {
            }
        }