Improved the previous fix on logging statements.  Do not call isXXXEnabled() methods, but use "{}" to delay arg evaluation, which achieves the same desired effect.


git-svn-id: https://svn.apache.org/repos/asf/mina/asyncweb/branches/1.0@682770 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java b/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java
index 0a2c67b..1e95d36 100644
--- a/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java
+++ b/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java
@@ -107,9 +107,7 @@
      */
     public String authenticate(Credentials credentials, HttpRequestMessage request) throws AuthenticationException {
 
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter BasicScheme.authenticate(Credentials, HttpMethod)");
-        }
+        LOG.trace("enter BasicScheme.authenticate(Credentials, HttpMethod)");
 
         if (request == null) {
             throw new IllegalArgumentException("Request may not be null");
@@ -139,9 +137,7 @@
      */
     public static String authenticate(UsernamePasswordCredentials credentials, String charset) {
 
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter BasicScheme.authenticate(UsernamePasswordCredentials, String)");
-        }
+        LOG.trace("enter BasicScheme.authenticate(UsernamePasswordCredentials, String)");
 
         if (credentials == null) {
             throw new IllegalArgumentException("Credentials may not be null");
diff --git a/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java b/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java
index 5e8372c..19e3097 100644
--- a/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java
+++ b/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java
@@ -108,7 +108,7 @@
                     qopVariant = QOP_AUTH_INT;
                 } else {
                     unsupportedQop = true;
-                    LOG.warn("Unsupported qop detected: "+ variant);
+                    LOG.warn("Unsupported qop detected: {}", variant);
                 }
             }
         }
@@ -176,9 +176,7 @@
     public String authenticate(Credentials credentials, HttpRequestMessage request)
     throws AuthenticationException {
 
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter DigestScheme.authenticate(Credentials, HttpMethod)");
-        }
+        LOG.trace("enter DigestScheme.authenticate(Credentials, HttpMethod)");
 
         UsernamePasswordCredentials usernamepassword = null;
         try {
@@ -221,9 +219,7 @@
      */
     private String createDigest(final String uname, final String pwd) throws AuthenticationException {
 
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter DigestScheme.createDigest(String, String, Map)");
-        }
+        LOG.trace("enter DigestScheme.createDigest(String, String, Map)");
 
         final String digAlg = "MD5";
 
@@ -284,7 +280,7 @@
             tmp3.append(cnonce);
             a1 = tmp3.toString();
         } else if(!algorithm.equals("MD5")) {
-            LOG.warn("Unhandled algorithm " + algorithm + " requested");
+            LOG.warn("Unhandled algorithm {} requested", algorithm);
         }
         String md5a1 = encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset)));
 
@@ -301,9 +297,7 @@
         // 3.2.2.1
         String serverDigestValue;
         if (qopVariant == QOP_MISSING) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using null qop method");
-            }
+            LOG.debug("Using null qop method");
             StringBuilder tmp2 = new StringBuilder(md5a1.length() + nonce.length() + md5a2.length());
             tmp2.append(md5a1);
             tmp2.append(':');
@@ -312,9 +306,7 @@
             tmp2.append(md5a2);
             serverDigestValue = tmp2.toString();
         } else {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Using qop method " + qop);
-            }
+            LOG.debug("Using qop method {}", qop);
             String qopOption = getQopVariantString();
             StringBuilder tmp2 = new StringBuilder(md5a1.length() + nonce.length()
                 + NC.length() + cnonce.length() + qopOption.length() + md5a2.length() + 5);
@@ -349,10 +341,7 @@
     private String createDigestHeader(final String uname, final String digest)
         throws AuthenticationException {
 
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter DigestScheme.createDigestHeader(String, Map, "
-                    + "String)");
-        }
+        LOG.trace("enter DigestScheme.createDigestHeader(String, Map, String)");
 
         String uri = getParameter("uri");
         String realm = getParameter("realm");
@@ -412,9 +401,7 @@
      * @return encoded MD5, or <CODE>null</CODE> if encoding failed
      */
     private static String encode(byte[] binaryData) {
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter DigestScheme.encode(byte[])");
-        }
+        LOG.trace("enter DigestScheme.encode(byte[])");
 
         if (binaryData.length != 16) {
             return null;
@@ -439,9 +426,7 @@
      * @throws AsyncHttpClientException if MD5 algorithm is not supported.
      */
     public static String createCnonce() {
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter DigestScheme.createCnonce()");
-        }
+        LOG.trace("enter DigestScheme.createCnonce()");
 
         String cnonce;
         final String digAlg = "MD5";
diff --git a/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java b/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java
index 54721bb..eb01020 100644
--- a/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java
+++ b/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java
@@ -173,9 +173,7 @@
      */
     public String authenticate(Credentials credentials, HttpRequestMessage request)
         throws AuthenticationException {
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("enter NTLMScheme.authenticate(Credentials, HttpMethod)");
-        }
+        LOG.trace("enter NTLMScheme.authenticate(Credentials, HttpMethod)");
 
         if (this.state == UNINITIATED) {
             throw new IllegalStateException("NTLM authentication process has not been initiated");
diff --git a/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java b/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java
index 3f4a78b..5731bbe 100644
--- a/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java
+++ b/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java
@@ -248,9 +248,8 @@
      * @throws Exception if any exception occurs
      */
     public void decodeHeader(String line, HttpResponseMessage msg) throws Exception {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Processing Header Line: " + line);
-        }
+        LOG.debug("Processing Header Line: {}", line);
+
         // first, get rid of the CRLF from linear whitespace
         line = folding.matcher(line).replaceAll("$1");
         int pos = line.indexOf(":");
@@ -422,9 +421,8 @@
      * @see Cookie
      */
     public Cookie decodeCookie(String cookieStr, HttpResponseMessage msg) throws Exception {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Processing Cookie Line: " + cookieStr);
-        }
+        LOG.debug("Processing Cookie Line: {}", cookieStr);
+
         Cookie cookie = null;
 
         String pairs[] = cookieStr.split(";");
diff --git a/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java b/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java
index f394eb3..0588331 100644
--- a/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java
+++ b/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java
@@ -72,7 +72,7 @@
         try {
             return doFormUrlEncode(pairs, charset);
         } catch (UnsupportedEncodingException e) {
-            LOG.error("Encoding not supported: " + charset);
+            LOG.error("Encoding not supported: {}", charset);
             try {
                 return doFormUrlEncode(pairs, DEFAULT_CHARSET);
             } catch (UnsupportedEncodingException fatal) {
@@ -151,10 +151,7 @@
         try {
             return new String(data, offset, length, charset);
         } catch (UnsupportedEncodingException e) {
-
-            if (LOG.isWarnEnabled()) {
-                LOG.warn("Unsupported encoding: " + charset + ". System encoding used");
-            }
+            LOG.warn("Unsupported encoding: {}. System encoding used", charset);
             return new String(data, offset, length);
         }
     }
@@ -196,11 +193,7 @@
         try {
             return data.getBytes(charset);
         } catch (UnsupportedEncodingException e) {
-
-            if (LOG.isWarnEnabled()) {
-                LOG.warn("Unsupported encoding: " + charset + ". System encoding used.");
-            }
-
+            LOG.warn("Unsupported encoding: {}. System encoding used.", charset);
             return data.getBytes();
         }
     }