Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1BC61200D04 for ; Mon, 11 Sep 2017 10:37:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1A4F91609C3; Mon, 11 Sep 2017 08:37:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 140A91609C4 for ; Mon, 11 Sep 2017 10:37:18 +0200 (CEST) Received: (qmail 39082 invoked by uid 500); 11 Sep 2017 08:37:18 -0000 Mailing-List: contact notifications-help@ofbiz.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ofbiz.apache.org Delivered-To: mailing list notifications@ofbiz.apache.org Received: (qmail 39064 invoked by uid 99); 11 Sep 2017 08:37:18 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Sep 2017 08:37:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 7E066183579 for ; Mon, 11 Sep 2017 08:37:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id ZwTl_npOYg5y for ; Mon, 11 Sep 2017 08:37:15 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 6A80C61283 for ; Mon, 11 Sep 2017 08:37:12 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6FE82E0E3D for ; Mon, 11 Sep 2017 08:37:09 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 945762416E for ; Mon, 11 Sep 2017 08:37:04 +0000 (UTC) Date: Mon, 11 Sep 2017 08:37:04 +0000 (UTC) From: "Julian Leichert (JIRA)" To: notifications@ofbiz.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (OFBIZ-9702) [FB] Package org.apache.ofbiz.widget.renderer.macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 11 Sep 2017 08:37:20 -0000 Julian Leichert created OFBIZ-9702: -------------------------------------- Summary: [FB] Package org.apache.ofbiz.widget.renderer.macro Key: OFBIZ-9702 URL: https://issues.apache.org/jira/browse/OFBIZ-9702 Project: OFBiz Issue Type: Sub-task Affects Versions: Trunk Reporter: Julian Leichert Priority: Minor MacroFormRenderer.java:237, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE - RCN: Redundant nullcheck of fieldMap, which is known to be non-null in or= g.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.renderDisplayField(A= ppendable, Map, ModelFormField$DisplayField) This method contains a redundant check of a known non-null value against th= e constant null. MacroFormRenderer.java:246, SBSC_USE_STRINGBUFFER_CONCATENATION - SBSC: org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.renderDisp= layField(Appendable, Map, ModelFormField$DisplayField) concatenates strings= using + in a loop The method seems to be building a String using concatenation in a loop. In = each iteration, the String is converted to a StringBuffer/StringBuilder, ap= pended to, and converted back to a String. This can lead to a cost quadrati= c in the number of iterations, as the growing string is recopied in each it= eration. Better performance can be obtained by using a StringBuffer (or StringBuilde= r in Java 1.5) explicitly. For example: // This is bad String s =3D ""; for (int i =3D 0; i < field.length; ++i) { s =3D s + field[i]; } // This is better StringBuffer buf =3D new StringBuffer(); for (int i =3D 0; i < field.length; ++i) { buf.append(field[i]); } String s =3D buf.toString(); MacroFormRenderer.java:538, DM_BOXED_PRIMITIVE_FOR_PARSING - Bx: Boxing/unboxing to parse a primitive org.apache.ofbiz.widget.renderer= .macro.MacroFormRenderer.renderDateTimeField(Appendable, Map, ModelFormFiel= d$DateTimeField) A boxed primitive is created from a String, just to extract the unboxed pri= mitive value. It is more efficient to just call the static parseXXX method. MacroFormRenderer.java:1000, RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT Return value of method without side effect is ignored This code calls a method and ignores the return value. However our analysis= shows that the method (including its implementations in subclasses if any)= does not produce any effect other than return value. Thus this call can be= removed. We are trying to reduce the false positives as much as possible, but in som= e cases this warning might be wrong. Common false-positive cases include: - The method is designed to be overridden and produce a side effect in othe= r projects which are out of the scope of the analysis. - The method is called to trigger the class loading which may have a side e= ffect. - The method is called just to get some exception. If you feel that our assumption is incorrect, you can use a @CheckReturnVal= ue annotation to instruct FindBugs that ignoring the return value of this m= ethod is acceptable. MacroFormRenderer.java:1062, RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT, Priori= t=C3=A4t: Normal Return value of method without side effect is ignored This code calls a method and ignores the return value. However our analysis= shows that the method (including its implementations in subclasses if any)= does not produce any effect other than return value. Thus this call can be= removed. We are trying to reduce the false positives as much as possible, but in som= e cases this warning might be wrong. Common false-positive cases include: - The method is designed to be overridden and produce a side effect in othe= r projects which are out of the scope of the analysis. - The method is called to trigger the class loading which may have a side e= ffect. - The method is called just to get some exception. If you feel that our assumption is incorrect, you can use a @CheckReturnVal= ue annotation to instruct FindBugs that ignoring the return value of this m= ethod is acceptable. MacroFormRenderer.java:1275, DM_CONVERT_CASE, Priorit=C3=A4t: Niedrig Dm: Use of non-localized String.toUpperCase() or String.toLowerCase() in or= g.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.renderFieldTitle(App= endable, Map, ModelFormField) A String is being converted to upper or lowercase, using the platform's def= ault encoding. This may result in improper conversions when used with inter= national characters. Use the String.toUpperCase( Locale l ) String.toLowerCase( Locale l ) versions instead. MacroFormRenderer.java:1639, NP_NULL_ON_SOME_PATH - NP: Possible null pointer dereference of itemIndex in org.apache.ofbiz.wi= dget.renderer.macro.MacroFormRenderer.renderFormatItemRowOpen(Appendable, M= ap, ModelForm) There is a branch of statement that, if executed, guarantees that a null va= lue will be dereferenced, which would generate a NullPointerException when = the code is executed. Of course, the problem might be that the branch or st= atement is infeasible and that the null pointer exception can't ever be exe= cuted; deciding that is beyond the ability of FindBugs. MacroFormRenderer.java:2339, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE - RCN: Redundant nullcheck of prepLinkText, which is known to be non-null i= n org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.renderNextPrev(A= ppendable, Map, ModelForm) This method contains a redundant check of a known non-null value against th= e constant null. MacroFormRenderer.java:2979, SBSC_USE_STRINGBUFFER_CONCATENATION - SBSC: org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.createAjax= ParamsFromUpdateAreas(List, String, Map) concatenates strings using + in a = loop The method seems to be building a String using concatenation in a loop. In = each iteration, the String is converted to a StringBuffer/StringBuilder, ap= pended to, and converted back to a String. This can lead to a cost quadrati= c in the number of iterations, as the growing string is recopied in each it= eration. Better performance can be obtained by using a StringBuffer (or StringBuilde= r in Java 1.5) explicitly. For example: // This is bad String s =3D ""; for (int i =3D 0; i < field.length; ++i) { s =3D s + field[i]; } // This is better StringBuffer buf =3D new StringBuffer(); for (int i =3D 0; i < field.length; ++i) { buf.append(field[i]); } String s =3D buf.toString(); MacroFormRenderer.java:3069, RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE - RCN: Nullcheck of modelFormField at line 3083 of value previously derefer= enced in org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.makeHyper= linkByType(Appendable, String, String, String, String, Map, String, String,= String, ModelFormField, HttpServletRequest, HttpServletResponse, Map) A value is checked here to see whether it is null, but this value can't be = null because it was previously dereferenced and if it were null a null poin= ter exception would have occurred at the earlier dereference. Essentially, = this code and the previous dereference disagree as to whether this value is= allowed to be null. Either the check is redundant or the previous derefere= nce is erroneous. MacroFormRenderer.java:3188, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE RCN: Redundant nullcheck of hiddenFormName, which is known to be non-null i= n org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.makeHyperlinkStr= ing(Appendable, String, String, String, Map, String, String, ModelFormField= , HttpServletRequest, HttpServletResponse, Map, String) This method contains a redundant check of a known non-null value against th= e constant null. MacroFormRenderer.java:3240, RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE - RCN: Redundant nullcheck of hiddenFormName, which is known to be non-null= in org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer.makeHiddenForm= LinkAnchor(Appendable, String, String, String, ModelFormField, HttpServletR= equest, HttpServletResponse, Map) This method contains a redundant check of a known non-null value against th= e constant null. MacroScreenRenderer.java:443, DM_CONVERT_CASE - Dm: Use of non-localized String.toUpperCase() or String.toLowerCase() in = org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer.renderContentEnd= (Appendable, Map, ModelScreenWidget$Content) A String is being converted to upper or lowercase, using the platform's def= ault encoding. This may result in improper conversions when used with inter= national characters. Use the String.toUpperCase( Locale l ) String.toLowerCase( Locale l ) versions instead. MacroScreenRenderer.java:443, RV_CHECK_FOR_POSITIVE_INDEXOF - RV: org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer.renderCont= entEnd(Appendable, Map, ModelScreenWidget$Content) checks to see if result = of String.indexOf is positive The method invokes String.indexOf and checks to see if the result is positi= ve or non-positive. It is much more typical to check to see if the result i= s negative or non-negative. It is positive only if the substring checked fo= r occurs at some place other than at the beginning of the String. MacroScreenRenderer.java:555, DM_CONVERT_CASE - Dm: Use of non-localized String.toUpperCase() or String.toLowerCase() in = org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer.renderSubContent= End(Appendable, Map, ModelScreenWidget$SubContent) A String is being converted to upper or lowercase, using the platform's def= ault encoding. This may result in improper conversions when used with inter= national characters. Use the String.toUpperCase( Locale l ) String.toLowerCase( Locale l ) versions instead. MacroScreenRenderer.java:555, RV_CHECK_FOR_POSITIVE_INDEXOF - RV: org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer.renderSubC= ontentEnd(Appendable, Map, ModelScreenWidget$SubContent) checks to see if r= esult of String.indexOf is positive The method invokes String.indexOf and checks to see if the result is positi= ve or non-positive. It is much more typical to check to see if the result i= s negative or non-negative. It is positive only if the substring checked fo= r occurs at some place other than at the beginning of the String. MacroScreenRenderer.java:726, DM_CONVERT_CASE - Dm: Use of non-localized String.toUpperCase() or String.toLowerCase() in = org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer.renderScreenletP= aginateMenu(Appendable, Map, ModelScreenWidget$Form) A String is being converted to upper or lowercase, using the platform's def= ault encoding. This may result in improper conversions when used with inter= national characters. Use the String.toUpperCase( Locale l ) String.toLowerCase( Locale l ) versions instead. MacroScreenRenderer.java:1022, NP_NULL_ON_SOME_PATH - NP: Possible null pointer dereference of modelScreen in org.apache.ofbiz.= widget.renderer.macro.MacroScreenRenderer.renderPortalPagePortletBody(Appen= dable, Map, ModelScreenWidget$PortalPage, GenericValue) There is a branch of statement that, if executed, guarantees that a null va= lue will be dereferenced, which would generate a NullPointerException when = the code is executed. Of course, the problem might be that the branch or st= atement is infeasible and that the null pointer exception can't ever be exe= cuted; deciding that is beyond the ability of FindBugs. -- This message was sent by Atlassian JIRA (v6.4.14#64029)