Merge "Invalid cast results in HTTP 500 error returned by the Neutron REST APIs."
authorAlessandro Boch <aboch@cisco.com>
Tue, 14 Jan 2014 23:54:58 +0000 (23:54 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 14 Jan 2014 23:54:58 +0000 (23:54 +0000)
opendaylight/distribution/opendaylight/src/main/resources/configuration/logback.xml
opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java
opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java [deleted file]
opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionPolicy.java [new file with mode: 0644]
opendaylight/md-sal/model/model-flow-statistics/src/main/yang/group-statistics.yang
opendaylight/netconf/netconf-ssh/pom.xml

index 84d1c913c413ef5e1978aded60ff85c200437169..61d274d80c22daf91dd28fe6cf8b9c7138fb7c41 100644 (file)
@@ -41,7 +41,8 @@
   <logger name="org.opendaylight.controller" level="INFO"/>
 
   <!-- OSGi logging bridge -->
-  <logger name="org.opendaylight.controller.logging.bridge" level="WARN"/>
+  <logger name="org.opendaylight.controller.logging.bridge" level="INFO"/>
+  <logger name="org.opendaylight.controller.logging.bridge.internal" level="WARN"/>
 
   <!-- Netty -->
   <logger name="io.netty" level="WARN"/>
index 95f57ae31cc405ec83b69e59a2fc3310be24848e..b231faf15307b558cebc629524ee185c12c89a97 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -6,11 +5,13 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.logging.bridge.internal;
 
 import org.osgi.service.log.LogEntry;
+
+import java.lang.Thread.UncaughtExceptionHandler;
 import java.util.Enumeration;
+
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleActivator;
@@ -21,7 +22,11 @@ import org.slf4j.ILoggerFactory;
 import org.osgi.service.log.LogReaderService;
 
 public class Activator implements BundleActivator {
+    private static final String UNCAUGHT_EXCEPTION_POLICY_PROP = "controller.uncaughtExceptionPolicy";
+    private static final UncaughtExceptionPolicy DEFAULT_UNCAUGHT_EXCEPTION_POLICY = UncaughtExceptionPolicy.IGNORE;
+
     private LogListenerImpl listener = null;
+    private ShutdownHandler shutdownHandler = null;
     private Logger log = null;
 
     @Override
@@ -62,16 +67,25 @@ public class Activator implements BundleActivator {
                  * handler will display the exceptions to OSGI console as well
                  * as log to file.
                  */
-                Thread.setDefaultUncaughtExceptionHandler(new org.opendaylight.
-                        controller.logging.bridge.internal.UncaughtExceptionHandler());
+                UncaughtExceptionHandler handler = DEFAULT_UNCAUGHT_EXCEPTION_POLICY;
+                final String policy = context.getProperty(UNCAUGHT_EXCEPTION_POLICY_PROP);
+                if (policy != null) {
+                    try {
+                        handler = UncaughtExceptionPolicy.valueOf(policy.toUpperCase());
+                    } catch (IllegalArgumentException ex) {
+                        log.warn("Invalid policy name \"{}\", defaulting to {}", policy, handler);
+                    }
+                }
+                log.info("Setting uncaught exception policy to {}", handler);
+                Thread.setDefaultUncaughtExceptionHandler(handler);
 
                 /*
                  * Install the Shutdown handler. This will intercept SIGTERM signal and
                  * close the system bundle. This allows for a graceful  closing of OSGI
                  * framework.
                  */
-
-                Runtime.getRuntime().addShutdownHook(new shutdownHandler(context));
+                shutdownHandler = new ShutdownHandler(context);
+                Runtime.getRuntime().addShutdownHook(shutdownHandler);
             } else {
                 this.log.error("Cannot register the LogListener because "
                         + "cannot retrieve LogReaderService");
@@ -90,14 +104,17 @@ public class Activator implements BundleActivator {
             LogReaderService reader = (LogReaderService) service;
             reader.removeLogListener(this.listener);
         }
-
+        if (this.shutdownHandler != null) {
+            Runtime.getRuntime().removeShutdownHook(this.shutdownHandler);
+        }
         this.listener = null;
         this.log = null;
+        this.shutdownHandler = null;
     }
 
-    private class shutdownHandler extends Thread {
+    private class ShutdownHandler extends Thread {
         BundleContext bundlecontext;
-        public shutdownHandler(BundleContext ctxt) {
+        public ShutdownHandler(BundleContext ctxt) {
                 this.bundlecontext = ctxt;
         }
 
diff --git a/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java b/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java
deleted file mode 100644 (file)
index 6fe9c44..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.opendaylight.controller.logging.bridge.internal;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class UncaughtExceptionHandler implements Thread.UncaughtExceptionHandler{
-        private static Logger log = LoggerFactory.getLogger(UncaughtExceptionHandler.class);
-
-        public void uncaughtException (Thread t, Throwable e) {
-                log.error("Uncaught ExceptionHandler:", e);
-        }
-}
diff --git a/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionPolicy.java b/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionPolicy.java
new file mode 100644 (file)
index 0000000..0545578
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.logging.bridge.internal;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+enum UncaughtExceptionPolicy implements Thread.UncaughtExceptionHandler {
+    ABORT {
+        public static final int EXIT_CODE = 1;
+
+        @Override
+        public void uncaughtException(final Thread t, final Throwable e) {
+            log.error("Thread {} died because of an uncaught exception, forcing virtual machine shutdown", t, e);
+            System.exit(EXIT_CODE);
+        }
+    },
+    IGNORE {
+        @Override
+        public void uncaughtException(final Thread t, final Throwable e) {
+            log.error("Thread {} died because of an uncaught exception", t, e);
+        }
+    };
+
+    private static final Logger log = LoggerFactory.getLogger(UncaughtExceptionPolicy.class);
+}
index 5640858d516c341c9dd167fe43fe321a00fc3220..834e0a78358fa9cc55a5b419abc04f2e4fdeba87 100644 (file)
@@ -6,6 +6,7 @@ module opendaylight-group-statistics {
     import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
     import opendaylight-group-types {prefix group-types;revision-date "2013-10-18";}
     import flow-capable-transaction {prefix tr;}
+    import flow-node-inventory {prefix fni;}
     
     contact
         "Anilkumar Vishnoi
@@ -22,7 +23,7 @@ module opendaylight-group-statistics {
         }
        }    
     
-    augment "/inv:nodes/inv:node/group-types:group" {
+    augment "/inv:nodes/inv:node/fni:group" {
         ext:augment-identifier "node-group-statistics";
         uses group-statistics;
     }
index 34f131c678e15ab3ca0609ff6d4c73e1b41fd118..d91564ba0ba3a6b70292f83e028debeb318ce261 100644 (file)
                     <instructions>
                         <Bundle-Activator>org.opendaylight.controller.netconf.osgi.NetconfSSHActivator</Bundle-Activator>
                         <Import-Package>
+                            com.google.common.base,
                             ch.ethz.ssh2,
                             ch.ethz.ssh2.signature,
+                            org.apache.commons.io,
                             org.opendaylight.controller.netconf.util.osgi,
                             org.opendaylight.controller.usermanager,
                             org.opendaylight.controller.sal.authorization,
+                            org.opendaylight.controller.sal.utils,
                             org.osgi.framework,
                             org.osgi.util.tracker,
                             org.slf4j,