svn commit: r1804824 - in /ofbiz/ofbiz-framework/trunk/framework: entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

svn commit: r1804824 - in /ofbiz/ofbiz-framework/trunk/framework: entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java

nmalin
Author: nmalin
Date: Fri Aug 11 17:02:34 2017
New Revision: 1804824

URL: http://svn.apache.org/viewvc?rev=1804824&view=rev
Log:
Fixed: Related to the issue OFBIZ-6401Connect OFBiz to a read only database
Escape null pointer exception stack trace when the helper return no value

Modified:
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java?rev=1804824&r1=1804823&r2=1804824&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java Fri Aug 11 17:02:34 2017
@@ -838,13 +838,14 @@ public class GenericDelegator implements
                     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
                     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
             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);

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java?rev=1804824&r1=1804823&r2=1804824&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/stats/VisitHandler.java Fri Aug 11 17:02:34 2017
@@ -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);


Loading...