Skip to content
Permalink
Browse files

Merge branch 'findbugs' into spotbugs

  • Loading branch information...
mebigfatguy committed Feb 26, 2019
2 parents bd7ca7d + 828d9ad commit 6f189fa301db928bace39da0f80d6f0488961a82
@@ -180,6 +180,7 @@
+0 BugPattern PIS_POSSIBLE_INCOMPLETE_SERIALIZATION
+0 BugPattern PL_PARALLEL_LISTS
+0 BugPattern PMB_INSTANCE_BASED_THREAD_LOCAL
+0 BugPattern PMB_LOCAL_BASED_JAXB_CONTEXT
+0 BugPattern PMB_POSSIBLE_MEMORY_BLOAT
+0 BugPattern PME_POOR_MANS_ENUM
+0 BugPattern PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS
@@ -106,7 +106,7 @@

<Detector class="com.mebigfatguy.fbcontrib.detect.JDBCVendorReliance" speed="fast" reports="JVR_JDBC_VENDOR_RELIANCE" />

<Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat" speed="fast" reports="PMB_POSSIBLE_MEMORY_BLOAT,PMB_INSTANCE_BASED_THREAD_LOCAL" />
<Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat" speed="fast" reports="PMB_POSSIBLE_MEMORY_BLOAT,PMB_INSTANCE_BASED_THREAD_LOCAL,PMB_LOCAL_BASED_JAXB_CONTEXT" />

<Detector class="com.mebigfatguy.fbcontrib.detect.LocalSynchronizedCollection" speed="moderate" reports="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" />

@@ -389,6 +389,7 @@
<BugPattern abbrev="JVR" type="JVR_JDBC_VENDOR_RELIANCE" category="CORRECTNESS" />
<BugPattern abbrev="PMB" type="PMB_POSSIBLE_MEMORY_BLOAT" category="CORRECTNESS" />
<BugPattern abbrev="PMB" type="PMB_INSTANCE_BASED_THREAD_LOCAL" category="CORRECTNESS" />
<BugPattern abbrev="PMB" type="PMB_LOCAL_BASED_JAXB_CONTEXT" category="CORRECTNESS" />
<BugPattern abbrev="LSYC" type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" category="CORRECTNESS" />
<BugPattern abbrev="FCBL" type="FCBL_FIELD_COULD_BE_LOCAL" category="CORRECTNESS" />
<BugPattern abbrev="NRTL" type="NRTL_NON_RECYCLEABLE_TAG_LIB" category="CORRECTNESS"/>
@@ -516,9 +516,13 @@ public void test(int i)
<Detector class="com.mebigfatguy.fbcontrib.detect.PossibleMemoryBloat">
<Details>
<![CDATA[
<p>Looks for classes that maintain collections or StringBuffer/StringBuilders in
<p>Looks for classes that have usage patterns that may cause memory bloat to occur.
This can occur with classes maintain collections or StringBuffer/StringBuilders in
static member variables, and that do not appear to provide a way to clear or remove
items from these members. Such class fields are likely causes of memory bloat.</p>
items from these members.
Other cases are use of JAXBContexts stored recreated over and over again, instead of
using a cached instance.
Such class fields are likely causes of memory bloat.</p>
<p>It is a fast detector.</p>
]]>
</Details>
@@ -2661,7 +2665,7 @@ static {
]]>
</Details>
</BugPattern>

<BugPattern type="PMB_INSTANCE_BASED_THREAD_LOCAL">
<ShortDescription>Field is an instance based ThreadLocal variable</ShortDescription>
<LongDescription>Field {1} is an instance based ThreadLocal variable</LongDescription>
@@ -2676,6 +2680,20 @@ static {
]]>
</Details>
</BugPattern>

<BugPattern type="PMB_LOCAL_BASED_JAXB_CONTEXT">
<ShortDescription>Local JAXBContext created on demand</ShortDescription>
<LongDescription>Method {1} createa a local JAXBContext on demand</LongDescription>
<Details>
<![CDATA[
<p>This method creates a JAXBContext and stores it in a local variable. This
implies that this JAXBContext is created each time on demand, which will cause
memory bloat issues. It is better to either create this instance as a static field,
or hold onto it with a ConcurrentHashMap, or such. See
https://javaee.github.io/jaxb-v2/doc/user-guide/ch03.html#other-miscellaneous-topics-performance-and-thread-safety </p>
]]>
</Details>
</BugPattern>

<BugPattern type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION">
<ShortDescription>Method creates local variable-based synchronized collection</ShortDescription>
@@ -217,6 +217,7 @@
PIS_POSSIBLE_INCOMPLETE_SERIALIZATION,
PL_PARALLEL_LISTS,
PMB_INSTANCE_BASED_THREAD_LOCAL,
PMB_LOCAL_BASED_JAXB_CONTEXT,
PMB_POSSIBLE_MEMORY_BLOAT,
PME_POOR_MANS_ENUM,
PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS,
@@ -1,5 +1,6 @@
package ex;

import java.io.ByteArrayInputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -12,6 +13,10 @@
import java.util.Set;
import java.util.WeakHashMap;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class PMB_Sample {
private static Set<String> bl_data = new HashSet<>(); // tag
private static List<String> data = new ArrayList<>(); // no tag
@@ -83,6 +88,12 @@ public void add(String s) {
public void remove(String s) {
data.remove(s);
}

public X instanceJAXBFactory(String xml) throws JAXBException {
JAXBContext jc = JAXBContext.newInstance(X.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
return (X) unmarshaller.unmarshal( new ByteArrayInputStream(xml.getBytes()));
}

public void fpInnerDoesRemove() {
inner_data.add("Hello");
@@ -114,4 +125,8 @@ public static void fpCleanUpWithIterator276(String key) {
fpEmptyWithIterator.put(key, "foo");
}
}

class X {
}

}

0 comments on commit 6f189fa

Please sign in to comment.
You can’t perform that action at this time.