You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by sj...@apache.org on 2008/08/05 18:10:57 UTC

svn commit: r682770 - in /mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client: auth/BasicScheme.java auth/DigestScheme.java auth/NTLMScheme.java codec/HttpDecoder.java util/EncodingUtil.java

Author: sjlee
Date: Tue Aug  5 09:10:56 2008
New Revision: 682770

URL: http://svn.apache.org/viewvc?rev=682770&view=rev
Log:
Improved the previous fix on logging statements.  Do not call isXXXEnabled() methods, but use "{}" to delay arg evaluation, which achieves the same desired effect.

Modified:
    mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java
    mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java
    mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java
    mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java
    mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java

Modified: mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java
URL: http://svn.apache.org/viewvc/mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java?rev=682770&r1=682769&r2=682770&view=diff
==============================================================================
--- mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java (original)
+++ mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/BasicScheme.java Tue Aug  5 09:10:56 2008
@@ -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");

Modified: mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java
URL: http://svn.apache.org/viewvc/mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java?rev=682770&r1=682769&r2=682770&view=diff
==============================================================================
--- mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java (original)
+++ mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/DigestScheme.java Tue Aug  5 09:10:56 2008
@@ -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";

Modified: mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java
URL: http://svn.apache.org/viewvc/mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java?rev=682770&r1=682769&r2=682770&view=diff
==============================================================================
--- mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java (original)
+++ mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/auth/NTLMScheme.java Tue Aug  5 09:10:56 2008
@@ -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");

Modified: mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java
URL: http://svn.apache.org/viewvc/mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java?rev=682770&r1=682769&r2=682770&view=diff
==============================================================================
--- mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java (original)
+++ mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/HttpDecoder.java Tue Aug  5 09:10:56 2008
@@ -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(";");

Modified: mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java
URL: http://svn.apache.org/viewvc/mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java?rev=682770&r1=682769&r2=682770&view=diff
==============================================================================
--- mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java (original)
+++ mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/util/EncodingUtil.java Tue Aug  5 09:10:56 2008
@@ -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();
         }
     }