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

(OFBIZ-10052)

This completes r1818010, there were much more cases.
Also few tabs automatically replaced by spaces

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1818020 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2017-12-13 14:11:38 +00:00
parent 24b92d6921
commit 40e8be83df
44 changed files with 105 additions and 104 deletions
@@ -459,7 +459,7 @@ public final class ComponentConfig {
throw new ComponentException("Error reading container configurations for component: " + this.globalName, ce);
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Read component config : [" + rootLocation + "]", module);
Debug.logVerbose("Read component config : [" + rootLocation + "]", module);
}
}
@@ -55,7 +55,7 @@ public class ComponentResourceHandler implements ResourceHandler {
this.loaderName = loaderName;
this.location = location;
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Created " + this.toString(), module);
Debug.logVerbose("Created " + this.toString(), module);
}
}
@@ -74,7 +74,7 @@ public class Converters {
public static <S, T> Converter<S, T> getConverter(Class<S> sourceClass, Class<T> targetClass) throws ClassNotFoundException {
String key = sourceClass.getName().concat(DELIMITER).concat(targetClass.getName());
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Getting converter: " + key, module);
Debug.logVerbose("Getting converter: " + key, module);
}
OUTER:
do {
@@ -85,14 +85,14 @@ public class GroovyUtil {
return null;
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Evaluating -- " + expression, module);
Debug.logVerbose("Evaluating -- " + expression, module);
if (Debug.verboseOn()) Debug.logVerbose("Using Context -- " + context, module);
}
try {
GroovyShell shell = new GroovyShell(getBinding(context, expression));
o = shell.evaluate(StringUtil.convertOperatorSubstitutions(expression));
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Evaluated to -- " + o, module);
Debug.logVerbose("Evaluated to -- " + o, module);
}
// read back the context info
Binding binding = shell.getContext();
@@ -160,7 +160,7 @@ public class GroovyUtil {
Class<?> scriptClassCached = parsedScripts.putIfAbsent(location, scriptClass);
if (scriptClassCached == null) { // putIfAbsent returns null if the class is added to the cache
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Cached Groovy script at: " + location, module);
Debug.logVerbose("Cached Groovy script at: " + location, module);
}
} else {
// the newly parsed script is discarded and the one found in the cache (that has been created by a concurrent thread in the meantime) is used
@@ -800,7 +800,7 @@ public class ObjectType {
if (value instanceof java.util.Date) return false;
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("In ObjectType.isEmpty(Object value) returning false for " + value.getClass() + " Object.", module);
Debug.logVerbose("In ObjectType.isEmpty(Object value) returning false for " + value.getClass() + " Object.", module);
}
return false;
}
@@ -52,7 +52,7 @@ public class PatternFactory {
}
pattern = compiledPerl5Patterns.putIfAbsentAndGet(stringPattern, pattern);
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Compiled and cached the pattern: '" + stringPattern, module);
Debug.logVerbose("Compiled and cached the pattern: '" + stringPattern, module);
}
}
return pattern;
@@ -108,7 +108,7 @@ public final class ScriptUtil {
if (iter.hasNext()) {
helperFactory = iter.next();
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("ScriptHelper factory set to " + helperFactory.getClass().getName(), module);
Debug.logVerbose("ScriptHelper factory set to " + helperFactory.getClass().getName(), module);
}
} else {
Debug.logWarning("ScriptHelper factory not found", module);
@@ -140,11 +140,11 @@ public final class ScriptUtil {
.getUtf8()));
script = compilableEngine.compile(reader);
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Compiled script " + filePath + " using engine " + engine.getClass().getName(), module);
Debug.logVerbose("Compiled script " + filePath + " using engine " + engine.getClass().getName(), module);
}
} catch (ClassCastException e) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Script engine " + engine.getClass().getName() + " does not implement Compilable", module);
Debug.logVerbose("Script engine " + engine.getClass().getName() + " does not implement Compilable", module);
}
}
if (script != null) {
@@ -177,11 +177,11 @@ public final class ScriptUtil {
Compilable compilableEngine = (Compilable) engine;
compiledScript = compilableEngine.compile(script);
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Compiled script [" + script + "] using engine " + engine.getClass().getName(), module);
Debug.logVerbose("Compiled script [" + script + "] using engine " + engine.getClass().getName(), module);
}
} catch (ClassCastException e) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Script engine " + engine.getClass().getName() + " does not implement Compilable", module);
Debug.logVerbose("Script engine " + engine.getClass().getName() + " does not implement Compilable", module);
}
}
if (compiledScript != null) {
@@ -273,7 +273,7 @@ public final class ScriptUtil {
throw new IllegalArgumentException("The script type is not supported for language: " + language);
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Begin processing script [" + script + "] using engine " + engine.getClass().getName(), module);
Debug.logVerbose("Begin processing script [" + script + "] using engine " + engine.getClass().getName(), module);
}
ScriptContext scriptContext = createScriptContext(context);
return engine.eval(script, scriptContext);
@@ -298,7 +298,7 @@ public final class ScriptUtil {
Object result = script.eval(scriptContext);
if (UtilValidate.isNotEmpty(functionName)) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Invoking function/method " + functionName, module);
Debug.logVerbose("Invoking function/method " + functionName, module);
}
ScriptEngine engine = script.getEngine();
try {
@@ -380,7 +380,7 @@ public final class ScriptUtil {
throw new IllegalArgumentException("The script type is not supported for location: " + filePath);
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Begin processing script [" + filePath + "] using engine " + engine.getClass().getName(), module);
Debug.logVerbose("Begin processing script [" + filePath + "] using engine " + engine.getClass().getName(), module);
}
engine.setContext(scriptContext);
URL scriptUrl = FlexibleLocation.resolveLocation(filePath);
@@ -533,7 +533,7 @@ public class StringUtil {
result = pattern.matcher(result).replaceAll(entry.getKey());
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Converted " + expression + " to " + result, module);
Debug.logVerbose("Converted " + expression + " to " + result, module);
}
}
return result;
@@ -159,7 +159,7 @@ public final class UtilHttp {
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Made Request Parameter Map with [" + paramMap.size() + "] Entries", module);
Debug.logVerbose("Made Request Parameter Map with [" + paramMap.size() + "] Entries", module);
//Debug.logVerbose("Request Parameter Map Entries: " + System.getProperty("line.separator") + UtilMisc.printMap(paramMap), module); see OFBIZ-9310
}
@@ -319,7 +319,7 @@ public final class UtilHttp {
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Made Request Attribute Map with [" + attributeMap.size() + "] Entries", module);
Debug.logVerbose("Made Request Attribute Map with [" + attributeMap.size() + "] Entries", module);
if (Debug.verboseOn()) Debug.logVerbose("Request Attribute Map Entries: " + System.getProperty("line.separator") + UtilMisc.printMap(attributeMap), module);
}
@@ -354,7 +354,7 @@ public final class UtilHttp {
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Made Session Attribute Map with [" + sessionMap.size() + "] Entries", module);
Debug.logVerbose("Made Session Attribute Map with [" + sessionMap.size() + "] Entries", module);
if (Debug.verboseOn()) Debug.logVerbose("Session Attribute Map Entries: " + System.getProperty("line.separator") + UtilMisc.printMap(sessionMap), module);
}
@@ -389,7 +389,7 @@ public final class UtilHttp {
}
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Made ServletContext Attribute Map with [" + servletCtxMap.size() + "] Entries", module);
Debug.logVerbose("Made ServletContext Attribute Map with [" + servletCtxMap.size() + "] Entries", module);
if (Debug.verboseOn()) Debug.logVerbose("ServletContext Attribute Map Entries: " + System.getProperty("line.separator") + UtilMisc.printMap(servletCtxMap), module);
}
@@ -76,7 +76,7 @@ public final class FlexibleMapAccessor<T> implements Serializable, IsEmpty {
this.isAscending = isAscending;
this.fse = fse;
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("FlexibleMapAccessor created, original = " + this.original, module);
Debug.logVerbose("FlexibleMapAccessor created, original = " + this.original, module);
}
}
@@ -149,7 +149,7 @@ public final class FlexibleMapAccessor<T> implements Serializable, IsEmpty {
} catch (PropertyNotFoundException e) {
// PropertyNotFound exceptions are common, so log verbose.
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("UEL exception while getting value: " + e + ", original = " + this.original, module);
Debug.logVerbose("UEL exception while getting value: " + e + ", original = " + this.original, module);
}
} catch (Exception e) {
Debug.logError("UEL exception while getting value: " + e + ", original = " + this.original, module);
@@ -604,7 +604,7 @@ public abstract class FlexibleStringExpander implements Serializable, IsEmpty {
}
} catch (PropertyNotFoundException e) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Error evaluating expression: " + e, module);
Debug.logVerbose("Error evaluating expression: " + e, module);
}
} catch (Exception e) {
Debug.logError("Error evaluating expression: " + e, module);
@@ -658,7 +658,7 @@ public abstract class FlexibleStringExpander implements Serializable, IsEmpty {
return obj;
} else {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Scriptlet evaluated to null [" + this + "].", module);
Debug.logVerbose("Scriptlet evaluated to null [" + this + "].", module);
}
}
} catch (Exception e) {
@@ -693,7 +693,7 @@ public abstract class FlexibleStringExpander implements Serializable, IsEmpty {
return UelUtil.evaluate(context, openBracket.concat(expr.toString()).concat(closeBracket));
} catch (PropertyNotFoundException e) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Error evaluating expression: " + e, module);
Debug.logVerbose("Error evaluating expression: " + e, module);
}
} catch (Exception e) {
Debug.logError("Error evaluating expression: " + e, module);
@@ -718,7 +718,7 @@ public abstract class FlexibleStringExpander implements Serializable, IsEmpty {
obj = UelUtil.evaluate(context, new String(this.bracketedOriginal));
} catch (PropertyNotFoundException e) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Error evaluating expression " + this + ": " + e, module);
Debug.logVerbose("Error evaluating expression " + this + ": " + e, module);
}
} catch (Exception e) {
Debug.logError("Error evaluating expression " + this + ": " + e, module);
@@ -88,7 +88,7 @@ public class JuelConnector {
if (base == null) {
base = UelUtil.autoVivifyListOrMap(property);
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("ExtendedAstBracket.setValue auto-vivify base: " + base + ", property = " + property, module);
Debug.logVerbose("ExtendedAstBracket.setValue auto-vivify base: " + base + ", property = " + property, module);
}
prefix.setValue(bindings, context, base);
}
@@ -124,7 +124,7 @@ public class JuelConnector {
if (base == null) {
base = UelUtil.autoVivifyListOrMap(property);
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("ExtendedAstDot.setValue auto-vivify base: " + base + ", property = " + property, module);
Debug.logVerbose("ExtendedAstDot.setValue auto-vivify base: " + base + ", property = " + property, module);
}
prefix.setValue(bindings, context, base);
}
@@ -97,7 +97,7 @@ public final class UelUtil {
*/
public static void setValue(Map<String, Object> context, String expression, Class expectedType, Object value) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("UelUtil.setValue invoked, expression = " + expression + ", value = " + value, module);
Debug.logVerbose("UelUtil.setValue invoked, expression = " + expression + ", value = " + value, module);
}
ELContext elContext = new BasicContext(context);
ValueExpression ve = exprFactory.createValueExpression(elContext, expression, expectedType);
@@ -111,7 +111,7 @@ public final class UelUtil {
*/
public static void removeValue(Map<String, Object> context, String expression) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("UelUtil.removeValue invoked, expression = " + expression , module);
Debug.logVerbose("UelUtil.removeValue invoked, expression = " + expression , module);
}
ELContext elContext = new BasicContext(context);
ValueExpression ve = exprFactory.createValueExpression(elContext, expression, Object.class);
@@ -340,7 +340,7 @@ public final class UelUtil {
super.setValue(context, base, property, val);
if (!context.isPropertyResolved() && base == null) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("ExtendedCompositeResolver.setValue: base = " + base + ", property = " + property + ", value = " + val, module);
Debug.logVerbose("ExtendedCompositeResolver.setValue: base = " + base + ", property = " + property + ", value = " + val, module);
}
try {
BasicContext elContext = (BasicContext) context;
@@ -375,14 +375,14 @@ public final class UelUtil {
String str = property.toString();
if ("add".equals(str)) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("ExtendedListResolver.setValue adding List element: base = " + base + ", property = " + property + ", value = " + val, module);
Debug.logVerbose("ExtendedListResolver.setValue adding List element: base = " + base + ", property = " + property + ", value = " + val, module);
}
context.setPropertyResolved(true);
List list = (List) base;
list.add(val);
} else if (str.startsWith("insert@")) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("ExtendedListResolver.setValue inserting List element: base = " + base + ", property = " + property + ", value = " + val, module);
Debug.logVerbose("ExtendedListResolver.setValue inserting List element: base = " + base + ", property = " + property + ", value = " + val, module);
}
context.setPropertyResolved(true);
String indexStr = str.replace("insert@", "");
@@ -436,7 +436,7 @@ public final class UelUtil {
}
if (locale == null) {
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("ExtendedMapResolver.getValue: unable to find Locale for LocalizedMap element, using default locale", module);
Debug.logVerbose("ExtendedMapResolver.getValue: unable to find Locale for LocalizedMap element, using default locale", module);
}
locale = Locale.getDefault();
}
@@ -144,7 +144,7 @@ public final class FreeMarkerWorker {
String key = (String) i.next();
String className = props.getProperty(key);
if (Debug.verboseOn()) {
if (Debug.verboseOn()) Debug.logVerbose("Adding FTL Transform " + key + " with class " + className, module);
Debug.logVerbose("Adding FTL Transform " + key + " with class " + className, module);
}
try {
config.setSharedVariable(key, loader.loadClass(className).newInstance());