src.samples.java.ex.DWI_Sample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sb-contrib Show documentation
Show all versions of sb-contrib Show documentation
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);
}
}
}
}