Don’t do important call as parameter to log.debug!

- doing t.get() in parameters to log.debug is asking for trouble!
- someone would likely add if (log.isDebugEnabled()) at some point
  in the future, causing things to fail unexpectedly for a customer
  who configures their logging differently from the default!


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/b361ea4e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/b361ea4e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/b361ea4e

Branch: refs/pull/1406/head
Commit: b361ea4e6f30ea810abee65ea9918ae9b9c705b0
Parents: 8402582
Author: Aled Sage <aled.s...@gmail.com>
Authored: Thu May 22 10:19:12 2014 +0100
Committer: Aled Sage <aled.s...@gmail.com>
Committed: Thu May 22 12:59:33 2014 +0100

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/BrooklynShutdownHooks.java   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b361ea4e/core/src/main/java/brooklyn/entity/basic/BrooklynShutdownHooks.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/brooklyn/entity/basic/BrooklynShutdownHooks.java 
b/core/src/main/java/brooklyn/entity/basic/BrooklynShutdownHooks.java
index 928f918..df6045b 100644
--- a/core/src/main/java/brooklyn/entity/basic/BrooklynShutdownHooks.java
+++ b/core/src/main/java/brooklyn/entity/basic/BrooklynShutdownHooks.java
@@ -61,21 +61,22 @@ public class BrooklynShutdownHooks {
                     try {
                         stops.add(entity.invoke(Startable.STOP, new 
MutableMap()));
                     } catch (RuntimeException exc) {
-                        log.debug("stopOnShutdown of "+entity+" returned error 
(continuing): "+exc, exc);
+                        if (log.isDebugEnabled()) log.debug("stopOnShutdown of 
"+entity+" returned error (continuing): "+exc, exc);
                     }
                 }
                 try {
                     for (Task t: stops) {
                         try {
-                            log.debug("stopOnShutdown of {} completed: {}", t, 
t.get());
+                            Object result = t.get();
+                            if (log.isDebugEnabled()) 
log.debug("stopOnShutdown of {} completed: {}", t, result);
                         } catch (Exception e) {
-                            log.debug("stopOnShutdown of "+t+" returned error 
(continuing): "+e, e);
+                            if (log.isDebugEnabled()) 
log.debug("stopOnShutdown of "+t+" returned error (continuing): "+e, e);
                             Exceptions.propagateIfFatal(e);
                         }
                     }
                 } catch (RuntimeInterruptedException e) {
                     Thread.currentThread().interrupt();
-                    log.debug("stopOnShutdown interrupted while waiting for 
entity-stop tasks; continuing: "+e);
+                    if (log.isDebugEnabled()) log.debug("stopOnShutdown 
interrupted while waiting for entity-stop tasks; continuing: "+e);
                 }
             }
             

Reply via email to