Functionality: CRC32 File Checksum
Clone type: Type-3 (WT3/4)
Is clone: FALSE

Function 1:
@Override
public void run () {
    final Counter counter = new Counter ("TRANSMIT", plotter);
    counter.start ();
    try {
        final DataInputStream dis = new DataInputStream (s.getInputStream ());
        while (! Thread.interrupted ()) {
            if (! running.get ()) {
                Thread.sleep (1000);
                continue;
            }
            final int nextPacketSize = dis.readInt ();
            counter.addBytes (INTEGER_BYTES);
            final byte [] packet = new byte [nextPacketSize];
            dis.readFully (packet);
            counter.addBytes (nextPacketSize);
            final long otherSideCrc = dis.readLong ();
            counter.addBytes (CRC_BYTES);
            final CRC32 crc = new CRC32 ();
            crc.update (packet);
            if (otherSideCrc != crc.getValue ()) {
                throw new RuntimeException ("CRC values don't match: this: " + crc.getValue () + ", other: " + otherSideCrc);
            }
        }
    } catch (InterruptedException e) {
        System.out.println ("Receiver thread interrupted!");
    } catch (Exception e) {
        System.err.println ("Unexpected error in receiver thread: " + e.getMessage ());
    } finally {
        abortLatch.countDown ();
        counter.interrupt ();
    }
}

Function 2:
protected void zipFile (InputStream in, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode, ZipExtraField [] extra) throws IOException {
    if (entries.contains (vPath)) {
        if (duplicate.equals ("preserve")) {
            logWhenWriting (vPath + " already added, skipping", Project.MSG_INFO);
            return;
        } else if (duplicate.equals ("fail")) {
            throw new BuildException ("Duplicate file " + vPath + " was found and the duplicate " + "attribute is 'fail'.");
        } else {
            logWhenWriting ("duplicate file " + vPath + " found, adding.", Project.MSG_VERBOSE);
        }

    } else {
        logWhenWriting ("adding entry " + vPath, Project.MSG_VERBOSE);
    }
    entries.put (vPath, vPath);
    if (! skipWriting) {
        ZipEntry ze = new ZipEntry (vPath);
        ze.setTime (lastModified);
        ze.setMethod (doCompress ? ZipEntry.DEFLATED : ZipEntry.STORED);
        if (! zOut.isSeekable () && ! doCompress) {
            long size = 0;
            CRC32 cal = new CRC32 ();
            if (! in.markSupported ()) {
                ByteArrayOutputStream bos = new ByteArrayOutputStream ();
                byte [] buffer = new byte [BUFFER_SIZE];
                int count = 0;
                do {
                    size += count;
                    cal.update (buffer, 0, count);
                    bos.write (buffer, 0, count);
                    count = in.read (buffer, 0, buffer.length);
                } while (count != - 1);
                in = new ByteArrayInputStream (bos.toByteArray ());
            } else {
                in.mark (Integer.MAX_VALUE);
                byte [] buffer = new byte [BUFFER_SIZE];
                int count = 0;
                do {
                    size += count;
                    cal.update (buffer, 0, count);
                    count = in.read (buffer, 0, buffer.length);
                } while (count != - 1);
                in.reset ();
            }
            ze.setSize (size);
            ze.setCrc (cal.getValue ());
        }
        ze.setUnixMode (mode);
        zOut.putNextEntry (ze);
        if (extra != null) {
            ze.setExtraFields (extra);
        }
        byte [] buffer = new byte [BUFFER_SIZE];
        int count = 0;
        do {
            if (count != 0) {
                zOut.write (buffer, 0, count);
            }
            count = in.read (buffer, 0, buffer.length);
        } while (count != - 1);
    }
    addedFiles.addElement (vPath);
}