This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 82c5a57  Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
82c5a57 is described below

commit 82c5a574fb47ffe7fbda0c8c0e1b913bed8fe7b7
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Sun Dec 26 15:26:33 2021 +0100

    Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
    
    I wrote in previous commit:
    "uses <<private static final SecureRandom SECURE_RANDOM = new 
SecureRandom();>>
    in classes:
    PaymentGatewayServices
    ValueLinkApi
    ContactMechServices
    ProductStoreWorker
    DesCrypt
    HashCrypt
    EntityCrypto
    ContextFilter.java
    Despite doing so SpotButs still reports the same error for those classes.
    As it's obviously an error I prefer to not excludes those cases that will 
maybe
    not be reported in a future version of SpotButs in Eclipse. For instance 
they
    are not reported at all in previous version (4.5.1) but are in 4.5.2"
    
    Actually it turn out to be that I needed to remove the SpotBugs markers.
    SpotBugs is mischievous. Sometimes just when fixing a report in a file it
    automatically updates the tree of reports, most of the time not. Sometimes 
you
    don't need to remove the SpotBugs markers. Just running again clears the 
tree of
    reports.
    
    Anyway I was inspired to not exclude the reported cases for the classes 
above.
    They no longer appear, but a new one popped up (or I missed it previously 
but
    I doubt) in SampleHtmlThread::run.
    
    This fixes it and it no longer appears when just running SpotBugs again,
    go figure...
---
 .../main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java 
b/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java
index 774deb9..867d12a 100644
--- 
a/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java
+++ 
b/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java
@@ -77,11 +77,10 @@ public class SampleHtmlThread extends AbstractReportThread {
                 getReport().println(UtilProperties.getMessage(RESOURCE, 
"COUNT_COMPLETED", getLocale()), InterfaceReport.FORMAT_HEADLINE);
             } else if (getName().startsWith(COUNT_UP)) {
                 getReport().println(UtilProperties.getMessage(RESOURCE, 
"START_COUNT_UP", getLocale()), InterfaceReport.FORMAT_HEADLINE);
-                SecureRandom random = new SecureRandom();
                 int j = 0;
                 for (int i = 1; i <= 1000; i++) {
                     sleep(20);
-                    j = random.nextInt(7);
+                    j = SECURE_RANDOM.nextInt(7);
                     if (j == 6) {
                         getReport().println(new 
Throwable(UtilProperties.getMessage(RESOURCE, MESSAGES.get(j), new Object[] 
{i}, getLocale())));
                     } else {

Reply via email to