From d5e3c2d3d42444be9b4f28b73449d7741cff309b Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sun, 21 Apr 2019 09:37:49 +0000 Subject: [PATCH] Improved: Remove redundant null checks (OFBIZ-10911) Redundant null checks detected by Eclipse has been removed. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857896 13f79535-47bb-0310-9956-ffa450edef68 --- .../payment/PaymentMethodServices.java | 16 +- .../content/ContentManagementEvents.java | 1 - .../content/ContentManagementServices.java | 6 +- .../ofbiz/content/content/ContentWorker.java | 2 +- .../ofbiz/manufacturing/bom/BOMNode.java | 8 +- .../ofbiz/manufacturing/bom/BOMServices.java | 6 +- .../ofbiz/order/order/OrderServices.java | 12 +- .../order/shoppingcart/CheckOutEvents.java | 26 ++- .../order/shoppingcart/ShoppingCart.java | 2 +- .../shoppinglist/ShoppingListEvents.java | 4 +- .../shoppinglist/ShoppingListServices.java | 2 +- .../party/contact/ContactMechServices.java | 13 +- .../product/category/CategoryServices.java | 2 +- .../ofbiz/product/category/SeoConfigUtil.java | 11 - .../product/config/ProductConfigWorker.java | 3 +- .../ofbiz/product/product/ProductEvents.java | 4 +- .../shipment/thirdparty/ups/UpsServices.java | 2 +- .../apache/ofbiz/base/util/ScriptUtil.java | 4 +- .../org/apache/ofbiz/base/util/UtilURL.java | 1 - .../base/util/template/FreeMarkerWorker.java | 4 +- .../common/email/NotificationServices.java | 1 - .../ofbiz/common/qrcode/QRCodeServices.java | 4 +- .../org/apache/ofbiz/datafile/Record.java | 2 - .../apache/ofbiz/entity/GenericDelegator.java | 2 +- .../ofbiz/entity/jdbc/DatabaseUtil.java | 210 +++++++++--------- .../ofbiz/minilang/SimpleMapProcessor.java | 6 +- .../ofbiz/minilang/method/envops/Iterate.java | 3 +- .../ofbiz/webapp/event/SOAPEventHandler.java | 4 +- .../ofbiz/webtools/WebToolsServices.java | 2 +- .../apache/ofbiz/widget/model/ModelTree.java | 4 +- 30 files changed, 163 insertions(+), 204 deletions(-) diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java index 92c0bca4b8..36116eea79 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java @@ -212,8 +212,7 @@ public class PaymentMethodServices { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; - GenericValue tempVal = null; - + GenericValue tempVal; try { List allPCWPs = EntityQuery.use(delegator).from("PartyContactWithPurpose") .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList(); @@ -393,8 +392,7 @@ public class PaymentMethodServices { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; - GenericValue tempVal = null; - + GenericValue tempVal; try { List allPCWPs = EntityQuery.use(delegator).from("PartyContactWithPurpose") .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList(); @@ -740,7 +738,7 @@ public class PaymentMethodServices { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; - GenericValue tempVal = null; + GenericValue tempVal; try { List allPCWPs = EntityQuery.use(delegator).from("PartyContactWithPurpose") .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList(); @@ -871,8 +869,7 @@ public class PaymentMethodServices { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; - GenericValue tempVal = null; - + GenericValue tempVal; try { List allPCWPs = EntityQuery.use(delegator).from("PartyContactWithPurpose") .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList(); @@ -976,7 +973,7 @@ public class PaymentMethodServices { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; - GenericValue tempVal = null; + GenericValue tempVal; try { List allPCWPs = EntityQuery.use(delegator).from("PartyContactWithPurpose") .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList(); @@ -1098,8 +1095,7 @@ public class PaymentMethodServices { // add a PartyContactMechPurpose of BILLING_LOCATION if necessary String contactMechPurposeTypeId = "BILLING_LOCATION"; - GenericValue tempVal = null; - + GenericValue tempVal; try { List allPCWPs = EntityQuery.use(delegator).from("PartyContactWithPurpose") .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java index 364f36da02..d44abe756d 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java @@ -222,7 +222,6 @@ public class ContentManagementEvents { Timestamp origFromDate = null; for (Object [] pubArr : origSubList) { Timestamp fromDate = (Timestamp)pubArr[2]; - origSubContentId = null; if (fromDate != null) { origSubContentId = (String)pubArr[0]; origFromDate = fromDate; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java index ea80433d27..af652b0cc3 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java @@ -163,10 +163,8 @@ public class ContentManagementServices { List tmpPurposes = StringUtil.split(contentPurposeString, "|"); contentPurposeList.addAll(tmpPurposes); } - if (contentPurposeList != null) { - context.put("contentPurposeList", contentPurposeList); - context.put("contentPurposeString", null); - } + context.put("contentPurposeList", contentPurposeList); + context.put("contentPurposeString", null); if (Debug.infoOn()) { Debug.logInfo("in persist... contentPurposeList(0):" + contentPurposeList, module); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java index e69f79a9b3..51e95b2d87 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java @@ -195,7 +195,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor custMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", content.get("customMethodId")).cache().queryOne(); } if (custMethod != null) serviceName = custMethod.getString("customMethodName"); - if (dispatcher != null && UtilValidate.isNotEmpty(serviceName)) { + if (UtilValidate.isNotEmpty(serviceName)) { DispatchContext dctx = dispatcher.getDispatchContext(); ModelService service = dctx.getModelService(serviceName); if (service != null) { diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java index aaeabb93ef..06ab069e85 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java @@ -350,11 +350,9 @@ public class BOMNode { oneChildNode = new BOMNode(oneChild.getString("productId"), delegator, dispatcher, userLogin); // Configurator // If the node is null this means that the node has been discarded by the rules. - if (oneChildNode != null) { - oneChildNode.setParentNode(this); - oneChildNode.setTree(tree); - oneChildNode.loadParents(partBomTypeId, inDate, productFeatures); - } + oneChildNode.setParentNode(this); + oneChildNode.setTree(tree); + oneChildNode.loadParents(partBomTypeId, inDate, productFeatures); childrenNodes.add(oneChildNode); } } diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java index 803ac80ce7..7290ba24fc 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java @@ -319,16 +319,16 @@ public class BOMServices { fromDate = new Date(); } - BOMTree tree = null; + BOMTree tree; try { tree = new BOMTree(productId, bomType, fromDate, type, delegator, dispatcher, userLogin); } catch (GenericEntityException gee) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingBomErrorCreatingBillOfMaterialsTree", UtilMisc.toMap("errorString", gee.getMessage()), locale)); } - if (tree != null && quantity != null) { + if (quantity != null) { tree.setRootQuantity(quantity); } - if (tree != null && amount != null) { + if (amount != null) { tree.setRootAmount(amount); } result.put("tree", tree); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java index c89b8f94fc..a5841ce4ab 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java @@ -1253,9 +1253,7 @@ public class OrderServices { Map reserveResult = dispatcher.runSync("reserveStoreInventory", reserveInput); if (ServiceUtil.isError(reserveResult)) { String invErrMsg = "The product "; - if (product != null) { - invErrMsg += getProductName(product, orderItem); - } + invErrMsg += getProductName(product, orderItem); invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try reducing the quantity or removing the product from this order."; resErrorMessages.add(invErrMsg); } @@ -5984,10 +5982,8 @@ public class OrderServices { if (rowNumber == null) { Long count = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryCount(); - if (count != null) { - rowNumber = count.intValue(); - result.put("rowNumber", rowNumber); - } + rowNumber = count.intValue(); + result.put("rowNumber", rowNumber); } //find OISG Assoc @@ -6099,7 +6095,7 @@ public class OrderServices { result.put("totalQuantity", totalQuantity); //Only for multi service calling and the last row : test if orderItem quantity equals OrderItemShipGroupAssocs quantitys - if (rowCount != null && rowNumber != null ) { + if (rowCount != null) { int rowCountInt = rowCount; int rowNumberInt = rowNumber; if (rowCountInt == rowNumberInt - 1) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java index 1dd37e83d5..ee87527c08 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -435,18 +435,20 @@ public class CheckOutEvents { public static String checkoutValidation(HttpServletRequest request, HttpServletResponse response) { ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("shoppingCart"); if (cart.isSalesOrder()) { - List paymentMethodTypes = cart.getPaymentMethodTypes(); - if (UtilValidate.isEmpty(paymentMethodTypes)) { - String errMsg = UtilProperties.getMessage(resource_error, "OrderNoPaymentMethodTypeSelected", (cart != null ? cart.getLocale() : UtilHttp.getLocale(request))); - request.setAttribute("_ERROR_MESSAGE_",errMsg); - return "error"; - } - String shipmentMethod = cart.getShipmentMethodTypeId(); - if (UtilValidate.isEmpty(shipmentMethod)) { - String errMsg = UtilProperties.getMessage(resource_error, "OrderNoShipmentMethodSelected", (cart != null ? cart.getLocale() : UtilHttp.getLocale(request))); - request.setAttribute("_ERROR_MESSAGE_",errMsg); - return "error"; - } + List paymentMethodTypes = cart.getPaymentMethodTypes(); + if (UtilValidate.isEmpty(paymentMethodTypes)) { + String errMsg = UtilProperties.getMessage(resource_error, "OrderNoPaymentMethodTypeSelected", + cart.getLocale()); + request.setAttribute("_ERROR_MESSAGE_",errMsg); + return "error"; + } + String shipmentMethod = cart.getShipmentMethodTypeId(); + if (UtilValidate.isEmpty(shipmentMethod)) { + String errMsg = UtilProperties.getMessage(resource_error, "OrderNoShipmentMethodSelected", + cart.getLocale()); + request.setAttribute("_ERROR_MESSAGE_",errMsg); + return "error"; + } } return "success"; } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java index afb5e67463..076f1ac7a8 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java @@ -4708,7 +4708,7 @@ public class ShoppingCart implements Iterable, Serializable { Delegator delegator = cart.delegator; //check information from the cart ship info try { - if (originAddress == null && facilityId != null) { + if (facilityId != null) { originAddress = ShippingEvents.getShippingOriginContactMechFromFacility(delegator, facilityId); } if (originAddress == null && supplierPartyId != null) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java index e320b5caeb..1724c1ff03 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java @@ -474,7 +474,7 @@ public class ShoppingListEvents { Debug.logError(e, module); } cart.setAutoSaveListId(autoSaveListId); - } else if (userLogin != null) { + } else { String existingAutoSaveListId = null; try { existingAutoSaveListId = getAutoSaveListId(delegator, dispatcher, null, userLogin, cart.getProductStoreId()); @@ -522,7 +522,7 @@ public class ShoppingListEvents { if (okayToLoad) { String prodCatalogId = CatalogWorker.getCurrentCatalogId(request); try { - addListToCart(delegator, dispatcher, cart, prodCatalogId, autoSaveListId, false, false, userLogin != null ? true : false); + addListToCart(delegator, dispatcher, cart, prodCatalogId, autoSaveListId, false, false, true); cart.setLastListRestore(UtilDateTime.nowTimestamp()); } catch (IllegalArgumentException e) { Debug.logError(e, module); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java index 95dbc70b6f..502f9b5c37 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java @@ -171,7 +171,7 @@ public class ShoppingListServices { // store the order Map createResp = helper.createOrder(userLogin); - if (createResp == null || (createResp != null && ServiceUtil.isError(createResp))) { + if (createResp == null || ServiceUtil.isError(createResp)) { Debug.logError("Cannot create order for shopping list - " + shoppingList, module); } else { diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java index cf4cb5045f..a37bdb6686 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java @@ -157,7 +157,7 @@ public class ContactMechServices { } String contactMechId = (String) context.get("contactMechId"); - GenericValue contactMech = null; + GenericValue contactMech; GenericValue partyContactMech = null; try { @@ -427,7 +427,7 @@ public class ContactMechServices { } String contactMechId = (String) context.get("contactMechId"); - GenericValue contactMech = null; + GenericValue contactMech; GenericValue partyContactMech = null; try { @@ -469,8 +469,7 @@ public class ContactMechServices { GenericValue relatedEntityToSet = null; if ("POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) { - GenericValue addr = null; - + GenericValue addr; try { addr = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", contactMechId).queryOne(); } catch (GenericEntityException e) { @@ -669,7 +668,6 @@ public class ContactMechServices { } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); contactMech = null; - partyContactMech = null; } if (contactMech == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -687,8 +685,7 @@ public class ContactMechServices { GenericValue relatedEntityToSet = null; if ("TELECOM_NUMBER".equals(contactMech.getString("contactMechTypeId"))) { - GenericValue telNum = null; - + GenericValue telNum; try { telNum = EntityQuery.use(delegator).from("TelecomNumber").where("contactMechId", contactMechId).queryOne(); } catch (GenericEntityException e) { @@ -834,7 +831,7 @@ public class ContactMechServices { String contactMechPurposeTypeId = (String) context.get("contactMechPurposeTypeId"); Timestamp fromDate = (Timestamp) context.get("fromDate"); - GenericValue tempVal = null; + GenericValue tempVal; try { tempVal = EntityQuery.use(delegator).from("PartyContactWithPurpose") .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId) diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java index e1e23d2667..aa26938c2b 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java @@ -249,7 +249,7 @@ public class CategoryServices { Debug.logError(e.getMessage(), module); } - GenericValue productCategory = null; + GenericValue productCategory; try { productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne(); } catch (GenericEntityException e) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java index 2238e04c31..873a0e1566 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoConfigUtil.java @@ -18,7 +18,6 @@ *******************************************************************************/ package org.apache.ofbiz.product.category; -import java.io.FileInputStream; import java.io.IOException; import java.net.URL; import java.util.HashMap; @@ -101,7 +100,6 @@ public final class SeoConfigUtil { * Initialize url regular express configuration. */ public static void init() { - FileInputStream configFileIS = null; String result = "success"; seoPatterns = new HashMap(); seoReplacements = new HashMap(); @@ -322,15 +320,6 @@ public final class SeoConfigUtil { } catch (IOException e) { result = "error"; Debug.logError(e, module); - } finally { - if (configFileIS != null) { - try { - configFileIS.close(); - } catch (IOException e) { - result = "error"; - Debug.logError(e, module); - } - } } if (seoReplacements.keySet().isEmpty()) { useUrlRegexp = false; diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java index ea5c169466..e10b974af1 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java @@ -79,10 +79,9 @@ public final class ProductConfigWorker { } else { configWrapper = new ProductConfigWrapper(configWrapper); } - } catch (ProductConfigWrapperException we) { - configWrapper = null; } catch (Exception e) { Debug.logWarning(e.getMessage(), module); + configWrapper = null; } return configWrapper; } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java index f9fdcd7426..d683c7ce58 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java @@ -281,7 +281,6 @@ public class ProductEvents { productAssoc = EntityQuery.use(delegator).from(tempProductAssoc.getEntityName()).where(tempProductAssoc.getPrimaryKey()).queryOne(); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); - productAssoc = null; } if (productAssoc == null) { errMsg = UtilProperties.getMessage(resource,"productevents.could_not_remove_product_association_exist", UtilHttp.getLocale(request)); @@ -348,8 +347,7 @@ public class ProductEvents { request.setAttribute("ProductAssocCreateFromDate", fromDate); } - GenericValue productAssoc = null; - + GenericValue productAssoc; try { productAssoc = EntityQuery.use(delegator).from(tempProductAssoc.getEntityName()).where(tempProductAssoc.getPrimaryKey()).queryOne(); } catch (GenericEntityException e) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java index 7be8c1eb7e..1a7c10068f 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java @@ -517,7 +517,7 @@ public class UpsServices { UtilXml.addChildElementValue(dimensionsElement, "Length", UtilValidate.isNotEmpty(boxLength) ? ""+boxLength.intValue() : "", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(dimensionsElement, "Width", UtilValidate.isNotEmpty(boxWidth) ? ""+boxWidth.intValue() : "", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(dimensionsElement, "Height", UtilValidate.isNotEmpty(boxHeight) ? ""+boxHeight.intValue() : "", shipmentConfirmRequestDoc); - } else if (shipmentPackage != null && UtilValidate.isNotEmpty(shipmentPackage.getBigDecimal("boxLength")) + } else if (UtilValidate.isNotEmpty(shipmentPackage.getBigDecimal("boxLength")) && UtilValidate.isNotEmpty(shipmentPackage.getBigDecimal("boxWidth")) && UtilValidate.isNotEmpty(shipmentPackage.getBigDecimal("boxHeight"))) { Element dimensionsElement = UtilXml.addChildElement(packageElement, "Dimensions", shipmentConfirmRequestDoc); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java index 5d3b347b63..8a83015a48 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java @@ -197,9 +197,7 @@ public final class ScriptUtil { localContext.put("context", context); ScriptContext scriptContext = new SimpleScriptContext(); ScriptHelper helper = new ScriptHelperImpl(scriptContext); - if (helper != null) { - localContext.put(SCRIPT_HELPER_KEY, helper); - } + localContext.put(SCRIPT_HELPER_KEY, helper); Bindings bindings = new SimpleBindings(localContext); scriptContext.setBindings(bindings, ScriptContext.ENGINE_SCOPE); return scriptContext; diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java index f938dc3951..3559a70500 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java @@ -136,7 +136,6 @@ public final class UtilURL { } } catch (java.net.MalformedURLException e) { Debug.logError(e, "unable to retrieve URL for file: " + filename, module); - url = null; } return url; } diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java index 3c7abbe2b4..00a9a3758c 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java @@ -341,7 +341,7 @@ public final class FreeMarkerWorker { @SuppressWarnings("unchecked") public static T unwrap(Object o) { - Object returnObj = null; + Object returnObj; if (o == TemplateModel.NOTHING) { returnObj = null; @@ -349,6 +349,8 @@ public final class FreeMarkerWorker { returnObj = o.toString(); } else if (o instanceof BeanModel) { returnObj = ((BeanModel) o).getWrappedObject(); + } else { + returnObj = null; } return (T) returnObj; diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java index 725d24d29f..ba2a276ca9 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/email/NotificationServices.java @@ -139,7 +139,6 @@ public class NotificationServices { } else { // otherwise just report the error Debug.logError("prepareNotification failed: " + bodyResult.get(ModelService.ERROR_MESSAGE), module); - body = null; } } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java index ed04e353b9..39f727d426 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/qrcode/QRCodeServices.java @@ -139,9 +139,7 @@ public class QRCodeServices { if (UtilValidate.isEmpty(defaultLogoImage)) { Debug.logError("Your logo image file(" + qrCodeDefaultLogoImage + ") cannot be read by javax.imageio.ImageIO. Please use png, jpeg formats instead of ico and etc.", module); } - } catch (IllegalArgumentException e) { - defaultLogoImage = null; - } catch (IOException e) { + } catch (IllegalArgumentException | IOException e) { defaultLogoImage = null; } } diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java index 019ab26aff..ed26b2a5a9 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java @@ -573,8 +573,6 @@ public class Record implements Serializable { catch (NoSuchElementException nsee) { throw new DataFileException("Field " + modelField.name + " could not be read from a line (" + lineNum + ") with only " + line.length() + " chars.", nsee); } - } else { //if input line is less than the header model then pad with null - strVal = null; } } try { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java index 801924e8d8..603f43f85c 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java @@ -1271,7 +1271,7 @@ public class GenericDelegator implements Delegator { if (!primaryKey.isPrimaryKey()) { throw new GenericModelException("[GenericDelegator.storeAll] One of the passed primary keys is not a valid primary key: " + primaryKey); } - GenericValue existing = null; + GenericValue existing; try { existing = helper.findByPrimaryKey(primaryKey); } catch (GenericEntityNotFoundException e) { diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java index e2201e5ca1..8d1fc7f470 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java @@ -252,38 +252,37 @@ public class DatabaseUtil { if (tableNames.contains(tableName)) { tableNames.remove(tableName); - if (colInfo != null) { - Map fieldColNames = new HashMap(); - Iterator fieldIter = entity.getFieldsIterator(); - while (fieldIter.hasNext()) { - ModelField field = fieldIter.next(); - fieldColNames.put(field.getColName(), field); - } + Map fieldColNames = new HashMap(); + Iterator fieldIter = entity.getFieldsIterator(); + while (fieldIter.hasNext()) { + ModelField field = fieldIter.next(); + fieldColNames.put(field.getColName(), field); + } - Map colMap = colInfo.get(tableName); - if (colMap != null) { - for (ColumnCheckInfo ccInfo: colMap.values()) { - // -list all columns that do not have a corresponding field - if (fieldColNames.containsKey(ccInfo.columnName)) { - ModelField field = null; + Map colMap = colInfo.get(tableName); + if (colMap != null) { + for (ColumnCheckInfo ccInfo: colMap.values()) { + // -list all columns that do not have a corresponding field + if (fieldColNames.containsKey(ccInfo.columnName)) { + ModelField field = null; - field = fieldColNames.remove(ccInfo.columnName); - ModelFieldType modelFieldType = modelFieldTypeReader.getModelFieldType(field.getType()); + field = fieldColNames.remove(ccInfo.columnName); + ModelFieldType modelFieldType = modelFieldTypeReader.getModelFieldType(field.getType()); - if (modelFieldType != null) { - // make sure each corresponding column is of the correct type - String fullTypeStr = modelFieldType.getSqlType(); - String typeName; - int columnSize = -1; - int decimalDigits = -1; + if (modelFieldType != null) { + // make sure each corresponding column is of the correct type + String fullTypeStr = modelFieldType.getSqlType(); + String typeName; + int columnSize = -1; + int decimalDigits = -1; - int openParen = fullTypeStr.indexOf('('); - int closeParen = fullTypeStr.indexOf(')'); - int comma = fullTypeStr.indexOf(','); + int openParen = fullTypeStr.indexOf('('); + int closeParen = fullTypeStr.indexOf(')'); + int comma = fullTypeStr.indexOf(','); - if (openParen > 0 && closeParen > 0 && closeParen > openParen) { - typeName = fullTypeStr.substring(0, openParen); - if (!("DATETIME".equals(typeName) || "TIME".equals(typeName))) { // for DATETIME and TIME fields the number within the parenthesis doesn't represent the column size + if (openParen > 0 && closeParen > 0 && closeParen > openParen) { + typeName = fullTypeStr.substring(0, openParen); + if (!("DATETIME".equals(typeName) || "TIME".equals(typeName))) { // for DATETIME and TIME fields the number within the parenthesis doesn't represent the column size if (comma > 0 && comma > openParen && comma < closeParen) { String csStr = fullTypeStr.substring(openParen + 1, comma); try { @@ -306,97 +305,96 @@ public class DatabaseUtil { Debug.logError(e, module); } } - } - } else { - typeName = fullTypeStr; - } - - // override the default typeName with the sqlTypeAlias if it is specified - if (UtilValidate.isNotEmpty(modelFieldType.getSqlTypeAlias())) { - typeName = modelFieldType.getSqlTypeAlias(); - } - - // NOTE: this may need a toUpperCase in some cases, keep an eye on it, okay just compare with ignore case - if (!ccInfo.typeName.equalsIgnoreCase(typeName)) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] is of type [" + ccInfo.typeName + "] in the database, but is defined as type [" + - typeName + "] in the entity definition."; - Debug.logError(message, module); - if (messages != null) messages.add(message); - } - if (columnSize != -1 && ccInfo.columnSize != -1 && columnSize != ccInfo.columnSize && (columnSize * 3) != ccInfo.columnSize) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] has a column size of [" + ccInfo.columnSize + - "] in the database, but is defined to have a column size of [" + columnSize + "] in the entity definition."; - Debug.logWarning(message, module); - if (messages != null) messages.add(message); - if (columnSize > ccInfo.columnSize && colWrongSize != null) { - // add item to list of wrong sized columns; only if the entity is larger - colWrongSize.add(entity.getEntityName() + "." + field.getName()); - } - } - if (decimalDigits != -1 && decimalDigits != ccInfo.decimalDigits) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] has a decimalDigits of [" + ccInfo.decimalDigits + - "] in the database, but is defined to have a decimalDigits of [" + decimalDigits + "] in the entity definition."; - Debug.logWarning(message, module); - if (messages != null) messages.add(message); - } - - // do primary key matching check - if (checkPks && ccInfo.isPk && !field.getIsPk()) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] IS a primary key in the database, but IS NOT a primary key in the entity definition. The primary key for this table needs to be re-created or modified so that this column is NOT part of the primary key."; - Debug.logError(message, module); - if (messages != null) messages.add(message); - } - if (checkPks && !ccInfo.isPk && field.getIsPk()) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] IS NOT a primary key in the database, but IS a primary key in the entity definition. The primary key for this table needs to be re-created or modified to add this column to the primary key. Note that data may need to be added first as a primary key column cannot have an null values."; - Debug.logError(message, module); - if (messages != null) messages.add(message); } } else { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + entity.getEntityName() + - "] has a field type name of [" + field.getType() + "] which is not found in the field type definitions"; + typeName = fullTypeStr; + } + + // override the default typeName with the sqlTypeAlias if it is specified + if (UtilValidate.isNotEmpty(modelFieldType.getSqlTypeAlias())) { + typeName = modelFieldType.getSqlTypeAlias(); + } + + // NOTE: this may need a toUpperCase in some cases, keep an eye on it, okay just compare with ignore case + if (!ccInfo.typeName.equalsIgnoreCase(typeName)) { + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] is of type [" + ccInfo.typeName + "] in the database, but is defined as type [" + + typeName + "] in the entity definition."; + Debug.logError(message, module); + if (messages != null) messages.add(message); + } + if (columnSize != -1 && ccInfo.columnSize != -1 && columnSize != ccInfo.columnSize && (columnSize * 3) != ccInfo.columnSize) { + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] has a column size of [" + ccInfo.columnSize + + "] in the database, but is defined to have a column size of [" + columnSize + "] in the entity definition."; + Debug.logWarning(message, module); + if (messages != null) messages.add(message); + if (columnSize > ccInfo.columnSize && colWrongSize != null) { + // add item to list of wrong sized columns; only if the entity is larger + colWrongSize.add(entity.getEntityName() + "." + field.getName()); + } + } + if (decimalDigits != -1 && decimalDigits != ccInfo.decimalDigits) { + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] has a decimalDigits of [" + ccInfo.decimalDigits + + "] in the database, but is defined to have a decimalDigits of [" + decimalDigits + "] in the entity definition."; + Debug.logWarning(message, module); + if (messages != null) messages.add(message); + } + + // do primary key matching check + if (checkPks && ccInfo.isPk && !field.getIsPk()) { + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] IS a primary key in the database, but IS NOT a primary key in the entity definition. The primary key for this table needs to be re-created or modified so that this column is NOT part of the primary key."; + Debug.logError(message, module); + if (messages != null) messages.add(message); + } + if (checkPks && !ccInfo.isPk && field.getIsPk()) { + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] IS NOT a primary key in the database, but IS a primary key in the entity definition. The primary key for this table needs to be re-created or modified to add this column to the primary key. Note that data may need to be added first as a primary key column cannot have an null values."; Debug.logError(message, module); if (messages != null) messages.add(message); } } else { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + entity.getEntityName() + "] exists in the database but has no corresponding field" + ((checkPks && ccInfo.isPk) ? " (and it is a PRIMARY KEY COLUMN)" : ""); - Debug.logWarning(message, module); + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + entity.getEntityName() + + "] has a field type name of [" + field.getType() + "] which is not found in the field type definitions"; + Debug.logError(message, module); if (messages != null) messages.add(message); } - } - - // -display message if number of table columns does not match number of entity fields - if (colMap.size() != entity.getFieldsSize()) { - String message = "Entity [" + entity.getEntityName() + "] has " + entity.getFieldsSize() + " fields but table [" + tableName + "] has " + colMap.size() + " columns."; + } else { + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + entity.getEntityName() + "] exists in the database but has no corresponding field" + ((checkPks && ccInfo.isPk) ? " (and it is a PRIMARY KEY COLUMN)" : ""); Debug.logWarning(message, module); if (messages != null) messages.add(message); } } - // -list all fields that do not have a corresponding column - for (ModelField field : fieldColNames.values()) { - String message = "Field [" + field.getName() + "] of entity [" + entity.getEntityName() + "] is missing its corresponding column [" + field.getColName() + "]" + (field.getIsPk() ? " (and it is a PRIMARY KEY FIELD)" : ""); - + // -display message if number of table columns does not match number of entity fields + if (colMap.size() != entity.getFieldsSize()) { + String message = "Entity [" + entity.getEntityName() + "] has " + entity.getFieldsSize() + " fields but table [" + tableName + "] has " + colMap.size() + " columns."; Debug.logWarning(message, module); if (messages != null) messages.add(message); + } + } - if (addMissing) { - // add the column - String errMsg = addColumn(entity, field); + // -list all fields that do not have a corresponding column + for (ModelField field : fieldColNames.values()) { + String message = "Field [" + field.getName() + "] of entity [" + entity.getEntityName() + "] is missing its corresponding column [" + field.getColName() + "]" + (field.getIsPk() ? " (and it is a PRIMARY KEY FIELD)" : ""); - if (UtilValidate.isNotEmpty(errMsg)) { - message = "Could not add column [" + field.getColName() + "] to table [" + tableName + "]: " + errMsg; - Debug.logError(message, module); - if (messages != null) messages.add(message); - } else { - message = "Added column [" + field.getColName() + "] to table [" + tableName + "]" + (field.getIsPk() ? " (NOTE: this is a PRIMARY KEY FIELD, but the primary key was not updated automatically (not considered a safe operation), be sure to fill in any needed data and re-create the primary key)" : ""); - Debug.logImportant(message, module); - if (messages != null) messages.add(message); - } + Debug.logWarning(message, module); + if (messages != null) messages.add(message); + + if (addMissing) { + // add the column + String errMsg = addColumn(entity, field); + + if (UtilValidate.isNotEmpty(errMsg)) { + message = "Could not add column [" + field.getColName() + "] to table [" + tableName + "]: " + errMsg; + Debug.logError(message, module); + if (messages != null) messages.add(message); + } else { + message = "Added column [" + field.getColName() + "] to table [" + tableName + "]" + (field.getIsPk() ? " (NOTE: this is a PRIMARY KEY FIELD, but the primary key was not updated automatically (not considered a safe operation), be sure to fill in any needed data and re-create the primary key)" : ""); + Debug.logImportant(message, module); + if (messages != null) messages.add(message); } } } @@ -694,12 +692,10 @@ public class DatabaseUtil { } // show index key references that exist but are unknown - if (tableIndexList != null) { - for (String indexLeft: tableIndexList) { - String message = "Unknown Index " + indexLeft + " found in table " + entity.getTableName(datasourceInfo); - Debug.logImportant(message, module); - if (messages != null) messages.add(message); - } + for (String indexLeft: tableIndexList) { + String message = "Unknown Index " + indexLeft + " found in table " + entity.getTableName(datasourceInfo); + Debug.logImportant(message, module); + if (messages != null) messages.add(message); } } } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMapProcessor.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMapProcessor.java index 71b396991b..26f12dc1f3 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMapProcessor.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/SimpleMapProcessor.java @@ -101,8 +101,7 @@ public class SimpleMapProcessor { MapProcessor processor = mapProcessors.get(name); if (processor == null) { throw new MiniLangException("Could not find SimpleMapProcessor named " + name + " in XML document resource: " + xmlResource); - } - if (processor != null) { + } else { processor.exec(inMap, results, messages, locale, loader); } } @@ -114,8 +113,7 @@ public class SimpleMapProcessor { MapProcessor processor = mapProcessors.get(name); if (processor == null) { throw new MiniLangException("Could not find SimpleMapProcessor named " + name + " in XML document: " + xmlURL.toString()); - } - if (processor != null) { + } else { processor.exec(inMap, results, messages, locale, loader); } } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java index c62bffc85f..bc477a2f75 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java @@ -154,7 +154,8 @@ public final class Iterate extends MethodOperation { } } else { if (Debug.verboseOn()) { - Debug.logVerbose("Cannot iterate over a " + objList == null ? "null object" : objList.getClass().getName() + Debug.logVerbose("Cannot iterate over a " + + (objList == null ? "null object" : objList.getClass().getName()) + ", doing nothing: " + this, module); } return true; diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/SOAPEventHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/SOAPEventHandler.java index b70f2f9def..92a9ddf355 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/SOAPEventHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/SOAPEventHandler.java @@ -115,9 +115,7 @@ public class SOAPEventHandler implements EventHandler { sendError(response, "Unable to obtain WSDL", serviceName); throw new EventHandlerException("Unable to obtain WSDL"); } - } - - if (serviceName == null) { + } else { try (Writer writer = response.getWriter()) { StringBuilder sb = new StringBuilder(); sb.append("OFBiz SOAP/1.1 Services"); diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java index 9c845e5f8b..820b1d110a 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java @@ -234,7 +234,7 @@ public class WebToolsServices { } if (UtilValidate.isNotEmpty(path)) { - long pauseLong = filePause != null ? filePause : 0; + long pauseLong = filePause; File baseDir = new File(path); if (baseDir.isDirectory() && baseDir.canRead()) { diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java index a0510df7ff..0cf5ab8174 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java @@ -512,7 +512,7 @@ public class ModelTree extends ModelWidget { getChildren(context); nodeCount = (long) subNodeValues.size(); } - if (nodeCount != null && nodeCount.intValue() > 0) { + if (nodeCount.intValue() > 0) { hasChildren = true; } return hasChildren; @@ -639,7 +639,7 @@ public class ModelTree extends ModelWidget { showPeers = true; } else if (!isFollowTrail()) { showPeers = true; - } else if ((currentDepth < trailSize) && (rStyle != null) + } else if ((currentDepth < trailSize) && ("show-peers".equals(rStyle) || "expand-collapse".equals(rStyle))) { showPeers = true; } else if (openDepth >= currentDepth) {