[Fb-contrib-commit] SF.net SVN: fb-contrib:[1774] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2014-07-26 03:41:11
|
Revision: 1774 http://sourceforge.net/p/fb-contrib/code/1774 Author: dbrosius Date: 2014-07-26 03:40:55 +0000 (Sat, 26 Jul 2014) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/etc/bugrank.txt trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/plugin.xml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples/ABC_Sample.java trunk/fb-contrib/samples/COM_Sample.java trunk/fb-contrib/samples/CU_Sample.java trunk/fb-contrib/samples/HES_Sample.java trunk/fb-contrib/samples/ISB_Sample.java trunk/fb-contrib/samples/JVR_Sample.java trunk/fb-contrib/samples/LO_Sample.java trunk/fb-contrib/samples/LSYC_Sample.java trunk/fb-contrib/samples/MDM_Sample.java trunk/fb-contrib/samples/NPMC_Sample.java trunk/fb-contrib/samples/NSE_Sample.java trunk/fb-contrib/samples/OCP_Sample.java trunk/fb-contrib/samples/PCAIL_Sample.java trunk/fb-contrib/samples/PMB_Sample.java trunk/fb-contrib/samples/PRMC_Sample.java trunk/fb-contrib/samples/SCA_Sample.java trunk/fb-contrib/samples/SCII_Sample.java trunk/fb-contrib/samples/SCRV_Sample.java trunk/fb-contrib/samples/SC_Sample.java trunk/fb-contrib/samples/SMA_Sample.java trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/samples/WOC_Sample.java trunk/fb-contrib/samples/samples.fbp trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CircularDependencies.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CompareClassNameEquals.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonFunctionalField.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CollectionUtils.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/samples/HCP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/debug/Debug.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/.classpath 2014-07-26 03:40:55 UTC (rev 1774) @@ -5,18 +5,21 @@ <classpathentry excluding="lib/" kind="src" path="samples"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> - <classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/> <classpathentry kind="lib" path="lib/backport-util-concurrent-3.1.jar"/> - <classpathentry kind="lib" path="lib/bcel-2.0.2.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="lib/javax.servlet-api-3.1.0.jar"/> <classpathentry kind="lib" path="lib/junit-4.11.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/> - <classpathentry kind="lib" path="lib/findbugs-2.0.3.jar" sourcepath="/home/dave/.m2/repository/com/google/code/findbugs/findbugs/2.0.3/findbugs-2.0.3-sources.jar"/> - <classpathentry kind="lib" path="lib/annotations-2.0.3.jar"/> <classpathentry kind="lib" path="lib/javax.servlet.jsp-api-2.3.1.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.3.jar"/> - <classpathentry kind="lib" path="lib/slf4j-api-1.7.6.jar"/> + <classpathentry kind="lib" path="lib/slf4j-api-1.7.7.jar"/> <classpathentry kind="lib" path="lib/guava-17.0.jar"/> + <classpathentry kind="lib" path="lib/httpclient-cache-4.3.4.jar"/> + <classpathentry kind="lib" path="lib/httpcore-4.3.2.jar"/> + <classpathentry kind="lib" path="lib/httpclient-4.3.4.jar"/> + <classpathentry kind="lib" path="lib/annotations-3.0.0.jar"/> + <classpathentry kind="lib" path="lib/asm-debug-all-5.0.2.jar"/> + <classpathentry kind="lib" path="lib/bcel-findbugs-6.0.jar"/> + <classpathentry kind="lib" path="lib/findbugs-3.0.0.jar"/> <classpathentry kind="output" path="classes"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/build.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -13,12 +13,12 @@ <property name="samples.dir" value="${basedir}/samples" /> <property name="javadoc.dir" value="${basedir}/javadoc" /> <property name="htdocs.dir" value="${basedir}/htdocs" /> - <property name="javac.source" value="1.5" /> - <property name="javac.target" value="1.5" /> + <property name="javac.source" value="1.6" /> + <property name="javac.target" value="1.6" /> <property name="javac.deprecation" value="on" /> <property name="javac.debug" value="on" /> - <property name="fb-contrib.version" value="5.2.1" /> + <property name="fb-contrib.version" value="6.0.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -36,9 +36,9 @@ <delete dir="${basedir}/plugin" /> </target> - <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank"> + <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank" unless="no.yank"> <mkdir dir="${lib.dir}" /> - <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true" separateClassifierTypes="true"> + <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true"> <server url="http://repo1.maven.org/maven2" /> <generateVersions propertyFileName="${basedir}/version.properties" /> </yank:yank> @@ -59,9 +59,9 @@ <mkdir dir="${javadoc.dir}" /> <path id="fb-contrib.classpath"> <pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar" /> - <pathelement location="${lib.dir}/bcel-${bcel.version}.jar" /> + <pathelement location="${lib.dir}/bcel-findbugs-${bcel-findbugs.version}.jar" /> <pathelement location="${lib.dir}/annotations-${annotations.version}.jar" /> - <pathelement location="${lib.dir}/asm-tree-${asm-tree.version}.jar" /> + <pathelement location="${lib.dir}/asm-debug-all-${asm-debug-all.version}.jar" /> </path> <path id="fb-contrib.samples.classpath"> <pathelement location="${lib.dir}/javax.servlet.jsp-api-${javax.servlet.jsp-api.version}.jar" /> @@ -72,6 +72,9 @@ <pathelement location="${lib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> <pathelement location="${lib.dir}/slf4j-api-${slf4j-api.version}.jar" /> <pathelement location="${lib.dir}/guava-${guava.version}.jar" /> + <pathelement location="${lib.dir}/httpclient-cache-${httpclient-cache.version}.jar" /> + <pathelement location="${lib.dir}/httpcore-${httpcore.version}.jar" /> + <pathelement location="${lib.dir}/httpclient-${httpclient.version}.jar" /> </path> </target> @@ -165,6 +168,7 @@ </target> <target name="install" depends="build" description="installs the plugin into FindBugs"> + <echo message="Findbugs: ${findbugs.dir}/plugin"/> <copy todir="${findbugs.dir}/plugin"> <fileset dir="${basedir}"> <include name="fb-contrib-${fb-contrib.version}.jar" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/etc/bugrank.txt 2014-07-26 03:40:55 UTC (rev 1774) @@ -88,6 +88,7 @@ 0 BugPattern SPP_USE_GETPROPERTY 0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE 0 BugPattern SPP_USELESS_CASING +0 BugPattern SPP_CONVERSION_OF_STRING_LITERAL 0 BugPattern BAS_BLOATED_ASSIGNMENT_SCOPE 0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR 0 BugPattern DWI_DELETING_WHILE_ITERATING @@ -129,4 +130,6 @@ 0 BugPattern CEBE_COMMONS_EQUAL_BUILDER_TOEQUALS -2 BugPattern HE_LOCAL_EXECUTOR_SERVICE -4 BugPattern HE_EXECUTOR_NEVER_SHUTDOWN --2 BugPattern HE_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN \ No newline at end of file +-2 BugPattern HE_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN +0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD +0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL \ No newline at end of file Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/etc/findbugs.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -149,7 +149,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri" speed="fast" - reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING" /> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -157,7 +157,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UseSplit" speed="fast" reports="USS_USE_STRING_SPLIT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" disabled="true" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousJDKVersionUse" speed="slow" reports="SJVU_SUSPICIOUS_JDK_VERSION_USE" /> <Detector class="com.mebigfatguy.fbcontrib.detect.UseAddAll" speed="fast" reports="UAA_USE_ADD_ALL" /> @@ -264,9 +264,7 @@ <Detector class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections" speed="fast" reports="" hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection" speed="fast" reports="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"/> - - <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> @@ -274,10 +272,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable" speed="fast" reports="UJM_UNJITABLE_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.HangingExecutors" speed="fast" reports="HES_EXECUTOR_NEVER_SHUTDOWN,HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN,HES_LOCAL_EXECUTOR_SERVICE"/> + + <Detector class="com.mebigfatguy.fbcontrib.detect.HttpClientProblems" speed="fast" reports="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD,HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL"/> <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits" speed="fast" reports="CTU_CONFLICTING_TIME_UNITS" /> - COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -384,6 +385,8 @@ <BugPattern abbrev="SPP" type="SPP_NULL_BEFORE_INSTANCEOF" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_NON_USEFUL_TOSTRING" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_TOSTRING_ON_STRING" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_STRING_BUILDER" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_CONVERSION_OF_STRING_LITERAL" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -485,5 +488,7 @@ <BugPattern abbrev="HES" type="HES_EXECUTOR_NEVER_SHUTDOWN" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="HES" type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="HES" type="HES_LOCAL_EXECUTOR_SERVICE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="HCP" type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD" category="CORRECTNESS" experimental="true"/> <BugPattern abbrev="CTU" type="CTU_CONFLICTING_TIME_UNITS" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/etc/messages.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -214,7 +214,7 @@ <Details> <![CDATA[ <p>Looks for methods that use floating point indexes for loops. Since floating point - math is inprecise, rounding errors will occur each time through the loop causing + math is imprecise, rounding errors will occur each time through the loop causing hard to find problems. It is usually better to use integer indexing, and calculating the correct floating point value from the index.</p> <p>It is a fast detector</p> @@ -226,7 +226,7 @@ <Details> <![CDATA[ <p>Looks for method calls to collection classes where the method is not defined by the Collections - interface, and an equivalent method exists in the interface. Examples include:<br> + interface, and an equivalent method exists in the interface. Examples include:<br/> <table border="1"> <tr><th>Old Method</th><th>New Method</th></tr> <tr><td>Hashtable.contains</td><td>Map.containsValue</td></tr> @@ -624,7 +624,7 @@ <![CDATA[ <p>Looks for code that builds an array of values from a collection, by manually looping over the elements of the collection, and adding them to the array. It is simpler and - cleaner to use mycollection.toArray(new type[mycollection.size()].</p> + cleaner to use mycollection.toArray(new type[mycollection.size()]).</p> <p>It is a fast detector</p> ]]> </Details> @@ -1204,7 +1204,7 @@ <![CDATA[ <p>This detector looks for creation of java.awt.Graphics object that do not have the .dispose() method called on them when finished. These objects will be cleaned up by - the Garbage collector, bug given the likelyhood that large numbers of these objects can + the Garbage collector, bug given the likelihood that large numbers of these objects can be created in a short period of time, it is better to dispose them as soon as possible.</p> <p>It is a fast detector</p> ]]> @@ -1418,18 +1418,28 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.HangingExecutors"> <Details> <![CDATA[ - <p>Single detector for hanging ExecutorServices, that is, ExecutorServices that never get a call to shutdown, which + <p>Three detectors for hanging ExecutorServices, that is, ExecutorServices that never get a call to shutdown, which can potentially cause the JVM to not exit.</p> <p>It is a fast detector</p> ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.HttpClientProblems"> + <Details> + <![CDATA[ + <p>The HttpRequests from the apache.httpComponents have some little-known quirks about them. + This is a set of detectors that helps guard against resource starvation.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable"> <Details> <![CDATA[ <p>This detector looks for methods that are longer than 8000 bytes. Methods this - long are automatically disqualified by the jit for compilation and will always be + long are automatically disqualified by the JIT for compilation and will always be emulated. Consider breaking this method up to avoid this, if performance is important.</p> <p>It is a fast detector.</p> ]]> @@ -1458,9 +1468,40 @@ <LongDescription>Method {1} passes simple concatenating string in StringBuffer or StringBuilder append</LongDescription> <Details> <![CDATA[ - <p>This method uses StringBuffer or StringBuilder's append method to concatenate strings. However, it passes the result + <p>This method uses <code>StringBuffer</code> or <code>StringBuilder</code>'s append method to concatenate strings. However, it passes the result of doing a simple String concatenation to one of these append calls, thus removing any performance gains - of using the StringBuffer or StringBuilder class.</p> + of using the <code>StringBuffer</code> or <code>StringBuilder</code> class.</p> + + <p> + Java will implicitly use StringBuilders, which can make this hard to detect or fix. For example, <br/> + <code> + StringBuilder sb = new StringBuilder();<br/> + for (Map.Entry<Integer, String> e : map.entrySet()) {<br/> + sb.append(e.getKey() + e.getValue()); //bug detected here<br/> + }<br/> + </code><br/> + + gets automatically turned into something like: <br/> + <code> + StringBuilder sb = new StringBuilder();<br/> + for (Map.Entry<Integer, String> e : map.entrySet()) {<br/> + StringBuilder tempBuilder = new StringBuilder();<br/> + tempBuilder.append(e.getKey());<br/> + tempBuilder.append(e.getValue());<br/> + sb.append(tempBuilder.toString()); //this isn't too efficient<br/> + }<br/> + </code><br/> + + which involves a temporary <code>StringBuilder</code>, which is completely unneccessary. To prevent this from happening, simply do:<br/> + + <code> + StringBuilder sb = new StringBuilder();<br/> + for (Map.Entry<Integer, String> e : map.entrySet()) {<br/> + sb.append(e.getKey()); <br/> + sb.append(e.getValue());<br/> + }<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1483,9 +1524,31 @@ <LongDescription>Method {1} concatenates the result of a toString() call</LongDescription> <Details> <![CDATA[ - <p>This method concatenates the output of a toString() call into a StringBuffer/Builder. + <p>This method concatenates the output of a <code>toString()</code> call into a <code>StringBuffer</code> or <code>StringBuilder</code>. It is simpler just to pass the object you want to append to the append call, as that form - does not suffer the potential for NullPointerExceptions, and is easier to read.</p> + does not suffer the potential for <code>NullPointerException</code>s, and is easier to read.</p> + + <p> + Keep in mind that Java compiles simple <code>String</code> Concatenation to use <code>StringBuilder</code>s, so you may see this bug even when you don't use <code>StringBuilder</code>s explicitly. + </p> + + <p> + Instead of: <br/> + <code> + StringBuilder builder = ... <br/> + builder.append(someObj.toString());<br/> + ... <br/> + System.out.println("Problem with the object :" + someObj.toString());<br/> + </code> + just do: <br/> + <code> + StringBuilder builder = ... <br/> + builder.append(someObj);<br/> + ... <br/> + System.out.println("Problem with the object :" + someObj);<br/> + </code> + to avoid the possibility of <code>NullPointerException</code>s when someObj is <code>null</code>. + </p> ]]> </Details> </BugPattern> @@ -1504,7 +1567,7 @@ <BugPattern type="CC_CYCLOMATIC_COMPLEXITY"> <ShortDescription>Method is excessively complex</ShortDescription> - <LongDescription>Method {1} is excessively complex</LongDescription> + <LongDescription>Method {1} is excessively complex, with a cyclomatic complexity of {3}</LongDescription> <Details> <![CDATA[ <p>This method has a high cyclomatic complexity figure, which calculates the number of branch @@ -1586,12 +1649,12 @@ <p>This line is in the form of <br/> <code>String str = ...<br/> str.equals("someOtherString");<br/> - //or</br> + //or<br/> str.compareTo("someOtherString");</code></p> <p>A <code>NullPointerException</code> may occur if the String variable <code>str</code> is <code>null</code>. If instead the code was restructured to<br/> <code>String str = ...<br/> "someOtherString".equals(str);<br/> - //or</br> + //or<br/> "someOtherString".compareTo(str);</code><br/> that is, call <code>equals()</code> or <code>compareTo()</code> on the string literal, passing the variable as an argument, this exception could never happen as both <code>equals()</code> and @@ -1785,8 +1848,24 @@ <LongDescription>Method {1} passes parsed string to primitive wrapper constructor</LongDescription> <Details> <![CDATA[ - <p>This method passes a primitive value retrieved from a BoxedPrimitive.parseBoxedPrimitive("1") call to - the same class's constructor. It is simpler to just pass the string to the BoxedPrimitives constructor.</p> + <p>This method passes a primitive value retrieved from a <code>BoxedPrimitive.parseBoxedPrimitive("1")</code> call to + the same class's constructor. It is simpler to just pass the string to the BoxedPrimitives constructor or, better yet, use the static valueOf.</p> + <p>Instead of something like:<br/> + <code> + Boolean bo = new Boolean(Boolean.parseBoolean("true")); <br/> + Float f = new Float(Float.parseFloat("1.234"));<br/> + </code> + Simply do: <br/> + <code> + Boolean bo = new Boolean("true"); <br/> + Float f = new Float("1.234");<br/> + </code> + or, to be more memory efficient: <br/> + <code> + Boolean bo = Boolean.valueOf("true"); <br/> + Float f = Float.valueOf("1.234");<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1810,8 +1889,27 @@ <![CDATA[ <p>This method passes a String to a wrapped primitive object's valueOf method, which in turn calls the boxedValue() method to convert to a primitive. When it is desired to convert from a String - to a primitive value, it is simpler to use the BoxedPrimitive.parseBoxedPrimitive(myString) + to a primitive value, it is simpler to use the BoxedPrimitive.parseBoxedPrimitive(String) method. </p> + + <p>Instead of something like:<br/> + <code> + public int someMethod(String data) {<br/> + long l = Long.valueOf(data).longValue(); <br/> + float f = Float.valueOf(data).floatValue(); <br/> + return Integer.valueOf(data); // There is an implicit .intValue() call<br/> + }<br/> + </code> + Simply do: <br/> + <code> + public int someMethod(String data) {<br/> + long l = Long.parseLong(data); <br/> + float f = Float.parseFloat(data); <br/> + return Integer.parseInt(data); <br/> + }<br/> + </code> + </p> + ]]> </Details> </BugPattern> @@ -1823,8 +1921,19 @@ <![CDATA[ <p>This method passes a String to a wrapped primitive object's parse method, which in turn calls the valueOf() method to convert to a boxed primitive. When it is desired to convert from a String - to a boxed primitive object, it is simpler to use the BoxedPrimitive.valueOf(myString) - method.</p> + to a boxed primitive object, it is simpler to use the BoxedPrimitive.valueOf(String) method.</p> + + <p>Instead of something like:<br/> + <code> + Boolean bo = Boolean.valueOf(Boolean.parseBoolean("true")); <br/> + Float f = Float.valueOf(Float.parseFloat("1.234"));<br/> + </code> + Simply do: <br/> + <code> + Boolean bo = Boolean.valueOf("true"); <br/> + Float f = Float.valueOf("1.234");<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1836,17 +1945,18 @@ <![CDATA[ <p>This method constructs a Boxed Primitive from a primitive only to call the primitiveValue() method to convert it back to a primitive. Just use the primitive value instead.</p> - <pre> - primitive i = new BoxedPrimitive(1).primitiveValue(); - </pre> - or - <pre> - primitive i = BoxedPrimitive.valueOf(1).primitiveValue(); - </pre> - should just use - <pre> - primitive i = 1; - </pre> + <p>Instead of something like:<br/> + <code> + boolean bo = new Boolean(true).booleanValue(); <br/> + float f = new Float(1.234f).floatValue();<br/> + </code> + Simply do: <br/> + <code> + boolean bo = true; <br/> + float f = 1.234f;<br/> + </code> + </p> + ]]> </Details> </BugPattern> @@ -1857,18 +1967,24 @@ <Details> <![CDATA[ <p>This method constructs a Boxed Primitive from a primitive only to call the primitiveValue() method to - cast the value to another primitive type. It is simpler to just use casting</p> - <pre> - primitive i = new BoxedPrimitive(1.0).primitiveValue(); - </pre> - or - <pre> - primitive i = BoxedPrimitive.valueOf(1.0).primitiveValue(); - </pre> - should just use - <pre> - primitive i = (primitive)1.0; - </pre> + cast the value to another primitive type. It is simpler to just use casting.</p> + <p>Instead of something like:<br/> + <code> + double someDouble = ...<br/> + float f = new Double(someDouble).floatValue();<br/> + <br/> + int someInt = ...<br/> + byte b = new Integer(someInt).byteValue();<br/> + </code> + Simply do: <br/> + <code> + double someDouble = ...<br/> + float f = (float) someDouble;<br/> + <br/> + int someInt = ...<br/> + byte b = (byte)someInt;<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -1879,16 +1995,39 @@ <Details> <![CDATA[ <p>This method assigns a Boxed boolean constant to a primitive boolean variable, or assigns a primitive boolean - constant to a Boxed boolean variable. Use the correct constant for the variable desired. Use</p> - <pre> - boolean b = true; - boolean b = false; - </pre> - or - <pre> - Boolean b = Boolean.TRUE; + constant to a Boxed boolean variable. Use the correct constant for the variable desired. Use <br/> + <code> + boolean b = true;<br/> + boolean b = false;<br/> + </code> + or <br/> + <code> + Boolean b = Boolean.TRUE;<br/> Boolean b = Boolean.FALSE; - </pre> + </code> + </p> + + <p>Be aware that this boxing happens automatically when you might not expect it. For example, <br/> + <code> + Map<String, Boolean> statusMap = ... <br/> + <br/> + public Boolean someMethod() {<br/> + statusMap.put("foo", true); //the "true" here is boxed<br/> + return false; //the "false" here is boxed<br/> + }<br/> + </code> + has two cases of this needless autoboxing. This can be made more efficient by simply substituting + in the constant values: <br/> + + <code> + Map<String, Boolean> statusMap = ... <br/> + <br/> + public Boolean someMethod() {<br/> + statusMap.put("foo", Boolean.TRUE); <br/> + return Boolean.FALSE; <br/> + }<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -2037,7 +2176,7 @@ <![CDATA[ <p>This method calls a method to load a reference to an object, and then only uses it to load a static member of that instance's class. It is simpler and - better performant to just load the static field from the class itself.</p> + more performant to just load the static field from the class itself.</p> ]]> </Details> </BugPattern> @@ -2049,29 +2188,31 @@ <![CDATA[ <p>This method compares dates with two comparisons, rather than using the reverse comparison. So this pattern</p> - <pre> - if ((date1.equals( date2 )) || (date1.after( date2 ))) - </pre> - could become - <pre> - if (date1.compareTo( date2 ) >= 0) - </pre> - and - <pre> - if ((date1.equals( date2 )) || (date1.before( date2 ))) - </pre> - could become - <pre> - if (date1.compareTo( date2 ) <= 0) - </pre> - and - <pre> - if ((date1.before( date2 )) || (date1.after( date2 ))) - </pre> - could become - <pre> - if (!date1.equals( date2 )) - </pre> + <code> + if ((date1.equals( date2 )) || (date1.after( date2 )))<br/> + </code> + could become:<br/> + <code> + if (date1.compareTo( date2 ) >= 0) <br/> + </code> + <br/> + and<br/> + <code> + if ((date1.equals( date2 )) || (date1.before( date2 ))) <br/> + </code> + could become <br/> + <code> + if (date1.compareTo( date2 ) <= 0) <br/> + </code> + <br/> + and<br/> + <code> + if ((date1.before( date2 )) || (date1.after( date2 ))) <br/> + </code> + could become<br/> + <code> + if (!date1.equals( date2 ))<br/> + </code> ]]> </Details> </BugPattern> @@ -2152,7 +2293,7 @@ <Details> <![CDATA[ <p>This method creates a synchronized collection and store the reference to it - in a local variable. As local variables are by definition threadsafe, it seems + in a local variable. As local variables are by definition thread-safe, it seems questionable that this collection needs to be synchronized.</p> <p> <table> @@ -2297,7 +2438,7 @@ <Details> <![CDATA[ <p>This class uses an ordinary set or map collection and uses an enum class as the key type. - It is better performant to use the JDK 1.5 EnumSet or EnumMap classes.</p> + It is more performant to use the JDK 1.5 EnumSet or EnumMap classes.</p> ]]> </Details> </BugPattern> @@ -2399,9 +2540,31 @@ <LongDescription>Method {1} passes constant String of length 1 to character overridden method</LongDescription> <Details> <![CDATA[ - <p>This method passes a constant literal String of length 1 as a parameter to a method, that - exposes a similar method that takes a character. It is simpler and more expedient to handle one - character, rather than pass a string.</p> + <p>This method passes a constant literal <code>String</code> of length 1 as a parameter to a method, that + exposes a similar method that takes a <code>char</code>. It is simpler and more expedient to handle one + character, rather than a <code>String</code.</p> + + <p> + Instead of making calls like: <br/> + <code> + String myString = ... <br/> + if (myString.indexOf("e") != -1) {<br/> + int i = myString.lastIndexOf("e");<br/> + ...<br/> + return myString.replace("m","z");<br/> + }<br/> + </code> + Replace the single letter <code>String</code>s with their <code>char</code> equivalents like so:<br/> + + <code> + String myString = ... <br/> + if (myString.indexOf('e') != -1) {<br/> + int i = myString.lastIndexOf('e');<br/> + ...<br/> + return myString.replace('m','z');<br/> + }<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -2595,14 +2758,15 @@ <![CDATA[ <p>This method attempts to check for null by just referring to the variable name as would be done in C++. This ordinarily would be considered a compile error, except the - variable in question is a Boolean, which does an auto unbox to boolean.</p> - <pre> - if (b && b.booleanValue()) - </pre> - should be - <pre> - if ((b != null) && b.booleanValue()) - </pre> + variable in question is a Boolean, which does an auto unbox to boolean. + <code><br/> + if (b && b.booleanValue())<br/> + </code> + should be<br/> + <code> + if ((b != null) && b.booleanValue())<br/> + </code> + </p> ]]> </Details> </BugPattern> @@ -2798,8 +2962,32 @@ <LongDescription>Method {1} appends two literal strings back to back to a StringBuilder</LongDescription> <Details> <![CDATA[ - <p>This method appends two literal strings to a StringBuilder back to back. This can be done with just - one append call, and may avoid intermediate reallocations of the StringBuilders backing store.</p> + <p>This method appends two literal strings to a <code>StringBuilder</code> back to back. + Modern compilers will optimize something like:<br/> + <code> + public static final string CONST_VAL = "there";<br/> + ...<br/> + String str = "Hello" + " "+ CONST_VAL + " " +"world!";<br/> + </code> + to: <br/> + <code> + public static final string CONST_VAL = "there";<br/> + ...<br/> + String str = "Hello there world!";<br/> + </code> + This means the concatenation is done during compile time, not at runtime, so there's <b>no need</b> to do: <br/> + <code> + public static final string CONST_VAL = "there";<br/> + ...<br/> + StringBuilder sb = new StringBuilder("Hello").append(" ").append(CONST_VAL).append(" ").append("world!");<br/> + String str = sb.toString();<br/> + </code> + which is harder to read and will result in more complex bytecode. + </p> + + <p> + Simply append your constants with the "+" symbol, don't append them with <code>StringBuilder.append()</code>. + </p> ]]> </Details> </BugPattern> @@ -2836,6 +3024,42 @@ ]]> </Details> </BugPattern> + + <BugPattern type="SPP_CONVERSION_OF_STRING_LITERAL"> + <ShortDescription>Method converts a String literal</ShortDescription> + <LongDescription>Method {1} calls {3} on a String Literal</LongDescription> + <Details> + <![CDATA[ + <p>This methods calls a converting method like <code>toLowerCase()</code> or <code>trim</code> + on a <code>String</code> literal. You should make the transformation yourself and use the transformed literal.</p> + + <p> + For example, instead of :<br/> + <code> + return "ThisIsAConstantString ".toLowerCase().trim(); <br/> + </code> + just do <br/> + <code> + return "thisisaconstantstring"; <br/> + </code> + for shorter and easier to read code. An exception might be made when locale-specific transformations need to be done (in the case of <code>toUpperCase()</code> and <code>toLowerCase()</code>. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="SPP_EQUALS_ON_STRING_BUILDER"> + <ShortDescription>Method calls equals(Object o) on a StringBuilder or StringBuffer</ShortDescription> + <LongDescription>Method {1} calls equals(Object o) on a StringBuilder or StringBuffer</LongDescription> + <Details> + <![CDATA[ + <p>This method calls equals on a StringBuilder or StringBuffer. Surprisingly, these classes do not override + the equals method from Object, and so equals is just defined to be == (or same references). This is most + likely not what you would like. If you wish to check that the strings have the same characters, you need to + call toString() on these object and compare them as Strings. + ]]> + </Details> + </BugPattern> <BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE"> <ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription> @@ -3148,7 +3372,7 @@ <BugPattern type="LO_SUSPECT_LOG_CLASS"> <ShortDescription>Method specifies an unrelated class when allocating a Logger</ShortDescription> - <LongDescription>Method {1} specifies an unrelated class when allocating a Logger</LongDescription> + <LongDescription>Method {1} specifies an unrelated class when allocating a Logger. Saw "{3}", expected "{4}".</LongDescription> <Details> <![CDATA[ <p>This method creates a Logger by passing in a specification for a class that is unrelated @@ -3212,7 +3436,7 @@ <LongDescription>Method {1} creates exception with logger parameter markers in message</LongDescription> <Details> <![CDATA[ - <pThis method creates an standard exception passing a message string which contains an slf4j style + <p>This method creates a standard exception passing a message string which contains an slf4j style parameter marker '{}'. This marker will not be translated as it is not processed by the Exception class. </p> ]]> @@ -3224,7 +3448,7 @@ <LongDescription>Method {1} passes a concatenated string to Slf4j's format string</LongDescription> <Details> <![CDATA[ - <p>This method uses an slf4j logger to log a string, where the first (format) string is created using concatenation. + <p>This method uses an Slf4j logger to log a string, where the first (format) string is created using concatenation. You should use {} markers to inject dynamic content into the string, so that String building is delayed until the actual log string is needed. If the log level is high enough that this log statement isn't used, then the appends will never be executed. @@ -3425,13 +3649,13 @@ <p>This method contains a contravariant array assignment. Since arrays are mutable data structures, their use must be restricted to covariant or invariant usage.</p> - <pre> - class A {} - class B extends A {} - - B[] b = new B[2]; - A[] a = b; - </pre> + <code> + class A {}<br/> + class B extends A {}<br/> + <br/> + B[] b = new B[2];<br/> + A[] a = b;<br/> + </code> ]]> </Details> </BugPattern> @@ -3444,14 +3668,14 @@ <p>This method contains a contravariant array element assignment. Since arrays are mutable data structures, their use must be restricted to covariant or invariant usage.</p> - <pre> - class A {} - class B extends A {} - - B[] b = new B[2]; - A[] a = b; - a[0] = new A(); // results in ArrayStoreException (Runtime) - </pre> + <code> + class A {}<br/> + class B extends A {}<br/> + <br/> + B[] b = new B[2];<br/> + A[] a = b;<br/> + a[0] = new A(); // results in ArrayStoreException (Runtime)<br/> + </code> ]]> </Details> </BugPattern> @@ -3588,7 +3812,7 @@ <LongDescription>Method {1} sleeps without timeout when calling {2}</LongDescription> <Details> <![CDATA[ - <p>Calling <code>{2}</code> without timeout could block forever. Consider using a timeout to detect deadlocks or performance problems. Thread.join() Object.wait() Condition.await() Lock.lock() Lock.lockInterruptibly()</p> + <p>Calling one of the following methods without timeout could block forever. Consider using a timeout to detect deadlocks or performance problems. Methods: Thread.join(), Object.wait(), Condition.await(), Lock.lock(), Lock.lockInterruptibly(), ReentrantLock.lock(), ReentrantLock.lockInterruptibly()</p> ]]> </Details> </BugPattern> @@ -3866,8 +4090,8 @@ </BugPattern> <BugPattern type="CU_CLONE_USABILITY_MISMATCHED_RETURN"> - <ShortDescription>Clone method declares it returns an type different then the owning class</ShortDescription> - <LongDescription>Clone method {1} declares it returns an type different then the owning class</LongDescription> + <ShortDescription>Clone method declares it returns a type different then the owning class</ShortDescription> + <LongDescription>Clone method {1} declares it returns a type different then the owning class</LongDescription> <Details> <![CDATA[ <p>This class implements the Cloneable interface but defines its clone method to return a type @@ -3977,7 +4201,7 @@ <Details> <![CDATA[ <p>This class defines a field or local collection variable with a name that contains a different type - of collection in its name. An example woutd be a Set<User> called userList. This is confusing to the reader, + of collection in its name. An example would be a Set<User> called userList. This is confusing to the reader, and likely caused by a previous refactor of type, without changing the name.</p> ]]> </Details> @@ -4050,7 +4274,7 @@ <p>Even though there are some exceptions to this, particularly when a custom <code>ThreadFactory</code> is provided, or for <code>ThreadPoolExecutor</code>s with <code>allowsCoreThreadTimeOut()</code> set to true, - it is good practice to explictly shutdown the <code>ExecutorService</code> when its utility is done.</p> + it is good practice to explicitly shutdown the <code>ExecutorService</code> when its utility is done.</p> ]]> </Details> </BugPattern> @@ -4069,7 +4293,7 @@ </Details> </BugPattern> -<BugPattern type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN"> + <BugPattern type="HES_EXECUTOR_OVERWRITTEN_WITHOUT_SHUTDOWN"> <ShortDescription>An ExecutorService isn't shutdown before the reference to it is lost</ShortDescription> <LongDescription>ExecutorService {2} is replaced with another ExecutorService without being shutdown, potentially preventing the entire JVM from shutting down</LongDescription> <Details> @@ -4102,7 +4326,7 @@ <p>Even though there are some exceptions to this, particularly when a custom <code>ThreadFactory</code> is provided, or for <code>ThreadPoolExecutor</code>s with <code>allowsCoreThreadTimeOut()</code> set to true, - it is good practice to explictly shutdown the <code>ExecutorService</code> at the end of execution, or + it is good practice to explicitly shutdown the <code>ExecutorService</code> at the end of execution, or when it is being replaced.</p> <p><b>Note:</b> <code>ExecutorService</code>s are generally created once in a program's lifecycle. If you find yourself @@ -4111,6 +4335,101 @@ ]]> </Details> </BugPattern> + + <BugPattern type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD"> + <ShortDescription>Unreleased HttpRequest network resources (field)</ShortDescription> + <LongDescription>The HttpRequest field {1} does not release its network resources, which could freeze the running code</LongDescription> + <Details> + <![CDATA[ + <p>FindBugs has detected an <code>org.apache.http.HttpRequest</code> (e.g. <code>HttpGet</code>, <code>HttpPost</code>, etc) + that didn't release its associated resources. Code like the following: <br/> + <code> + private HttpGet httpGet; <br/> + ...</br> + public String requestInfo(URI u) {</br> + this.httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + return null;</br> + }</br> + </code> + will freeze after a few requests, usually with no indication as to why. </p> + + <p> + The reason this code freezes is because <code>org.apache.http.HttpRequest</code>s need explicitly release their connection + with a call to either <code>reset()</code> or <code>releaseConnection()</code>. The above example can be easily fixed:<br/> + <code> + private HttpGet httpGet; <br/> + ...</br> + public String requestInfo(URI u) {</br> + this.httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + <b>finally {</br> + this.httpGet.reset();</br> + }</b></br> + return null;</br> + }</br> + </code> + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_LOCAL"> + <ShortDescription>Unreleased HttpRequest network resources (local)</ShortDescription> + <LongDescription>The local HttpRequest {1} does not release its network resources before being garbage collected, which could freeze the running code</LongDescription> + <Details> + <![CDATA[ + <p>FindBugs has detected an <code>org.apache.http.HttpRequest</code> (e.g. <code>HttpGet</code>, <code>HttpPost</code>, etc) + that didn't release its associated resources. Code like the following: <br/> + <code> + public String requestInfo(URI u) {</br> + HttpGet httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + return null;</br> + }</br> + </code> + will freeze after a few requests, usually with no indication as to why. </p> + + <p> + The reason this code freezes is because <code>org.apache.http.HttpRequest</code>s need explicitly release their connection + with a call to either <code>reset()</code> or <code>releaseConnection()</code>, <b>even if the request is a local</b>. + The garbage collector will not release these resources, leading to the frustrating freezing scenario described above. + + <br/>The above example can be easily fixed:<br/> + <code> + public String requestInfo(URI u) {</br> + HttpGet httpGet = new HttpGet(u);</br> + try(CloseableHttpResponse response = client.execute(httpGet);) {</br> + return getResponseAsString(response);</br> + }</br> + catch (IOException e) ( </br> + e.printStackTrace();</br> + }</br> + <b>finally {</br> + httpGet.reset();</br> + }</b></br> + return null;</br> + }</br> + </code> + </p> + ]]> + </Details> + </BugPattern> <BugPattern type="UJM_UNJITABLE_METHOD"> <ShortDescription>This method is too long to be compiled by the JIT</ShortDescription> @@ -4258,5 +4577,6 @@ <BugCode abbrev="MUC">Modifying Unmodifiable Collection</BugCode> <BugCode abbrev="UJM">Unjitable method</BugCode> <BugCode abbrev="HES">Hanging ExecutorService</BugCode> + <BugCode abbrev="HCP">HttpClient Problems</BugCode> <BugCode abbrev="CTU">Conflicting Time Units</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/htdocs/index.shtml 2014-07-26 03:40:55 UTC (rev 1774) @@ -68,11 +68,12 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 5.2.0 available for download - <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-5.2.0.jar/download">here</a>.</p> + <p style="font-weight: bold;">The latest version of fb-contrib is 6.0.0 available for download + <a href="http://sourceforge.net/projects/fb-contrib/files/Current/fb-contrib-6.0.0.jar/download">here</a>.</p> + <p style="font-weight: bold;">This version requires FindBugs 3.0 or better</p> </div> - <hr/> + <hr/> <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> Detectors added in git<br/> <div id="git" style="display:none;"> @@ -82,6 +83,14 @@ same kind of exception, and throw the same exception always. These blocks can be coalesced into one. </li> + </ul> + </div> + + <hr/> + + <img id="v6_0_0_image" src="flip2.gif" onClick="toggleBlock('v6_0_0', 'v6_0_0_image');" align="top"/> + Detectors added in v6.0.0<br/> + <div id="v6_0_0" style="display:block;"> <li><b>[PSC] Presize Collections</b><br/> Looks for methods that create and populate collections, and while knowing the end size of those collections, does not pre allocate the collection @@ -110,12 +119,17 @@ Looks for methods that perform arithmetic operations on values representing time where the time unit is incompatible, ie adding a millisecond value to a nanosecond value. </li> + <li><b>[HCP] Http Client Problems</b><br/> + The HttpRequests from the apache.httpComponents have some little-known quirks about them. + This is a set of detectors that helps guard against resource starvation.<br/> + <span style="color: #0000FF;">--contributed by Kevin Lubick - THANKS!</span> + </li> </ul> </div> <hr/> - <img id="v5_2_0_image" src="flip2.gif" onClick="toggleBlock('v5_2_0', 'v5_2_0_image');" align="top"/> + <img id="v5_2_0_image" src="flip1.gif" onClick="toggleBlock('v5_2_0', 'v5_2_0_image');" align="top"/> Detectors added in v5.2.0<br/> - <div id="git" style="display:block;"> + <div id="v5_2_0" style="display:none;"> <ul> <li><b>[CNC] Collection Naming Confusion</b><br/> Looks for fields and local variables that have Map, Set, List in their names Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/htdocs/repository.html 2014-07-26 03:40:55 UTC (rev 1774) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>5.2.0</td></tr> + <tr><td><b>Version:</b></td><td>6.0.0</td></tr> </table> </div> Modified: trunk/fb-contrib/plugin.xml =================================================================== --- trunk/fb-contrib/plugin.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/plugin.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> -<plugin id="fb-contrib" name="fb-contrib" version="5.2.0"> +<plugin id="fb-contrib" name="fb-contrib" version="6.0.0"> <extension point="edu.umd.cs.findbugs.plugin.eclipse.findbugsPlugins"> <findbugsPlugin fbPluginId="com.mebigfatguy.fbcontrib" libraryPath="."></findbugsPlugin> </extension> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/pom.xml 2014-07-26 03:40:55 UTC (rev 1774) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>5.2.1</version> + <version>6.0.0</version> <parent> <groupId>org.sonatype.oss</groupId> @@ -106,7 +106,7 @@ <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>findbugs</artifactId> - <version>2.0.3</version> + <version>3.0.0</version> <scope>provided</scope> </dependency> </dependencies> @@ -198,8 +198,8 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.5</source> - <target>1.5</target> + <source>1.6</source> + <target>1.6</target> </configuration> </plugin> </plugins> Modified: trunk/fb-contrib/samples/ABC_Sample.java =================================================================== --- trunk/fb-contrib/samples/ABC_Sample.java 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/samples/ABC_Sample.java 2014-07-26 03:40:55 UTC (rev 1774) @@ -28,6 +28,7 @@ public UseComparator() { testComp = new TreeMap<byte[], byte[]>(new Comparator<byte[]>() { + @Override public int compare(byte[] b1, byte[] b2) { return b1.length - b2.length; } Modified: trunk/fb-contrib/samples/COM_Sample.java =================================================================== --- trunk/fb-contrib/samples/COM_Sample.java 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/samples/COM_Sample.java 2014-07-26 03:40:55 UTC (rev 1774) @@ -46,11 +46,13 @@ } abstract class c1 implements Inf { + @Override public void m1() { } } abstract class c2 extends c1 { + @Override public void m2() { } } Modified: trunk/fb-contrib/samples/CU_Sample.java =================================================================== --- trunk/fb-contrib/samples/CU_Sample.java 2014-05-24 04:13:22 UTC (rev 1773) +++ trunk/fb-contrib/samples/CU_Sample.java 2014-07-26 03:40:55 UTC (rev 1774... [truncated message content] |