All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.samples.java.ex.DWI_Sample Maven / Gradle / Ivy

Go to download

An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.

The newest version!
package ex;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

public class DWI_Sample {
    Set avail;
    List cow = new CopyOnWriteArrayList();

    public void deleteOdds(Set bagOInts) {
        Iterator it = bagOInts.iterator();
        while (it.hasNext()) {
            Integer i = it.next();
            if ((i.intValue() & 0x01) == 1) {
                bagOInts.remove(i);
            }
        }
    }

    void concurrentModificaitonExceptionTest352() {
        ArrayList list = new ArrayList();
        list.add(2);
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Integer integer = iterator.next();
            list.remove(integer);
        }
    }

    public void addIf(Set s, Collection c) {
        for (String ss : s) {
            if (ss.equals("addem")) {
                s.addAll(c);
            }
        }
    }

    public void fpUnaliased() {
        Iterator it = avail.iterator();
        avail = new HashSet();

        while (it.hasNext()) {
            avail.add(it.next() + "booya");
        }
    }

    public void fpWithBreak(Set ss) {
        for (String s : ss) {
            if (s.equals("foo")) {
                ss.remove("foo");
                break;
            }
        }
    }

    public void fpClearWithBreak(Set ss) {
        for (String s : ss) {
            if (s.equals("foo")) {
                ss.clear();
                break;
            }
        }
    }

    public void fpRemoveWithReturn(Set ss) {
        for (String s : ss) {
            if (s.equals("foo")) {
                ss.remove("foo");
                return;
            }
        }
    }

    public boolean fpRemoveWithReturn2(Set ss) {
        for (String s : ss) {
            if (s.equals("foo")) {
                ss.remove("foo");
                return true;
            }
        }

        return false;
    }

    public void fpNonCMECollection() {
        for (String s : cow) {
            if (s.isEmpty()) {
                cow.remove(s);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy