From 753f0ee6bf24ff6d84a11c073a51647c0b3a7c0a Mon Sep 17 00:00:00 2001
From: Gregor Maier <gregor.maier@bigswitch.com>
Date: Mon, 17 Jun 2013 15:12:27 -0700
Subject: [PATCH] Don't use printStackTrace() on exceptions.

---
 .../firewall/FirewallResource.java            | 37 ++++-----
 .../firewall/FirewallRulesResource.java       | 82 +++++++++----------
 .../NotificationManagerFactory.java           |  8 +-
 .../web/StaticFlowEntryPusherResource.java    | 22 +++--
 .../openflow/protocol/OFMatchBeanInfo.java    | 27 +++---
 .../core/internal/OFChannelHandlerTest.java   |  1 -
 .../core/util/SingletonTaskTest.java          | 53 ++++++------
 .../debugevent/DebugEventTest.java            | 18 ++--
 .../firewall/FirewallTest.java                | 44 +++++-----
 9 files changed, 137 insertions(+), 155 deletions(-)

diff --git a/src/main/java/net/floodlightcontroller/firewall/FirewallResource.java b/src/main/java/net/floodlightcontroller/firewall/FirewallResource.java
index 2f731db49..03f9baef2 100644
--- a/src/main/java/net/floodlightcontroller/firewall/FirewallResource.java
+++ b/src/main/java/net/floodlightcontroller/firewall/FirewallResource.java
@@ -1,14 +1,14 @@
 /**
  *    Copyright 2011, Big Switch Networks, Inc.
  *    Originally created by Amer Tahir
- *    
- *    Licensed under the Apache License, Version 2.0 (the "License"); you may 
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License"); you may
  *    not use this file except in compliance with the License. You may obtain
  *    a copy of the License at
- *    
- *         http://www.apache.org/licenses/LICENSE-2.0 
- *    
- *    Unless required by applicable law or agreed to in writing, software 
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
  *    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  *    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  *    License for the specific language governing permissions and limitations
@@ -31,10 +31,10 @@ import org.slf4j.LoggerFactory;
 
 public class FirewallResource extends ServerResource {
     protected static Logger log = LoggerFactory.getLogger(FirewallResource.class);
-    
+
     @Get("json")
     public Object handleRequest() {
-        IFirewallService firewall = 
+        IFirewallService firewall =
                 (IFirewallService)getContext().getAttributes().
                 get(IFirewallService.class.getCanonicalName());
 
@@ -52,20 +52,20 @@ public class FirewallResource extends ServerResource {
         if (op.equalsIgnoreCase("enable")) {
             firewall.enableFirewall(true);
             return "{\"status\" : \"success\", \"details\" : \"firewall running\"}";
-        } 
-        
+        }
+
         // REST API disable firewall
         if (op.equalsIgnoreCase("disable")) {
             firewall.enableFirewall(false);
             return "{\"status\" : \"success\", \"details\" : \"firewall stopped\"}";
-        } 
-        
+        }
+
         // REST API retrieving rules from storage
         // currently equivalent to /wm/firewall/rules/json
         if (op.equalsIgnoreCase("storageRules")) {
             return firewall.getStorageRules();
-        } 
-        
+        }
+
         // REST API set local subnet mask -- this only makes sense for one subnet
         // will remove later
         if (op.equalsIgnoreCase("subnet-mask")) {
@@ -75,7 +75,7 @@ public class FirewallResource extends ServerResource {
         // no known options found
         return "{\"status\" : \"failure\", \"details\" : \"invalid operation\"}";
     }
-    
+
     /**
      * Allows setting of subnet mask
      * @param fmJson The Subnet Mask in JSON format.
@@ -83,7 +83,7 @@ public class FirewallResource extends ServerResource {
      */
     @Post
     public String handlePost(String fmJson) {
-        IFirewallService firewall = 
+        IFirewallService firewall =
                 (IFirewallService)getContext().getAttributes().
                 get(IFirewallService.class.getCanonicalName());
 
@@ -92,13 +92,12 @@ public class FirewallResource extends ServerResource {
             newMask = jsonExtractSubnetMask(fmJson);
         } catch (IOException e) {
             log.error("Error parsing new subnet mask: " + fmJson, e);
-            e.printStackTrace();
             return "{\"status\" : \"Error! Could not parse new subnet mask, see log for details.\"}";
         }
         firewall.setSubnetMask(newMask);
         return ("{\"status\" : \"subnet mask set\"}");
     }
-    
+
     /**
      * Extracts subnet mask from a JSON string
      * @param fmJson The JSON formatted string
@@ -128,7 +127,7 @@ public class FirewallResource extends ServerResource {
 
             String n = jp.getCurrentName();
             jp.nextToken();
-            if (jp.getText().equals("")) 
+            if (jp.getText().equals(""))
                 continue;
 
             if (n == "subnet-mask") {
diff --git a/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java b/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java
index b72f983dd..db83c4a21 100644
--- a/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java
+++ b/src/main/java/net/floodlightcontroller/firewall/FirewallRulesResource.java
@@ -1,14 +1,14 @@
 /**
  *    Copyright 2011, Big Switch Networks, Inc.
  *    Originally created by Amer Tahir
- *    
- *    Licensed under the Apache License, Version 2.0 (the "License"); you may 
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License"); you may
  *    not use this file except in compliance with the License. You may obtain
  *    a copy of the License at
- *    
- *         http://www.apache.org/licenses/LICENSE-2.0 
- *    
- *    Unless required by applicable law or agreed to in writing, software 
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
  *    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  *    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  *    License for the specific language governing permissions and limitations
@@ -41,7 +41,7 @@ public class FirewallRulesResource extends ServerResource {
 
     @Get("json")
     public List<FirewallRule> retrieve() {
-        IFirewallService firewall = 
+        IFirewallService firewall =
                 (IFirewallService)getContext().getAttributes().
                 get(IFirewallService.class.getCanonicalName());
 
@@ -56,7 +56,7 @@ public class FirewallRulesResource extends ServerResource {
      */
     @Post
     public String store(String fmJson) {
-        IFirewallService firewall = 
+        IFirewallService firewall =
                 (IFirewallService)getContext().getAttributes().
                 get(IFirewallService.class.getCanonicalName());
 
@@ -65,7 +65,6 @@ public class FirewallRulesResource extends ServerResource {
             rule = jsonToFirewallRule(fmJson);
         } catch (IOException e) {
             log.error("Error parsing firewall rule: " + fmJson, e);
-            e.printStackTrace();
             return "{\"status\" : \"Error! Could not parse firewall rule, see log for details.\"}";
         }
         String status = null;
@@ -86,10 +85,10 @@ public class FirewallRulesResource extends ServerResource {
      * @param fmJson The Firewall rule entry in JSON format.
      * @return A string status message
      */
-    
+
     @Delete
     public String remove(String fmJson) {
-        IFirewallService firewall = 
+        IFirewallService firewall =
                 (IFirewallService)getContext().getAttributes().
                 get(IFirewallService.class.getCanonicalName());
 
@@ -98,7 +97,6 @@ public class FirewallRulesResource extends ServerResource {
             rule = jsonToFirewallRule(fmJson);
         } catch (IOException e) {
             log.error("Error parsing firewall rule: " + fmJson, e);
-            e.printStackTrace();
             return "{\"status\" : \"Error! Could not parse firewall rule, see log for details.\"}";
         }
         String status = null;
@@ -128,7 +126,7 @@ public class FirewallRulesResource extends ServerResource {
      * @return The FirewallRule instance
      * @throws IOException If there was an error parsing the JSON
      */
-     
+
     public static FirewallRule jsonToFirewallRule(String fmJson) throws IOException {
         FirewallRule rule = new FirewallRule();
         MappingJsonFactory f = new MappingJsonFactory();
@@ -152,47 +150,47 @@ public class FirewallRulesResource extends ServerResource {
 
             String n = jp.getCurrentName();
             jp.nextToken();
-            if (jp.getText().equals("")) 
+            if (jp.getText().equals(""))
                 continue;
 
             String tmp;
-            
+
             // This is currently only applicable for remove().  In store(), ruleid takes a random number
             if (n == "ruleid") {
-                rule.ruleid = Integer.parseInt((String)jp.getText());
+                rule.ruleid = Integer.parseInt(jp.getText());
             }
-            
+
             // This assumes user having dpid info for involved switches
             else if (n == "switchid") {
                 tmp = jp.getText();
                 if (tmp.equalsIgnoreCase("-1") == false) {
-                    // user inputs hex format dpid 
-                    rule.dpid = HexString.toLong(tmp);                    
+                    // user inputs hex format dpid
+                    rule.dpid = HexString.toLong(tmp);
                     rule.wildcard_dpid = false;
                 }
-            } 
-            
+            }
+
             else if (n == "src-inport") {
                 rule.in_port = Short.parseShort(jp.getText());
                 rule.wildcard_in_port = false;
-            } 
-            
+            }
+
             else if (n == "src-mac") {
                 tmp = jp.getText();
                 if (tmp.equalsIgnoreCase("ANY") == false) {
                     rule.wildcard_dl_src = false;
                     rule.dl_src = Ethernet.toLong(Ethernet.toMACAddress(tmp));
                 }
-            } 
-            
+            }
+
             else if (n == "dst-mac") {
                 tmp = jp.getText();
                 if (tmp.equalsIgnoreCase("ANY") == false) {
                     rule.wildcard_dl_dst = false;
                     rule.dl_dst = Ethernet.toLong(Ethernet.toMACAddress(tmp));
                 }
-            } 
-            
+            }
+
             else if (n == "dl-type") {
                 tmp = jp.getText();
                 if (tmp.equalsIgnoreCase("ARP")) {
@@ -203,8 +201,8 @@ public class FirewallRulesResource extends ServerResource {
                     rule.wildcard_dl_type = false;
                     rule.dl_type = Ethernet.TYPE_IPv4;
                 }
-            } 
-            
+            }
+
             else if (n == "src-ip") {
                 tmp = jp.getText();
                 if (tmp.equalsIgnoreCase("ANY") == false) {
@@ -215,8 +213,8 @@ public class FirewallRulesResource extends ServerResource {
                     rule.nw_src_prefix = cidr[0];
                     rule.nw_src_maskbits = cidr[1];
                 }
-            } 
-            
+            }
+
             else if (n == "dst-ip") {
                 tmp = jp.getText();
                 if (tmp.equalsIgnoreCase("ANY") == false) {
@@ -227,8 +225,8 @@ public class FirewallRulesResource extends ServerResource {
                     rule.nw_dst_prefix = cidr[0];
                     rule.nw_dst_maskbits = cidr[1];
                 }
-            } 
-            
+            }
+
             else if (n == "nw-proto") {
                 tmp = jp.getText();
                 if (tmp.equalsIgnoreCase("TCP")) {
@@ -246,23 +244,23 @@ public class FirewallRulesResource extends ServerResource {
                     rule.nw_proto = IPv4.PROTOCOL_ICMP;
                     rule.wildcard_dl_type = false;
                     rule.dl_type = Ethernet.TYPE_IPv4;
-                } 
-            } 
-            
+                }
+            }
+
             else if (n == "tp-src") {
                 rule.wildcard_tp_src = false;
                 rule.tp_src = Short.parseShort(jp.getText());
-            } 
-            
+            }
+
             else if (n == "tp-dst") {
                 rule.wildcard_tp_dst = false;
                 rule.tp_dst = Short.parseShort(jp.getText());
-            } 
-            
+            }
+
             else if (n == "priority") {
                 rule.priority = Integer.parseInt(jp.getText());
-            } 
-            
+            }
+
             else if (n == "action") {
                 if (jp.getText().equalsIgnoreCase("allow") == true) {
                     rule.action = FirewallRule.FirewallAction.ALLOW;
diff --git a/src/main/java/net/floodlightcontroller/notification/NotificationManagerFactory.java b/src/main/java/net/floodlightcontroller/notification/NotificationManagerFactory.java
index 212c37a41..1e596a9d2 100644
--- a/src/main/java/net/floodlightcontroller/notification/NotificationManagerFactory.java
+++ b/src/main/java/net/floodlightcontroller/notification/NotificationManagerFactory.java
@@ -37,7 +37,7 @@ public class NotificationManagerFactory {
             notificationfactoryClassName =
                     System.getProperty(NOTIFICATION_FACTORY_NAME);
         } catch (SecurityException e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         if (notificationfactoryClassName != null) {
             Class<?> nfc;
@@ -45,11 +45,11 @@ public class NotificationManagerFactory {
                 nfc = Class.forName(notificationfactoryClassName);
                 factory = (INotificationManagerFactory) nfc.newInstance();
             } catch (ClassNotFoundException e) {
-                e.printStackTrace();
+                throw new RuntimeException(e);
             } catch (InstantiationException e) {
-                e.printStackTrace();
+                throw new RuntimeException(e);
             } catch (IllegalAccessException e) {
-                e.printStackTrace();
+                throw new RuntimeException(e);
             }
          }
     }
diff --git a/src/main/java/net/floodlightcontroller/staticflowentry/web/StaticFlowEntryPusherResource.java b/src/main/java/net/floodlightcontroller/staticflowentry/web/StaticFlowEntryPusherResource.java
index 3b750ae35..8048fe183 100644
--- a/src/main/java/net/floodlightcontroller/staticflowentry/web/StaticFlowEntryPusherResource.java
+++ b/src/main/java/net/floodlightcontroller/staticflowentry/web/StaticFlowEntryPusherResource.java
@@ -1,7 +1,7 @@
 /**
-*    Copyright 2011, Big Switch Networks, Inc. 
+*    Copyright 2011, Big Switch Networks, Inc.
 *    Originally created by David Erickson, Stanford University
-* 
+*
 *    Licensed under the Apache License, Version 2.0 (the "License"); you may
 *    not use this file except in compliance with the License. You may obtain
 *    a copy of the License at
@@ -41,7 +41,7 @@ import net.floodlightcontroller.storage.IStorageSourceService;
 @LogMessageCategory("Static Flow Pusher")
 public class StaticFlowEntryPusherResource extends ServerResource {
     protected static Logger log = LoggerFactory.getLogger(StaticFlowEntryPusherResource.class);
-    
+
     /**
      * Checks to see if the user matches IP information without
      * checking for the correct ether-type (2048).
@@ -64,17 +64,17 @@ public class StaticFlowEntryPusherResource extends ServerResource {
             }
             if (type == 2048) matchEther = true;
         }
-        
-        if ((rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_DST) || 
+
+        if ((rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_DST) ||
                 rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_SRC) ||
                 rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_PROTO) ||
                 rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_TOS)) &&
                 (matchEther == false))
             return false;
-        
+
         return true;
     }
-    
+
     /**
      * Takes a Static Flow Pusher string in JSON format and parses it into
      * our database schema then pushes it to the database.
@@ -90,7 +90,7 @@ public class StaticFlowEntryPusherResource extends ServerResource {
         IStorageSourceService storageSource =
                 (IStorageSourceService)getContext().getAttributes().
                     get(IStorageSourceService.class.getCanonicalName());
-        
+
         Map<String, Object> rowValues;
         try {
             rowValues = StaticFlowEntries.jsonToStorageEntry(fmJson);
@@ -107,11 +107,10 @@ public class StaticFlowEntryPusherResource extends ServerResource {
             return ("{\"status\" : \"" + status + "\"}");
         } catch (IOException e) {
             log.error("Error parsing push flow mod request: " + fmJson, e);
-            e.printStackTrace();
             return "{\"status\" : \"Error! Could not parse flod mod, see log for details.\"}";
         }
     }
-    
+
     @Delete
     @LogMessageDoc(level="ERROR",
         message="Error deleting flow mod request: {request}",
@@ -132,10 +131,9 @@ public class StaticFlowEntryPusherResource extends ServerResource {
             }
         } catch (IOException e) {
             log.error("Error deleting flow mod request: " + fmJson, e);
-            e.printStackTrace();
             return "{\"status\" : \"Error deleting entry, see log for details\"}";
         }
-        
+
         storageSource.deleteRowAsync(StaticFlowEntryPusher.TABLE_NAME, fmName);
         return "{\"status\" : \"Entry " + fmName + " deleted\"}";
     }
diff --git a/src/main/java/org/openflow/protocol/OFMatchBeanInfo.java b/src/main/java/org/openflow/protocol/OFMatchBeanInfo.java
index 16a813f1e..97e14a559 100644
--- a/src/main/java/org/openflow/protocol/OFMatchBeanInfo.java
+++ b/src/main/java/org/openflow/protocol/OFMatchBeanInfo.java
@@ -1,7 +1,7 @@
 /**
 *    Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
 *    University
-* 
+*
 *    Licensed under the Apache License, Version 2.0 (the "License"); you may
 *    not use this file except in compliance with the License. You may obtain
 *    a copy of the License at
@@ -28,12 +28,12 @@ import java.util.List;
 
 /**
  * Extra info for how to treat OFMatch as a JavaBean
- * 
+ *
  * For some (inane!) reason, using chained setters in OFMatch breaks a lot of the JavaBean defaults.
- * 
+ *
  * We don't really use OFMatch as a java bean, but there are a lot of nice XML utils that work for
  * free if OFMatch follows the java bean paradigm.
- * 
+ *
  * @author Rob Sherwood (rob.sherwood@stanford.edu)
  *
  */
@@ -47,23 +47,22 @@ public class OFMatchBeanInfo extends SimpleBeanInfo {
         String name;
         for (int i=0; i< fields.length; i++) {
             int mod = fields[i].getModifiers();
-            if(Modifier.isFinal(mod) ||     // don't expose static or final fields 
+            if(Modifier.isFinal(mod) ||     // don't expose static or final fields
                     Modifier.isStatic(mod))
                 continue;
-            
+
             name = fields[i].getName();
             Class<?> type = fields[i].getType();
-            
+
             try {
-                descs.add(new PropertyDescriptor(name, 
-                        name2getter(OFMatch.class, name), 
+                descs.add(new PropertyDescriptor(name,
+                        name2getter(OFMatch.class, name),
                         name2setter(OFMatch.class, name, type)));
             } catch (IntrospectionException e) {
-                e.printStackTrace();
                 throw new RuntimeException(e);
             }
         }
-        
+
         return descs.toArray(new PropertyDescriptor[0]);
     }
 
@@ -74,10 +73,8 @@ public class OFMatchBeanInfo extends SimpleBeanInfo {
         try {
             m = c.getMethod(mName, new Class[]{ type});
         } catch (SecurityException e) {
-            e.printStackTrace();
             throw new RuntimeException(e);
         } catch (NoSuchMethodException e) {
-            e.printStackTrace();
             throw new RuntimeException(e);
         }
         return m;
@@ -89,15 +86,13 @@ public class OFMatchBeanInfo extends SimpleBeanInfo {
         try {
             m = c.getMethod(mName, new Class[]{});
         } catch (SecurityException e) {
-            e.printStackTrace();
             throw new RuntimeException(e);
         } catch (NoSuchMethodException e) {
-            e.printStackTrace();
             throw new RuntimeException(e);
         }
         return m;
     }
-    
+
     private String toLeadingCaps(String s) {
         char[] array = s.toCharArray();
         array[0] = Character.toUpperCase(array[0]);
diff --git a/src/test/java/net/floodlightcontroller/core/internal/OFChannelHandlerTest.java b/src/test/java/net/floodlightcontroller/core/internal/OFChannelHandlerTest.java
index ca1384103..19b817c58 100644
--- a/src/test/java/net/floodlightcontroller/core/internal/OFChannelHandlerTest.java
+++ b/src/test/java/net/floodlightcontroller/core/internal/OFChannelHandlerTest.java
@@ -163,7 +163,6 @@ public class OFChannelHandlerTest {
         /* ensure no exception was thrown */
         if (exceptionEventCapture.hasCaptured()) {
             Throwable ex = exceptionEventCapture.getValue().getCause();
-            ex.printStackTrace();
             throw new AssertionError("Unexpected exception: " +
                        ex.getClass().getName() + "(" + ex + ")");
         }
diff --git a/src/test/java/net/floodlightcontroller/core/util/SingletonTaskTest.java b/src/test/java/net/floodlightcontroller/core/util/SingletonTaskTest.java
index 8203161d9..fa04b7414 100644
--- a/src/test/java/net/floodlightcontroller/core/util/SingletonTaskTest.java
+++ b/src/test/java/net/floodlightcontroller/core/util/SingletonTaskTest.java
@@ -1,7 +1,7 @@
 /**
-*    Copyright 2011, Big Switch Networks, Inc. 
+*    Copyright 2011, Big Switch Networks, Inc.
 *    Originally created by David Erickson, Stanford University
-* 
+*
 *    Licensed under the Apache License, Version 2.0 (the "License"); you may
 *    not use this file except in compliance with the License. You may obtain
 *    a copy of the License at
@@ -27,25 +27,26 @@ import org.junit.Test;
 import net.floodlightcontroller.test.FloodlightTestCase;
 
 public class SingletonTaskTest extends FloodlightTestCase {
-    
+
     public int ran = 0;
     public int finished = 0;
     public long time = 0;
-    
+
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
-        
+
         ran = 0;
         finished = 0;
         time = 0;
     }
-    
+
     @Test
     public void testBasic() throws InterruptedException {
-        ScheduledExecutorService ses = 
+        ScheduledExecutorService ses =
             Executors.newSingleThreadScheduledExecutor();
-        
+
         SingletonTask st1 = new SingletonTask(ses, new Runnable() {
             @Override
             public void run() {
@@ -55,13 +56,13 @@ public class SingletonTaskTest extends FloodlightTestCase {
         st1.reschedule(0, null);
         ses.shutdown();
         ses.awaitTermination(5, TimeUnit.SECONDS);
-        
+
         assertEquals("Check that task ran", 1, ran);
     }
 
     @Test
     public void testDelay() throws InterruptedException {
-        ScheduledExecutorService ses = 
+        ScheduledExecutorService ses =
             Executors.newSingleThreadScheduledExecutor();
 
         SingletonTask st1 = new SingletonTask(ses, new Runnable() {
@@ -74,10 +75,10 @@ public class SingletonTaskTest extends FloodlightTestCase {
         long start = System.nanoTime();
         st1.reschedule(10, TimeUnit.MILLISECONDS);
         assertFalse("Check that task hasn't run yet", ran > 0);
-        
+
         ses.shutdown();
         ses.awaitTermination(5, TimeUnit.SECONDS);
-        
+
         assertEquals("Check that task ran", 1, ran);
         assertTrue("Check that time passed appropriately",
                    (time - start) >= TimeUnit.NANOSECONDS.convert(10, TimeUnit.MILLISECONDS));
@@ -85,7 +86,7 @@ public class SingletonTaskTest extends FloodlightTestCase {
 
     @Test
     public void testReschedule() throws InterruptedException {
-        ScheduledExecutorService ses = 
+        ScheduledExecutorService ses =
             Executors.newSingleThreadScheduledExecutor();
 
         final Object tc = this;
@@ -123,10 +124,10 @@ public class SingletonTaskTest extends FloodlightTestCase {
         st1.reschedule(20, TimeUnit.MILLISECONDS);
         Thread.sleep(5);
         assertFalse("Check that task hasn't run yet", ran > 0);
-        
+
         ses.shutdown();
         ses.awaitTermination(5, TimeUnit.SECONDS);
-        
+
         assertEquals("Check that task ran only once", 1, ran);
         assertTrue("Check that time passed appropriately: " + (time - start),
                 (time - start) >= TimeUnit.NANOSECONDS.convert(55, TimeUnit.MILLISECONDS));
@@ -134,7 +135,7 @@ public class SingletonTaskTest extends FloodlightTestCase {
 
     @Test
     public void testConcurrentAddDelay() throws InterruptedException {
-        ScheduledExecutorService ses = 
+        ScheduledExecutorService ses =
             Executors.newSingleThreadScheduledExecutor();
 
         final Object tc = this;
@@ -155,7 +156,7 @@ public class SingletonTaskTest extends FloodlightTestCase {
                 }
             }
         });
-        
+
         long start = System.nanoTime();
         st1.reschedule(5, TimeUnit.MILLISECONDS);
         Thread.sleep(20);
@@ -173,19 +174,19 @@ public class SingletonTaskTest extends FloodlightTestCase {
         assertTrue("Check task should run state false", !st1.context.taskShouldRun);
         assertEquals("Check that task ran exactly twice", 2, ran);
         assertEquals("Check that task finished exactly twice", 2, finished);
-        
+
         assertTrue("Check that time passed appropriately: " + (time - start),
                 (time - start) >= TimeUnit.NANOSECONDS.convert(130, TimeUnit.MILLISECONDS));
         assertTrue("Check that time passed appropriately: " + (time - start),
                 (time - start) <= TimeUnit.NANOSECONDS.convert(160, TimeUnit.MILLISECONDS));
-        
+
         ses.shutdown();
         ses.awaitTermination(5, TimeUnit.SECONDS);
     }
 
     @Test
     public void testConcurrentAddDelay2() throws InterruptedException {
-        ScheduledExecutorService ses = 
+        ScheduledExecutorService ses =
             Executors.newSingleThreadScheduledExecutor();
 
         final Object tc = this;
@@ -225,12 +226,12 @@ public class SingletonTaskTest extends FloodlightTestCase {
         assertTrue("Check task should run state false", !st1.context.taskShouldRun);
         assertEquals("Check that task ran exactly twice", 2, ran);
         assertEquals("Check that task finished exactly twice", 2, finished);
-        
+
         assertTrue("Check that time passed appropriately: " + (time - start),
                 (time - start) >= TimeUnit.NANOSECONDS.convert(100, TimeUnit.MILLISECONDS));
         assertTrue("Check that time passed appropriately: " + (time - start),
                 (time - start) <= TimeUnit.NANOSECONDS.convert(125, TimeUnit.MILLISECONDS));
-        
+
         ses.shutdown();
         ses.awaitTermination(5, TimeUnit.SECONDS);
     }
@@ -238,7 +239,7 @@ public class SingletonTaskTest extends FloodlightTestCase {
 
     @Test
     public void testConcurrentAddNoDelay() throws InterruptedException {
-        ScheduledExecutorService ses = 
+        ScheduledExecutorService ses =
             Executors.newSingleThreadScheduledExecutor();
 
         final Object tc = this;
@@ -260,7 +261,7 @@ public class SingletonTaskTest extends FloodlightTestCase {
                 }
             }
         });
-        
+
         long start = System.nanoTime();
         st1.reschedule(0, null);
         Thread.sleep(20);
@@ -278,12 +279,12 @@ public class SingletonTaskTest extends FloodlightTestCase {
         assertTrue("Check task should run state false", !st1.context.taskShouldRun);
         assertEquals("Check that task ran exactly twice", 2, ran);
         assertEquals("Check that task finished exactly twice", 2, finished);
-        
+
         assertTrue("Check that time passed appropriately: " + (time - start),
                 (time - start) >= TimeUnit.NANOSECONDS.convert(90, TimeUnit.MILLISECONDS));
         assertTrue("Check that time passed appropriately: " + (time - start),
                 (time - start) <= TimeUnit.NANOSECONDS.convert(130, TimeUnit.MILLISECONDS));
-        
+
         ses.shutdown();
         ses.awaitTermination(5, TimeUnit.SECONDS);
     }
diff --git a/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java b/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java
index 175b3d0d1..5fbaba9d4 100644
--- a/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java
+++ b/src/test/java/net/floodlightcontroller/debugevent/DebugEventTest.java
@@ -25,20 +25,16 @@ public class DebugEventTest extends FloodlightTestCase {
 
 
     @Test
-    public void testRegisterAndUpdateEvent() {
+    public void testRegisterAndUpdateEvent() throws Exception {
         assertEquals(0, debugEvent.currentEvents.size());
         IEventUpdater<SwitchyEvent> event1 = null;
         IEventUpdater<PacketyEvent> event2 = null;
-        try {
-            event1 = debugEvent.registerEvent("dbgevtest", "switchevent",
-                                               "switchtest", EventType.ALWAYS_LOG,
-                                               SwitchyEvent.class, 100);
-            event2 = debugEvent.registerEvent("dbgevtest", "pktinevent",
-                                               "pktintest", EventType.ALWAYS_LOG,
-                                               PacketyEvent.class, 100);
-        } catch (MaxEventsRegistered e) {
-            e.printStackTrace();
-        }
+        event1 = debugEvent.registerEvent("dbgevtest", "switchevent",
+                                           "switchtest", EventType.ALWAYS_LOG,
+                                           SwitchyEvent.class, 100);
+        event2 = debugEvent.registerEvent("dbgevtest", "pktinevent",
+                                           "pktintest", EventType.ALWAYS_LOG,
+                                           PacketyEvent.class, 100);
 
         assertEquals(2, debugEvent.currentEvents.size());
         assertTrue(null != debugEvent.moduleEvents.get("dbgevtest").
diff --git a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
index 5de211420..e10d320d9 100644
--- a/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
+++ b/src/test/java/net/floodlightcontroller/firewall/FirewallTest.java
@@ -1,14 +1,14 @@
 /**
  *    Copyright 2011, Big Switch Networks, Inc.
  *    Originally created by Amer Tahir
- *    
- *    Licensed under the Apache License, Version 2.0 (the "License"); you may 
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License"); you may
  *    not use this file except in compliance with the License. You may obtain
  *    a copy of the License at
- *    
- *         http://www.apache.org/licenses/LICENSE-2.0 
- *    
- *    Unless required by applicable law or agreed to in writing, software 
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
  *    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  *    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  *    License for the specific language governing permissions and limitations
@@ -29,7 +29,6 @@ import net.floodlightcontroller.core.FloodlightContext;
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.module.FloodlightModuleException;
 import net.floodlightcontroller.packet.ARP;
 import net.floodlightcontroller.packet.Data;
 import net.floodlightcontroller.packet.Ethernet;
@@ -55,7 +54,7 @@ import org.openflow.util.HexString;
 
 /**
  * Unit test for stateless firewall implemented as a Google Summer of Code project.
- * 
+ *
  * @author Amer Tahir
  */
 public class FirewallTest extends FloodlightTestCase {
@@ -71,6 +70,7 @@ public class FirewallTest extends FloodlightTestCase {
     private Firewall firewall;
     public static String TestSwitch1DPID = "00:00:00:00:00:00:00:01";
 
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
@@ -92,17 +92,13 @@ public class FirewallTest extends FloodlightTestCase {
         mockFloodlightProvider.setSwitches(switches);
 
         FloodlightModuleContext fmc = new FloodlightModuleContext();
-        fmc.addService(IFloodlightProviderService.class, 
+        fmc.addService(IFloodlightProviderService.class,
                 mockFloodlightProvider);
         fmc.addService(IFirewallService.class, firewall);
         fmc.addService(IStorageSourceService.class, storageService);
         fmc.addService(IRestApiService.class, restApi);
 
-        try {
-            restApi.init(fmc);
-        } catch (FloodlightModuleException e) {
-            e.printStackTrace();
-        }
+        restApi.init(fmc);
 
         firewall.init(fmc);
         firewall.startUp(fmc);
@@ -122,7 +118,7 @@ public class FirewallTest extends FloodlightTestCase {
                 .setSourcePort((short) 81)
                 .setDestinationPort((short) 80)
                 .setPayload(new Data(new byte[] {0x01}))));
-        
+
         // Build a broadcast ARP packet
         this.broadcastARPPacket = new Ethernet()
         .setDestinationMACAddress("FF:FF:FF:FF:FF:FF")
@@ -141,7 +137,7 @@ public class FirewallTest extends FloodlightTestCase {
                 .setTargetHardwareAddress(Ethernet.toMACAddress("00:00:00:00:00:00"))
                 .setTargetProtocolAddress(IPv4.toIPv4Address("192.168.1.2"))
                 .setPayload(new Data(new byte[] {0x01})));
-        
+
         // Build a ARP packet
         this.ARPReplyPacket = new Ethernet()
         .setDestinationMACAddress("00:44:33:22:11:00")
@@ -160,7 +156,7 @@ public class FirewallTest extends FloodlightTestCase {
                 .setTargetHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:00"))
                 .setTargetProtocolAddress(IPv4.toIPv4Address("192.168.1.1"))
                 .setPayload(new Data(new byte[] {0x01})));
-        
+
         // Build a broadcast IP packet
         this.broadcastIPPacket = new Ethernet()
         .setDestinationMACAddress("FF:FF:FF:FF:FF:FF")
@@ -221,8 +217,8 @@ public class FirewallTest extends FloodlightTestCase {
 
         // Add the packet to the context store
         IFloodlightProviderService.bcStore.
-        put(cntx, 
-                IFloodlightProviderService.CONTEXT_PI_PAYLOAD, 
+        put(cntx,
+                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                 (Ethernet)packet);
     }
 
@@ -241,7 +237,7 @@ public class FirewallTest extends FloodlightTestCase {
         // no rules to match, so firewall should deny
         assertEquals(decision.getRoutingAction(), IRoutingDecision.RoutingAction.DROP);
     }
-    
+
     @Test
     public void testReadRulesFromStorage() throws Exception {
         // add 2 rules first
@@ -440,10 +436,10 @@ public class FirewallTest extends FloodlightTestCase {
         // broadcast-ARP traffic should be allowed
         IRoutingDecision decision = IRoutingDecision.rtStore.get(cntx, IRoutingDecision.CONTEXT_DECISION);
         assertEquals(IRoutingDecision.RoutingAction.MULTICAST, decision.getRoutingAction());
-        
+
         // clear decision
         IRoutingDecision.rtStore.remove(cntx, IRoutingDecision.CONTEXT_DECISION);
-        
+
         // simulate an ARP reply packet-in event
 
         this.setPacketIn(ARPReplyPacket);
@@ -454,12 +450,12 @@ public class FirewallTest extends FloodlightTestCase {
         decision = IRoutingDecision.rtStore.get(cntx, IRoutingDecision.CONTEXT_DECISION);
         assertEquals(decision.getRoutingAction(), IRoutingDecision.RoutingAction.DROP);
     }
-    
+
     @Test
     public void testIPBroadcast() throws Exception {
         // enable firewall first
         firewall.enableFirewall(true);
-        
+
         // set subnet mask for IP broadcast
         firewall.setSubnetMask("255.255.255.0");
 
-- 
GitLab