Fixed: Fix Default or Empty Catch block in Java files
Removes swallowed exceptions, refactors
@@ -294,6 +294,7 @@ public class ShipmentServices {
List<GenericValue> estimateList = new LinkedList<GenericValue>();
for (GenericValue thisEstimate: estimates) {
+ try {
String toGeo = thisEstimate.getString("geoIdTo");
if (UtilValidate.isNotEmpty(toGeo) && shipAddress ==null) {
// This estimate requires shipping address details. We don't have it so we cannot use this estimate.
@@ -305,23 +306,9 @@ public class ShipmentServices {
GeoWorker.containsGeo(toGeoList, shipAddress.getString("countryGeoId"), delegator) ||
GeoWorker.containsGeo(toGeoList, shipAddress.getString("stateProvinceGeoId"), delegator) ||
GeoWorker.containsGeo(toGeoList, shipAddress.getString("postalCodeGeoId"), delegator)) {
-
- GenericValue wv = null;
- GenericValue qv = null;
- GenericValue pv = null;
-
- try {
- wv = thisEstimate.getRelatedOne("WeightQuantityBreak", false);
- } catch (GenericEntityException e) {
- }
- try {
- qv = thisEstimate.getRelatedOne("QuantityQuantityBreak", false);
- } catch (GenericEntityException e) {
- }
- try {
- pv = thisEstimate.getRelatedOne("PriceQuantityBreak", false);
- } catch (GenericEntityException e) {
- }
+ GenericValue wv = thisEstimate.getRelatedOne("WeightQuantityBreak", false);
+ GenericValue qv = thisEstimate.getRelatedOne("QuantityQuantityBreak", false);
+ GenericValue pv = thisEstimate.getRelatedOne("PriceQuantityBreak", false);
if (wv == null && qv == null && pv == null) {
estimateList.add(thisEstimate);
} else {
@@ -337,12 +324,8 @@ public class ShipmentServices {
useWeight = true;
BigDecimal min = BigDecimal.ONE.movePointLeft(4);
BigDecimal max = BigDecimal.ONE.movePointLeft(4);
-
- try {
min = wv.getBigDecimal("fromQuantity");
max = wv.getBigDecimal("thruQuantity");
- } catch (Exception e) {
- }
if (shippableWeight.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 || shippableWeight.compareTo(max) <= 0)) {
weightValid = true;
}
@@ -351,12 +334,8 @@ public class ShipmentServices {
useQty = true;
BigDecimal min = BigDecimal.ONE.movePointLeft(4);
BigDecimal max = BigDecimal.ONE.movePointLeft(4);
-
- try {
min = qv.getBigDecimal("fromQuantity");
max = qv.getBigDecimal("thruQuantity");
- } catch (Exception e) {
- }
if (shippableQuantity.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 || shippableQuantity.compareTo(max) <= 0)) {
qtyValid = true;
}
@@ -365,12 +344,8 @@ public class ShipmentServices {
usePrice = true;
BigDecimal min = BigDecimal.ONE.movePointLeft(4);
BigDecimal max = BigDecimal.ONE.movePointLeft(4);
-
- try {
min = pv.getBigDecimal("fromQuantity");
max = pv.getBigDecimal("thruQuantity");
- } catch (Exception e) {
- }
if (shippableTotal.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 || shippableTotal.compareTo(max) <= 0)) {
priceValid = true;
}
@@ -381,7 +356,9 @@ public class ShipmentServices {
}
}
}
-
+ } catch (GenericEntityException e) {
+ Debug.logError(e, e.getLocalizedMessage(), module);
+ }
}
if (estimateList.size() < 1) {
