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 a3a53b5 Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
a3a53b5 is described below
commit a3a53b5b72397265ae4b9b37488d9175bcf3ef8b
Author: Jacques Le Roux <[email protected]>
AuthorDate: Mon Nov 29 14:20:07 2021 +0100
Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
Fixes possible null dereferencings in PackingSession.java and
FormRenderer.java
Also a try with resource for FormRenderer because the EntityListIterator
was not
closed.
Also removes not used setShipmentBoxTypeId method and shipmentBoxTypeId var
in
PackingSession.java
---
.../ofbiz/shipment/packing/PackingSession.java | 14 +++----------
.../apache/ofbiz/widget/renderer/FormRenderer.java | 24 ++++++++++++++--------
2 files changed, 18 insertions(+), 20 deletions(-)
diff --git
a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java
b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java
index ba937e9..a7366ce 100644
---
a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java
+++
b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java
@@ -63,7 +63,6 @@ public class PackingSession implements java.io.Serializable {
private String shipmentId = null;
private String instructions = null;
private String weightUomId = null;
- private String shipmentBoxTypeId = null;
private BigDecimal additionalShippingCharge = null;
private Map<Integer, BigDecimal> packageWeights = null;
private List<PackingEvent> packEvents = null;
@@ -1219,8 +1218,9 @@ public class PackingSession implements
java.io.Serializable {
Delegator delegator = this.getDelegator();
if (picklistBinId != null) {
GenericValue picklist =
EntityQuery.use(delegator).from("PicklistAndBin").where("picklistBinId",
picklistBinId).queryFirst();
- if (picklist == null) {
- if (!"PICKLIST_PICKED".equals(picklist.getString("statusId"))
&& !"PICKLIST_COMPLETED".equals(picklist.getString("statusId"))
+ if (picklist != null) {
+ if (!"PICKLIST_PICKED".equals(picklist.getString("statusId"))
+ &&
!"PICKLIST_COMPLETED".equals(picklist.getString("statusId"))
&&
!"PICKLIST_CANCELLED".equals(picklist.getString("statusId"))) {
Map<String, Object> serviceResult =
this.getDispatcher().runSync("updatePicklist", UtilMisc.toMap("picklistId",
picklist.getString("picklistId"), "statusId",
"PICKLIST_PICKED", "userLogin", userLogin));
@@ -1425,14 +1425,6 @@ public class PackingSession implements
java.io.Serializable {
}
/**
- * Sets shipment box type id.
- * @param shipmentBoxTypeId the shipment box type id
- */
- public void setShipmentBoxTypeId(String shipmentBoxTypeId) {
- this.shipmentBoxTypeId = shipmentBoxTypeId;
- }
-
- /**
* Gets package seq ids.
* @return the package seq ids
*/
diff --git
a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java
b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java
index 937ca85..eaf2615 100644
---
a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java
+++
b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java
@@ -1087,10 +1087,15 @@ public class FormRenderer {
}
}
- FieldInfo fieldInfo = currentFormField.getFieldInfo();
- if (fieldInfo.getFieldType() == FieldInfo.HIDDEN
- || fieldInfo.getFieldType() == FieldInfo.IGNORED) {
- continue;
+ FieldInfo fieldInfo = null;
+ if (currentFormField != null) {
+ fieldInfo = currentFormField.getFieldInfo();
+ }
+ if (fieldInfo != null) {
+ if (fieldInfo.getFieldType() == FieldInfo.HIDDEN
+ || fieldInfo.getFieldType() == FieldInfo.IGNORED) {
+ continue;
+ }
}
if (alreadyRendered.contains(currentFormField.getName())) {
continue;
@@ -1227,8 +1232,7 @@ public class FormRenderer {
}
int itemIndex = -1;
if (iter instanceof EntityListIterator) {
- EntityListIterator eli = (EntityListIterator) iter;
- try {
+ try (EntityListIterator eli = (EntityListIterator) iter) {
if (eli.getResultsSizeAfterPartialList() > 0) {
itemIndex++;
}
@@ -1236,9 +1240,11 @@ public class FormRenderer {
Debug.logError(gee, MODULE);
}
} else {
- while (iter.hasNext()) {
- itemIndex++;
- break;
+ if (iter != null) {
+ while (iter.hasNext()) {
+ itemIndex++;
+ break;
+ }
}
}
if (itemIndex < 0) {