[exo-jcr-commits] exo-jcr SVN: r5535 - in ws/trunk: exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 27 04:03:13 EST 2012


Author: andrew.plotnikov
Date: 2012-01-27 04:03:12 -0500 (Fri, 27 Jan 2012)
New Revision: 5535

Modified:
   ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java
   ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java
   ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java
Log:
EXOJCR-1725: Fixed the Blocker/Critical violations and the easiest Major ones raised by eXo Quality Level 1.2

Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java	2012-01-27 08:58:12 UTC (rev 5534)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java	2012-01-27 09:03:12 UTC (rev 5535)
@@ -304,7 +304,7 @@
    /** controls whether modules are allowed to interact with user */
    private boolean allowUI;
 
-   private static final Log log = ExoLogger.getLogger("exo.ws.commons.HTTPConnection");
+   private static final Log LOG = ExoLogger.getLogger("exo.ws.commons.HTTPConnection");
 
    static
    {
@@ -321,8 +321,8 @@
             throw new Exception(); // try JDK 1.0.x naming
          int port = Integer.getInteger("http.proxyPort", -1).intValue();
 
-         if (log.isDebugEnabled())
-            log.debug("using proxy " + host + ":" + port);
+         if (LOG.isDebugEnabled())
+            LOG.debug("using proxy " + host + ":" + port);
 
          setProxyServer(host, port);
       }
@@ -336,8 +336,8 @@
                String host = PrivilegedSystemHelper.getProperty("proxyHost");
                int port = Integer.getInteger("proxyPort", -1).intValue();
 
-               if (log.isDebugEnabled())
-                  log.debug("using proxy " + host + ":" + port);
+               if (LOG.isDebugEnabled())
+                  LOG.debug("using proxy " + host + ":" + port);
 
                setProxyServer(host, port);
             }
@@ -362,6 +362,10 @@
       }
       catch (Exception e)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + e.getMessage());
+         }
       }
 
       /*
@@ -378,8 +382,8 @@
             int port = Integer.getInteger("HTTPClient.socksPort", -1).intValue();
             int version = Integer.getInteger("HTTPClient.socksVersion", -1).intValue();
 
-            if (log.isDebugEnabled())
-               log.debug("using SOCKS " + host + ":" + port);
+            if (LOG.isDebugEnabled())
+               LOG.debug("using SOCKS " + host + ":" + port);
 
             if (version == -1)
                setSocksServer(host, port);
@@ -431,8 +435,8 @@
             String mname = list[idx];
             DefaultModuleList.addElement(Class.forName(mname));
 
-            if (log.isDebugEnabled())
-               log.debug("added module " + list[idx]);
+            if (LOG.isDebugEnabled())
+               LOG.debug("added module " + list[idx]);
 
          }
          catch (ClassNotFoundException cnfe)
@@ -457,14 +461,17 @@
          neverPipeline = Boolean.getBoolean("HTTPClient.disable_pipelining");
          if (neverPipeline)
          {
-            if (log.isDebugEnabled())
-               log.debug("disabling pipelining");
+            if (LOG.isDebugEnabled())
+               LOG.debug("disabling pipelining");
 
          }
       }
       catch (Exception e)
       {
-         // nothing to do
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + e.getMessage());
+         }
       }
 
       /*
@@ -475,14 +482,17 @@
          noKeepAlives = Boolean.getBoolean("HTTPClient.disableKeepAlives");
          if (noKeepAlives)
          {
-            if (log.isDebugEnabled())
-               log.debug("disabling keep-alives");
+            if (LOG.isDebugEnabled())
+               LOG.debug("disabling keep-alives");
 
          }
       }
       catch (Exception e)
       {
-         // notning to do
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + e.getMessage());
+         }
       }
 
       /*
@@ -493,13 +503,17 @@
          force_1_0 = Boolean.getBoolean("HTTPClient.forceHTTP_1.0");
          if (force_1_0)
          {
-            if (log.isDebugEnabled())
-               log.debug("forcing HTTP/1.0 requests");
+            if (LOG.isDebugEnabled())
+               LOG.debug("forcing HTTP/1.0 requests");
 
          }
       }
       catch (Exception e)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + e.getMessage());
+         }
       }
 
       /*
@@ -510,13 +524,17 @@
          no_chunked = Boolean.getBoolean("HTTPClient.dontChunkRequests");
          if (no_chunked)
          {
-            if (log.isDebugEnabled())
-               log.debug("never chunking requests");
+            if (LOG.isDebugEnabled())
+               LOG.debug("never chunking requests");
 
          }
       }
       catch (Exception e)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + e.getMessage());
+         }
       }
 
       /*
@@ -529,13 +547,17 @@
             haveMSLargeWritesBug = true;
          if (haveMSLargeWritesBug)
          {
-            if (log.isDebugEnabled())
-               log.debug("splitting large writes into 20K chunks (M$ bug)");
+            if (LOG.isDebugEnabled())
+               LOG.debug("splitting large writes into 20K chunks (M$ bug)");
 
          }
       }
       catch (Exception e)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + e.getMessage());
+         }
       }
 
       /*
@@ -549,13 +571,17 @@
          deferStreamed = Boolean.getBoolean("HTTPClient.deferStreamed");
          if (deferStreamed)
          {
-            if (log.isDebugEnabled())
-               log.debug("enabling defered handling of responses to streamed requests");
+            if (LOG.isDebugEnabled())
+               LOG.debug("enabling defered handling of responses to streamed requests");
 
          }
       }
       catch (Exception e)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + e.getMessage());
+         }
       }
    }
 
@@ -1478,7 +1504,7 @@
       }
       catch (XMLStreamException e)
       {
-         log.error(e.getLocalizedMessage(), e);
+         LOG.error(e.getLocalizedMessage(), e);
          throw new IOException("Can't write XML data to output stream.");
       }
       return response;
@@ -1600,7 +1626,7 @@
       }
       catch (XMLStreamException e)
       {
-         log.error(e.getLocalizedMessage(), e);
+         LOG.error(e.getLocalizedMessage(), e);
          throw new IOException("Can't write XML data to output stream.");
       }
       return response;
@@ -1657,7 +1683,7 @@
       }
       catch (XMLStreamException e)
       {
-         log.error(e.getLocalizedMessage(), e);
+         LOG.error(e.getLocalizedMessage(), e);
          throw new IOException("Can't write XML request.");
       }
       finally
@@ -1930,6 +1956,10 @@
          }
          catch (ClassNotFoundException cnfe)
          {
+            if (LOG.isTraceEnabled())
+            {
+               LOG.trace("An exception occurred: " + cnfe.getMessage());
+            }
          }
       }
    }
@@ -2183,9 +2213,9 @@
             list.insertElementAt(module, pos);
       }
 
-      if (log.isDebugEnabled())
+      if (LOG.isDebugEnabled())
       {
-         log.debug("Added module " + module.getName() + " to " + ((list == DefaultModuleList) ? "default " : "") //NOSONAR
+         LOG.debug("Added module " + module.getName() + " to " + ((list == DefaultModuleList) ? "default " : "") //NOSONAR
             + "list");
       }
 
@@ -2200,9 +2230,9 @@
       boolean removed = list.removeElement(module);
       if (removed)
       {
-         if (log.isDebugEnabled())
+         if (LOG.isDebugEnabled())
          {
-            log.debug("Removed module " + module.getName() + " from " + ((list == DefaultModuleList) ? "default " : "") //NOSONAR
+            LOG.debug("Removed module " + module.getName() + " from " + ((list == DefaultModuleList) ? "default " : "") //NOSONAR
                + "list");
          }
       }
@@ -2518,7 +2548,10 @@
          }
          catch (ParseException pe)
          {
-            // ignore it
+            if (LOG.isTraceEnabled())
+            {
+               LOG.trace("An exception occurred: " + pe.getMessage());
+            }
          }
       }
    }
@@ -3007,27 +3040,25 @@
 
       if (early_stall != null)
       {
-         try
+         if (LOG.isDebugEnabled())
+            LOG.debug("Early-stalling Request: " + req.getMethod() + " " + req.getRequestURI());
+
+         synchronized (early_stall)
          {
-            if (log.isDebugEnabled())
-               log.debug("Early-stalling Request: " + req.getMethod() + " " + req.getRequestURI());
-
-            synchronized (early_stall)
+            // wait till the response is received
+            try
             {
-               // wait till the response is received
-               try
+               early_stall.getVersion();
+            }
+            catch (IOException ioe)
+            {
+               if (LOG.isTraceEnabled())
                {
-                  early_stall.getVersion();
+                  LOG.trace("An exception occurred: " + ioe.getMessage());
                }
-               catch (IOException ioe)
-               {
-               }
-               early_stall = null;
             }
+            early_stall = null;
          }
-         catch (NullPointerException npe)
-         {
-         }
       }
 
       String[] con_hdrs = assembleHeaders(req, hdr_buf);
@@ -3058,8 +3089,8 @@
          {
             if (input_demux != null || keepAliveUnknown)
             {
-               if (log.isDebugEnabled())
-                  log.debug("Stalling Request: " + req.getMethod() + " " + req.getRequestURI());
+               if (LOG.isDebugEnabled())
+                  LOG.debug("Stalling Request: " + req.getMethod() + " " + req.getRequestURI());
 
                try
                // wait till the response is received
@@ -3070,6 +3101,10 @@
                }
                catch (IOException ioe)
                {
+                  if (LOG.isTraceEnabled())
+                  {
+                     LOG.trace("An exception occurred: " + ioe.getMessage());
+                  }
                }
             }
 
@@ -3086,8 +3121,8 @@
          if ((req.getMethod().equals("POST") || req.dont_pipeline) && prev_resp != null && input_demux != null)
          {
 
-            if (log.isDebugEnabled())
-               log.debug("Stalling Request: " + req.getMethod() + " " + req.getRequestURI());
+            if (LOG.isDebugEnabled())
+               LOG.debug("Stalling Request: " + req.getMethod() + " " + req.getRequestURI());
 
             try
             // wait till the response is received
@@ -3096,6 +3131,10 @@
             }
             catch (IOException ioe)
             {
+               if (LOG.isTraceEnabled())
+               {
+                  LOG.trace("An exception occurred: " + ioe.getMessage());
+               }
             }
          }
 
@@ -3164,8 +3203,8 @@
                if (req.aborted)
                   throw new IOException("Request aborted by user");
 
-               if (log.isDebugEnabled())
-                  log.debug("Sending Request");
+               if (LOG.isDebugEnabled())
+                  LOG.debug("Sending Request");
 
                // Send headers
 
@@ -3194,6 +3233,10 @@
                }
                catch (InterruptedIOException iioe)
                {
+                  if (LOG.isTraceEnabled())
+                  {
+                     LOG.trace("An exception occurred: " + iioe.getMessage());
+                  }
                }
                finally
                {
@@ -3249,7 +3292,7 @@
             catch (IOException ioe)
             {
 
-               log.error("Send request error", ioe);
+               LOG.error("Send request error", ioe);
 
                closeDemux(ioe, true);
 
@@ -3257,7 +3300,7 @@
                   || ioe instanceof NoRouteToHostException || ioe instanceof InterruptedIOException || req.aborted)
                   throw ioe;
 
-               log.info("Retrying request");
+               LOG.info("Retrying request");
                continue;
             }
 
@@ -3278,8 +3321,8 @@
 
          if (keepAliveReqMax != -1)
 
-            if (log.isDebugEnabled())
-               log.debug("Number of requests left: " + keepAliveReqLeft);
+            if (LOG.isDebugEnabled())
+               LOG.debug("Number of requests left: " + keepAliveReqLeft);
 
          /*
           * We don't pipeline the first request, as we need some info about the
@@ -3325,8 +3368,8 @@
          }
 
          // Looks like were finally done
-         if (log.isDebugEnabled())
-            log.debug("Request sent");
+         if (LOG.isDebugEnabled())
+            LOG.debug("Request sent");
       }
 
       return resp;
@@ -3357,8 +3400,8 @@
          actual_port = Port;
       }
 
-      if (log.isDebugEnabled())
-         log.debug("Creating Socket: " + actual_host + ":" + actual_port);
+      if (LOG.isDebugEnabled())
+         LOG.debug("Creating Socket: " + actual_host + ":" + actual_port);
 
       if (con_timeout == 0) // normal connection establishment
       {
@@ -3455,8 +3498,8 @@
          hdr_buf.reset();
          assembleHeaders(connect, hdr_buf);
 
-         if (log.isDebugEnabled())
-            log.debug("Sending SSL-Tunneling Subrequest");
+         if (LOG.isDebugEnabled())
+            LOG.debug("Sending SSL-Tunneling Subrequest");
 
          // send CONNECT
 
@@ -3478,6 +3521,10 @@
          }
          catch (IOException ioe)
          {
+            if (LOG.isTraceEnabled())
+            {
+               LOG.trace("An exception occurred: " + ioe.getMessage());
+            }
          }
          try
          {
@@ -3485,6 +3532,10 @@
          }
          catch (IOException ioe)
          {
+            if (LOG.isTraceEnabled())
+            {
+               LOG.trace("An exception occurred: " + ioe.getMessage());
+            }
          }
 
          // handle response
@@ -3820,8 +3871,8 @@
          {
             doesKeepAlive = true;
             keepAliveUnknown = false;
-            if (log.isDebugEnabled())
-               log.debug("Keep-Alive enabled");
+            if (LOG.isDebugEnabled())
+               LOG.debug("Keep-Alive enabled");
 
          }
          else if (resp.getStatusCode() < 400)
@@ -3837,19 +3888,31 @@
                keepAliveReqMax = Integer.parseInt(max.getValue());
                keepAliveReqLeft = keepAliveReqMax;
 
-               if (log.isDebugEnabled())
-                  log.debug("Max Keep-Alive requests: " + keepAliveReqMax);
+               if (LOG.isDebugEnabled())
+                  LOG.debug("Max Keep-Alive requests: " + keepAliveReqMax);
             }
          }
       }
       catch (ParseException pe)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + pe.getMessage());
+         }
       }
       catch (NumberFormatException nfe)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + nfe.getMessage());
+         }
       }
       catch (ClassCastException cce)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + cce.getMessage());
+         }
       }
    }
 
@@ -3914,6 +3977,10 @@
          }
          catch (SecurityException se)
          {
+            if (LOG.isTraceEnabled())
+            {
+               LOG.trace("An exception occurred: " + se.getMessage());
+            }
          } // Oh well...
 
          actual_host = host;
@@ -3967,6 +4034,10 @@
             }
             catch (IOException ioe)
             {
+               if (LOG.isTraceEnabled())
+               {
+                  LOG.trace("An exception occurred: " + ioe.getMessage());
+               }
             }
             sock = null;
          }

Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java	2012-01-27 08:58:12 UTC (rev 5534)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java	2012-01-27 09:03:12 UTC (rev 5535)
@@ -144,7 +144,7 @@
    /** the output stream used for POST and PUT */
    private OutputStream output_stream;
 
-   private static final Log log = ExoLogger.getLogger("exo.ws.commons.HttpURLConnection");
+   private static final Log LOG = ExoLogger.getLogger("exo.ws.commons.HttpURLConnection");
 
    static
    {
@@ -157,6 +157,10 @@
       }
       catch (SecurityException se)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + se.getMessage());
+         }
       }
 
       // get the RedirectionModule class
@@ -178,6 +182,10 @@
       }
       catch (SecurityException se)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + se.getMessage());
+         }
       }
    }
 
@@ -219,6 +227,10 @@
       }
       catch (SecurityException se)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + se.getMessage());
+         }
       }
 
       try
@@ -235,6 +247,10 @@
       }
       catch (SecurityException se)
       {
+         if (LOG.isTraceEnabled())
+         {
+            LOG.trace("An exception occurred: " + se.getMessage());
+         }
       }
 
       // now setup stuff
@@ -292,8 +308,8 @@
       if (connected)
          throw new ProtocolException("Already connected!");
 
-      if (log.isDebugEnabled())
-         log.debug(urlString + " Setting request method: " + method);
+      if (LOG.isDebugEnabled())
+         LOG.debug(urlString + " Setting request method: " + method);
 
       this.method = method.trim().toUpperCase();
       method_set = true;
@@ -588,8 +604,8 @@
 
       if (output_stream == null)
       {
-         if (log.isDebugEnabled())
-            log.debug(urlString + " creating output stream");
+         if (LOG.isDebugEnabled())
+            LOG.debug(urlString + " creating output stream");
 
          String cl = getRequestProperty("Content-Length");
          if (cl != null)
@@ -656,8 +672,8 @@
    public void setRequestProperty(String name, String value)
    {
 
-      if (log.isDebugEnabled())
-         log.debug(urlString + " Setting request property: " + name + " : " + value);
+      if (LOG.isDebugEnabled())
+         LOG.debug(urlString + " Setting request property: " + name + " : " + value);
 
       int idx;
       for (idx = 0; idx < headers.length; idx++)
@@ -697,8 +713,8 @@
     */
    public static void setDefaultRequestProperty(String name, String value)
    {
-      if (log.isDebugEnabled())
-         log.debug("Setting default request property: " + name + " : " + value);
+      if (LOG.isDebugEnabled())
+         LOG.debug("Setting default request property: " + name + " : " + value);
 
       int idx;
       for (idx = 0; idx < default_headers.length; idx++)
@@ -763,8 +779,8 @@
       if (connected)
          return;
 
-      if (log.isDebugEnabled())
-         log.debug(urlString + " Connecting ...");
+      if (LOG.isDebugEnabled())
+         LOG.debug(urlString + " Connecting ...");
 
       // useCaches TBD!!!
 
@@ -799,8 +815,8 @@
    @Override
    public void disconnect()
    {
-      if (log.isDebugEnabled())
-         log.debug(urlString + " Disconnecting ...");
+      if (LOG.isDebugEnabled())
+         LOG.debug(urlString + " Disconnecting ...");
 
       con.stop();
    }

Modified: ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java
===================================================================
--- ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java	2012-01-27 08:58:12 UTC (rev 5534)
+++ ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java	2012-01-27 09:03:12 UTC (rev 5535)
@@ -18,6 +18,8 @@
  */
 package org.exoplatform.ws.frameworks.json.impl;
 
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
 import org.exoplatform.ws.frameworks.json.impl.JsonUtils.Types;
 import org.exoplatform.ws.frameworks.json.value.JsonValue;
 
@@ -43,6 +45,9 @@
  */
 public class ObjectBuilder
 {
+
+   private static final Log LOG = ExoLogger.getLogger("org.exoplatform.ws.frameworks.json.impl.ObjectBuilder");
+
    static final Collection<String> SKIP_METHODS = new HashSet<String>();
    static
    {
@@ -173,7 +178,10 @@
                   }
                   catch (Exception e2)
                   {
-                     // ignore exception here
+                     if (LOG.isTraceEnabled())
+                     {
+                        LOG.trace("An exception occurred: " + e2.getMessage());
+                     }
                   }
                }
             }
@@ -282,7 +290,10 @@
                   }
                   catch (Exception e2)
                   {
-                     // ignore exception here
+                     if (LOG.isTraceEnabled())
+                     {
+                        LOG.trace("An exception occurred: " + e2.getMessage());
+                     }
                   }
                }
             }



More information about the exo-jcr-commits mailing list