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 0116fe870d..00db9105ed 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 @@ -838,13 +838,14 @@ public class GenericDelegator implements Delegator { ecaRunner.evalRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_CREATE, value, false); this.clearCacheLine(value); } + ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_CREATE, value, false); } - ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_CREATE, value, false); TransactionUtil.commit(beganTransaction); return value; } catch (Exception e) { - String errMsg = "Failure in createSetNextSeqId operation for entity [" + value.getEntityName() + "]: " + e.toString() + ". Rolling back transaction."; + String entityName = value != null ? value.getEntityName() : "invalid Generic Value"; + String errMsg = "Failure in createSetNextSeqId operation for entity [" + entityName + "]: " + e.toString() + ". Rolling back transaction."; Debug.logError(e, errMsg, module); TransactionUtil.rollback(beganTransaction, errMsg, e); throw new GenericEntityException(e); @@ -894,13 +895,13 @@ public class GenericDelegator implements Delegator { ecaRunner.evalRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_CREATE, value, false); this.clearCacheLine(value); } + ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_CREATE, value, false); } - ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_CREATE, value, false); TransactionUtil.commit(beganTransaction); return value; } catch (Exception e) { - String errMsg = "Failure in create operation for entity [" + (value != null ? value.getEntityName() : "null") + "]: " + e.toString() + ". Rolling back transaction."; + String errMsg = "Failure in create operation for entity [" + (value != null ? value.getEntityName() : "value is null") + "]: " + e.toString() + ". Rolling back transaction."; Debug.logError(errMsg, module); TransactionUtil.rollback(beganTransaction, errMsg, e); throw new GenericEntityException(e); @@ -930,7 +931,7 @@ public class GenericDelegator implements Delegator { TransactionUtil.commit(beganTransaction); return value; } catch (Exception e) { - String errMsg = "Failure in createOrStore operation for entity [" + value.getEntityName() + "]: " + e.toString() + ". Rolling back transaction."; + String errMsg = "Failure in createOrStore operation for entity [" + (value != null ? value.getEntityName() : "value is null") + "]: " + e.toString() + ". Rolling back transaction."; Debug.logError(e, errMsg, module); TransactionUtil.rollback(beganTransaction, errMsg, e); throw new GenericEntityException(e); diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java index 03411e90b2..93f4b5be43 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java @@ -254,7 +254,10 @@ public class VisitHandler { // looks like we have an ID that doesn't exist in our database, so we'll create a new one visitor = delegator.makeValue("Visitor"); visitor = delegator.createSetNextSeqId(visitor); - if (Debug.infoOn()) Debug.logInfo("The visitorId [" + cookieVisitorId + "] found in cookie was invalid, creating new Visitor with ID [" + visitor.getString("visitorId") + "]", module); + if (Debug.infoOn()) { + String visitorId = visitor != null ? visitor.getString("visitorId") : "empty visitor"; + Debug.logInfo("The visitorId [" + cookieVisitorId + "] found in cookie was invalid, creating new Visitor with ID [" + visitorId + "]", module); + } } } catch (GenericEntityException e) { Debug.logError(e, "Error finding visitor with ID from cookie: " + cookieVisitorId, module);