Hi Scott,
What do you think about adding this check at the beginning of
ObjectType.isEmpty() something like
Index: framework/base/src/org/ofbiz/base/util/ObjectType.java
===================================================================
--- framework/base/src/org/ofbiz/base/util/ObjectType.java (revision 883647)
+++ framework/base/src/org/ofbiz/base/util/ObjectType.java (working copy)
@@ -754,7 +754,10 @@
}
public static boolean isEmpty(Object value) {
- if (value == null) return true;
+ if (value == null) {
+ Debug.logWarning("a warning", module);
+ return true;
+ }
Jacques
From: "Scott Gray" <[email protected]>
Thanks Jacques, it wasn't a compilation problem but a run-install problem, empty fields were being treated as empty strings
instead of null which was causing all sorts of fk problems during data load.
If you do work on UtilValidate it might be a good idea to log a warning whenever an object is passed in that we can only do a
null check on, it might help people avoid this sort of issue and help us identify any areas where the checks aren't doing what
we probably intended them to do.
Regards
Scott
On 24/11/2009, at 9:49 PM, Jacques Le Roux wrote:
Thanks Scott,
I did not notice build issues. I will double check possible CharSequence uses
or rather coonsider implementing
UtilValidate.is(Not)Empty for it (I can't see any reason to not do it at this
stage)
Jacques
From: <[email protected]>
Author: lektran
Date: Tue Nov 24 07:43:18 2009
New Revision: 883613
URL: http://svn.apache.org/viewvc?rev=883613&view=rev
Log:
Revert Jacques changes to EntitySaxReader.java from r883549 and 883507, the
UtilValidate.is(Not)Empty methods are not setup to
test CharSequence instances. Hopefully there aren't too many more out there.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/ EntitySaxReader.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/
EntitySaxReader.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java?rev=883613&r1=883612&r2=883613&view=diff
= = = = = = = = =
=====================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/
EntitySaxReader.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/
EntitySaxReader.java Tue Nov 24 07:43:18 2009
@@ -375,7 +375,7 @@
if (currentValue != null) {
if (currentFieldName != null) {
- if (UtilValidate.isNotEmpty(currentFieldValue)) {
+ if (currentFieldValue != null && currentFieldValue.length() >
0) {
if (currentValue
.getModelEntity().isField(currentFieldName.toString())) {
ModelEntity modelEntity = currentValue.getModelEntity();
ModelField modelField =
modelEntity.getField(currentFieldName.toString());
@@ -499,7 +499,7 @@
CharSequence name = attributes.getLocalName(i);
CharSequence value = attributes.getValue(i);
- if (UtilValidate.isEmpty(name)) {
+ if (name == null || name.length() == 0) {
name = attributes.getQName(i);
}
newElement.setAttribute(name.toString(), value.toString());
@@ -548,12 +548,12 @@
CharSequence name = attributes.getLocalName(i);
CharSequence value = attributes.getValue(i);
- if (UtilValidate.isEmpty(name)) {
+ if (name == null || name.length() == 0) {
name = attributes.getQName(i);
}
try {
// treat empty strings as nulls
- if (UtilValidate.isNotEmpty(value)) {
+ if (value != null && value.length() > 0) {
if
(currentValue.getModelEntity().isField(name.toString())) {
currentValue.setString(name.toString(),
value.toString());
} else {