cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [12/30] git commit: updated refs/heads/master to 64ff67d
Date Fri, 14 Aug 2015 19:47:35 GMT
CLOUDSTACK-8656: network related exception logging


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

Branch: refs/heads/master
Commit: c0534756d04f645c4e11e5b47f6eb0d9926babae
Parents: 6fa8b75
Author: Daan Hoogland <daan.hoogland@gmail.com>
Authored: Tue Aug 4 16:38:03 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Tue Aug 11 18:14:20 2015 +0200

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/MacAddress.java   | 43 +++++++-------------
 .../src/com/cloud/utils/nio/NioConnection.java  | 15 +++----
 2 files changed, 22 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0534756/utils/src/com/cloud/utils/net/MacAddress.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/MacAddress.java b/utils/src/com/cloud/utils/net/MacAddress.java
index dc53e4a..b9118cf 100644
--- a/utils/src/com/cloud/utils/net/MacAddress.java
+++ b/utils/src/com/cloud/utils/net/MacAddress.java
@@ -19,7 +19,7 @@
 
 package com.cloud.utils.net;
 
-import com.cloud.utils.NumbersUtil;
+import static com.cloud.utils.AutoCloseableUtil.closeAutoCloseable;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -29,12 +29,17 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Formatter;
 
+import org.apache.log4j.Logger;
+
+import com.cloud.utils.NumbersUtil;
+
 /**
  * copied from the public domain utility from John Burkard.
  * @author <a href="mailto:jb@eaio.com">Johann Burkard</a>
  * @version 2.1.3
  **/
 public class MacAddress {
+    private static final Logger s_logger = Logger.getLogger(MacAddress.class);
     private long _addr = 0;
 
     protected MacAddress() {
@@ -124,23 +129,14 @@ public class MacAddress {
             }
 
         } catch (SecurityException ex) {
+            s_logger.info("[ignored] security exception in static initializer of MacAddress",
ex);
         } catch (IOException ex) {
+            s_logger.info("[ignored] io exception in static initializer of MacAddress");
         } finally {
             if (p != null) {
-                if (in != null) {
-                    try {
-                        in.close();
-                    } catch (IOException ex) {
-                    }
-                }
-                try {
-                    p.getErrorStream().close();
-                } catch (IOException ex) {
-                }
-                try {
-                    p.getOutputStream().close();
-                } catch (IOException ex) {
-                }
+                closeAutoCloseable(in, "closing init process input stream");
+                closeAutoCloseable(p.getErrorStream(), "closing init process error output
stream");
+                closeAutoCloseable(p.getOutputStream(), "closing init process std output
stream");
                 p.destroy();
             }
         }
@@ -184,20 +180,9 @@ public class MacAddress {
             return reader.readLine();
         } finally {
             if (p != null) {
-                if (reader != null) {
-                    try {
-                        reader.close();
-                    } catch (IOException ex) {
-                    }
-                }
-                try {
-                    p.getErrorStream().close();
-                } catch (IOException ex) {
-                }
-                try {
-                    p.getOutputStream().close();
-                } catch (IOException ex) {
-                }
+                closeAutoCloseable(reader, "closing process input stream");
+                closeAutoCloseable(p.getErrorStream(), "closing process error output stream");
+                closeAutoCloseable(p.getOutputStream(), "closing process std output stream");
                 p.destroy();
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0534756/utils/src/com/cloud/utils/nio/NioConnection.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/NioConnection.java b/utils/src/com/cloud/utils/nio/NioConnection.java
index 34679b8..4c66360 100644
--- a/utils/src/com/cloud/utils/nio/NioConnection.java
+++ b/utils/src/com/cloud/utils/nio/NioConnection.java
@@ -19,6 +19,8 @@
 
 package com.cloud.utils.nio;
 
+import static com.cloud.utils.AutoCloseableUtil.closeAutoCloseable;
+
 import java.io.IOException;
 import java.net.ConnectException;
 import java.net.InetSocketAddress;
@@ -41,10 +43,10 @@ import java.util.concurrent.TimeUnit;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 
-import org.apache.cloudstack.utils.security.SSLUtils;
-
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.utils.security.SSLUtils;
+
 import com.cloud.utils.concurrency.NamedThreadFactory;
 
 /**
@@ -208,11 +210,8 @@ public abstract class NioConnection implements Runnable {
             if (s_logger.isTraceEnabled()) {
                 s_logger.trace("Socket " + socket + " closed on read.  Probably -1 returned:
" + e.getMessage());
             }
-            try {
-                socketChannel.close();
-                socket.close();
-            } catch (IOException ignore) {
-            }
+            closeAutoCloseable(socketChannel, "accepting socketChannel");
+            closeAutoCloseable(socket, "opened socket");
             return;
         }
 
@@ -334,6 +333,7 @@ public abstract class NioConnection implements Runnable {
                         try {
                             ((SocketChannel)(todo.key)).close();
                         } catch (IOException ignore) {
+                            s_logger.info("[ignored] socket channel");
                         } finally {
                             Link link = (Link)todo.att;
                             link.terminated();
@@ -420,6 +420,7 @@ public abstract class NioConnection implements Runnable {
                     channel.close();
                 }
             } catch (IOException ignore) {
+                s_logger.info("[ignored] channel");
             }
         }
     }


Mime
View raw message