Improved: Always check if debug verbose is on when using Debug.logVerbose()

(OFBIZ-10052)

This completes the work done so far by removing double check in cases not using 
brackets, like
if (Debug.verboseOn())
  if (Debug.verboseOn()) Debug.logVerbose()

Thanks: Michael for reporting this case I missed.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1818445 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2017-12-16 19:00:19 +00:00
parent 1e9b5fea5c
commit d1bdee2c6c
18 changed files with 114 additions and 83 deletions
@@ -110,8 +110,9 @@ public final class CallSimpleMethod extends MethodOperation {
localContext = new MethodContext(localEnv, methodContext.getLoader(), methodContext.getMethodType());
}
String returnVal = simpleMethodToCall.exec(localContext);
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Called simple-method named [" + this.methodName + "] in resource [" + this.xmlResource + "], returnVal is [" + returnVal + "]", module);
if (Debug.verboseOn()) {
Debug.logVerbose("Called simple-method named [" + this.methodName + "] in resource [" + this.xmlResource + "], returnVal is [" + returnVal + "]", module);
}
if (simpleMethodToCall.getDefaultErrorCode().equals(returnVal)) {
if (methodContext.getMethodType() == MethodContext.EVENT) {
methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode());
@@ -68,8 +68,9 @@ public final class Iterate extends MethodOperation {
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
if (listFma.isEmpty()) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Collection not found, doing nothing: " + this, module);
if (Debug.verboseOn()) {
Debug.logVerbose("Collection not found, doing nothing: " + this, module);
}
return true;
}
Object oldEntryValue = entryFma.get(methodContext.getEnvMap());
@@ -101,8 +102,9 @@ public final class Iterate extends MethodOperation {
} else if (objList instanceof Collection<?>) {
Collection<Object> theCollection = UtilGenerics.checkCollection(objList);
if (theCollection.size() == 0) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Collection has zero entries, doing nothing: " + this, module);
if (Debug.verboseOn()) {
Debug.logVerbose("Collection has zero entries, doing nothing: " + this, module);
}
return true;
}
for (Object theEntry : theCollection) {
@@ -126,8 +128,9 @@ public final class Iterate extends MethodOperation {
} else if (objList instanceof Iterator<?>) {
Iterator<Object> theIterator = UtilGenerics.cast(objList);
if (!theIterator.hasNext()) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Iterator has zero entries, doing nothing: " + this, module);
if (Debug.verboseOn()) {
Debug.logVerbose("Iterator has zero entries, doing nothing: " + this, module);
}
return true;
}
while (theIterator.hasNext()) {
@@ -70,22 +70,26 @@ public final class IterateMap extends MethodOperation {
Object oldKey = keyFma.get(methodContext.getEnvMap());
Object oldValue = valueFma.get(methodContext.getEnvMap());
if (oldKey != null) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("In iterate-map the key had a non-null value before entering the loop for the operation: " + this, module);
if (Debug.verboseOn()) {
Debug.logVerbose("In iterate-map the key had a non-null value before entering the loop for the operation: " + this, module);
}
}
if (oldValue != null) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("In iterate-map the value had a non-null value before entering the loop for the operation: " + this, module);
if (Debug.verboseOn()) {
Debug.logVerbose("In iterate-map the value had a non-null value before entering the loop for the operation: " + this, module);
}
}
Map<? extends Object, ? extends Object> theMap = mapFma.get(methodContext.getEnvMap());
if (theMap == null) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Map not found with name " + mapFma + ", doing nothing: " + this, module);
if (Debug.verboseOn()) {
Debug.logVerbose("Map not found with name " + mapFma + ", doing nothing: " + this, module);
}
return true;
}
if (theMap.size() == 0) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Map with name " + mapFma + " has zero entries, doing nothing: " + this, module);
if (Debug.verboseOn()) {
Debug.logVerbose("Map with name " + mapFma + " has zero entries, doing nothing: " + this, module);
}
return true;
}
for (Map.Entry<? extends Object, ? extends Object> theEntry : theMap.entrySet()) {
@@ -144,8 +144,9 @@ public final class SetOperation extends MethodOperation {
}
} else if (!this.fromFma.isEmpty()) {
newValue = this.fromFma.get(methodContext.getEnvMap());
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("In screen getting value for field from [" + this.fromFma.toString() + "]: " + newValue, module);
if (Debug.verboseOn()) {
Debug.logVerbose("In screen getting value for field from [" + this.fromFma.toString() + "]: " + newValue, module);
}
} else if (!this.valueFse.isEmpty()) {
newValue = this.valueFse.expand(methodContext.getEnvMap());
isConstant = true;
@@ -156,13 +157,15 @@ public final class SetOperation extends MethodOperation {
isConstant = true;
}
if (!setIfNull && newValue == null && !"NewMap".equals(this.type) && !"NewList".equals(this.type)) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Field value not found (null) with name [" + fromFma + "] and value [" + valueFse + "], and there was not default value, not setting field", module);
if (Debug.verboseOn()) {
Debug.logVerbose("Field value not found (null) with name [" + fromFma + "] and value [" + valueFse + "], and there was not default value, not setting field", module);
}
return true;
}
if (!setIfEmpty && ObjectType.isEmpty(newValue)) {
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Field value not found (empty) with name [" + fromFma + "] and value [" + valueFse + "], and there was not default value, not setting field", module);
if (Debug.verboseOn()) {
Debug.logVerbose("Field value not found (empty) with name [" + fromFma + "] and value [" + valueFse + "], and there was not default value, not setting field", module);
}
return true;
}
if (this.type.length() > 0) {
@@ -194,8 +197,9 @@ public final class SetOperation extends MethodOperation {
}
}
}
if (Debug.verboseOn())
if (Debug.verboseOn()) Debug.logVerbose("Setting field [" + this.fieldFma.toString() + "] to value: " + newValue, module);
if (Debug.verboseOn()) {
Debug.logVerbose("Setting field [" + this.fieldFma.toString() + "] to value: " + newValue, module);
}
this.fieldFma.put(methodContext.getEnvMap(), newValue);
return true;
}