Author: adrianc
Date: Wed Dec 4 12:43:24 2013
New Revision: 1547790
URL:
http://svn.apache.org/r1547790Log:
Improved error message in GenericEntity.java - no functional change. The improved message should help developers solve the problem causing the exception.
This has been discussed before, but I will mention it again for instruction: GenericEntity instances that are kept in the entity cache are shared among multiple threads. Therefore, they must be immutable. If you get a GenericEntity instance from the cache and you want to modify it, you must clone it first.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=1547790&r1=1547789&r2=1547790&view=diff==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Wed Dec 4 12:43:24 2013
@@ -154,8 +154,10 @@ public class GenericEntity implements Ma
protected void assertIsMutable() {
if (!this.mutable) {
- Debug.logError(new IllegalStateException("This object has been flagged as immutable (unchangeable), probably because it came from an Entity Engine cache. Cannot modify an immutable entity object."), module);
- throw new IllegalStateException("This object has been flagged as immutable (unchangeable), probably because it came from an Entity Engine cache. Cannot modify an immutable entity object.");
+ String msg = "This object has been flagged as immutable (unchangeable), probably because it came from an Entity Engine cache. Cannot modify an immutable entity object. Use the clone method to create a mutable copy of this object.";
+ IllegalStateException toBeThrown = new IllegalStateException(msg);
+ Debug.logError(toBeThrown, module);
+ throw toBeThrown;
}
}