ofbiz-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dennis Balkir (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OFBIZ-9694) [FB] Package org.apache.ofbiz.service.test
Date Fri, 08 Sep 2017 12:20:00 GMT

     [ https://issues.apache.org/jira/browse/OFBIZ-9694?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Dennis Balkir updated OFBIZ-9694:
    Attachment: OFBIZ-9694_org.apache.ofbiz.service.test_bugfixes.patch

- Diamond Operators fixed

class ServiceSOAPTests:
- Line 41: changed the new operator to {{Double.valueOf()}} because is faster

class XmlRpcTests:
- Line 41: changed the parameter to private
- Line 47: it is possible to refactor this into a new method, but it doesn’t really make

> [FB] Package org.apache.ofbiz.service.test
> ------------------------------------------
>                 Key: OFBIZ-9694
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9694
>             Project: OFBiz
>          Issue Type: Sub-task
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Dennis Balkir
>            Priority: Minor
>         Attachments: OFBIZ-9694_org.apache.ofbiz.service.test_bugfixes.patch
> - ServiceEngineTestServices.java:316, REC_CATCH_EXCEPTION
> REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.service.test.ServiceEngineTestServices.testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent(DispatchContext,
> This method uses a try-catch block that catches Exception objects, but Exception is not
thrown within the try block, and RuntimeException is not explicitly caught. It is a common
bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching
a number of types of exception each of whose catch blocks is identical, but this construct
also accidentally catches RuntimeException as well, masking potential bugs.
> A better approach is to either explicitly catch the specific exceptions that are thrown,
or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime
Exceptions, as shown below:
>   try {
>     ...
>   } catch (RuntimeException e) {
>     throw e;
>   } catch (Exception e) {
>     ... deal with all non-runtime exceptions ...
>   }
> - ServiceSOAPTests.java:41, DM_FP_NUMBER_CTOR
> Bx: org.apache.ofbiz.service.test.ServiceSOAPTests.testSOAPSimpleService() invokes inefficient
new Double(String) constructor; use Double.valueOf(String) instead
> Using new Double(double) is guaranteed to always result in a new object whereas Double.valueOf(double)
allows caching of values to be done by the compiler, class library, or JVM. Using of cached
values avoids object allocation and the code will be faster.
> Unless the class must be compatible with JVMs predating Java 1.5, use either autoboxing
or the valueOf() method when creating instances of Double and Float.
> - XmlRpcTests.java:41, MS_PKGPROTECT
> MS: org.apache.ofbiz.service.test.XmlRpcTests.url should be package protected
> A mutable static field could be changed by malicious code or by accident. The field could
be made package protected to avoid this vulnerability.
> ST: Write to static field org.apache.ofbiz.service.test.XmlRpcTests.url from instance
method new org.apache.ofbiz.service.test.XmlRpcTests(String)
> This instance method writes to a static field. This is tricky to get correct if multiple
instances are being manipulated, and generally bad practice.

This message was sent by Atlassian JIRA

View raw message