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-framework.git


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

commit 5a64c3d27da31a7817310743e1842a3acb75d4b0
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Thu Dec 9 07:22:39 2021 +0100

    Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
    
    In exclude.xml:
    removes Confidence lines, no need to complicate things
    Adds 2 DC_DOUBLECHECK false reports; synchronized is used there (maybe not 
the
    best way but it's OK as is)
    
    In ProductConfigWrapper::equals fixes use of == instead of equals (tested)
    In UspsServices::uspsPriorityMailInternationalLabel fixes 2 possible null
    dereferencements
    
    In EntityExpr::checkRhsType fixes a possible null dereferencement
---
 .../apache/ofbiz/product/config/ProductConfigWrapper.java  |  2 +-
 .../ofbiz/shipment/thirdparty/usps/UspsServices.java       |  8 ++++++--
 .../java/org/apache/ofbiz/entity/condition/EntityExpr.java |  3 ++-
 spotbugs/exclude.xml                                       | 14 ++++++++++----
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git 
a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
 
b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
index 1832a2c..05c0c7b 100644
--- 
a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
+++ 
b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java
@@ -1093,7 +1093,7 @@ public class ProductConfigWrapper implements Serializable 
{
             if (this == o) return true;
             if (o == null || getClass() != o.getClass()) return false;
             ConfigOption that = (ConfigOption) o;
-            return that.getId() == getId()
+            return that.getId().equals(getId())
                     && that.isSelected() == isSelected()
                     && Objects.equals(availabilityDate, that.availabilityDate)
                     && Objects.equals(componentList, that.componentList)
diff --git 
a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java
 
b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java
index 2005570..2bcb5b2 100644
--- 
a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java
+++ 
b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java
@@ -1640,7 +1640,9 @@ public class UspsServices {
                     Debug.logInfo(e, MODULE);
                 }
 
-                UtilXml.addChildElementValue(itemDetail, "Description", 
product.getString("productName"), packageDocument);
+                if (product != null) {
+                    UtilXml.addChildElementValue(itemDetail, "Description", 
product.getString("productName"), packageDocument);
+                }
                 UtilXml.addChildElementValue(itemDetail, "Quantity", 
shipmentPackageContent.getBigDecimal("quantity")
                         .setScale(0, RoundingMode.CEILING).toPlainString(), 
packageDocument);
                 String packageContentValue = 
ShipmentWorker.getShipmentPackageContentValue(shipmentPackageContent).setScale(2,
@@ -1651,7 +1653,9 @@ public class UspsServices {
                 UtilXml.addChildElementValue(itemDetail, "NetPounds", 
productPoundsOunces[0].toString(), packageDocument);
                 UtilXml.addChildElementValue(itemDetail, "NetOunces", 
productPoundsOunces[1].toString(), packageDocument);
                 UtilXml.addChildElementValue(itemDetail, "HSTariffNumber", "", 
packageDocument);
-                UtilXml.addChildElementValue(itemDetail, "CountryOfOrigin", 
originGeo.getString("geoName"), packageDocument);
+                if (originGeo != null) {
+                    UtilXml.addChildElementValue(itemDetail, 
"CountryOfOrigin", originGeo.getString("geoName"), packageDocument);
+                }
             }
 
             // Send the request
diff --git 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java
 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java
index 9e87c5b..816f018 100644
--- 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java
+++ 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java
@@ -279,7 +279,8 @@ public final class EntityExpr implements EntityCondition {
                 Debug.logWarning(e, MODULE);
             }
             try {
-                if 
(!ObjectType.instanceOf(ObjectType.loadClass(rhsType.getJavaType()), 
type.getJavaType())) {
+                if (rhsType != null
+                        && 
!ObjectType.instanceOf(ObjectType.loadClass(rhsType.getJavaType()), 
type.getJavaType())) {
                     String msg = "Warning using [" + 
value.getClass().getName() + "]"
                             + " and entity field [" + 
modelEntity.getEntityName() + "." + curField.getName() + "]."
                             + " The Java type [" + rhsType.getJavaType() + "] 
of rhsFieldName : [" + rhsFieldName + "]"
diff --git a/spotbugs/exclude.xml b/spotbugs/exclude.xml
index 532c2b2..bc8821f 100644
--- a/spotbugs/exclude.xml
+++ b/spotbugs/exclude.xml
@@ -9,19 +9,25 @@
     <Class name="org.apache.ofbiz.entity.GenericEntity" />
     <Method name="clone" />
     <Bug pattern="CN_IDIOM_NO_SUPER_CALL" />
-    <Confidence value="1" />
   </Match>
   <Match>
     <Class name="org.apache.ofbiz.entity.GenericPK" />
     <Method name="clone" />
     <Bug pattern="CN_IDIOM_NO_SUPER_CALL" />
-    <Confidence value="1" />
   </Match>
   <Match>
     <Class name="org.apache.ofbiz.entity.GenericValue" />
     <Method name="clone" />
     <Bug pattern="CN_IDIOM_NO_SUPER_CALL" />
-    <Confidence value="1" />
   </Match>
-  
+  <Match>
+    <Class name="org.apache.ofbiz.webapp.view.ApacheFopWorker" />
+    <Method name="getFactoryInstance" />
+    <Bug pattern="DC_DOUBLECHECK" />
+  </Match>
+  <Match>
+    <Class 
name="org.apache.ofbiz.accounting.thirdparty.valuelink.ValueLinkApi" />
+    <Method name="getWorkingKeyIndex" />
+    <Bug pattern="DC_DOUBLECHECK" />
+  </Match>
 </FindBugsFilter>

Reply via email to