[jboss-cvs] JBoss Profiler SVN: r450 - branches/JBossProfiler2/src/main/org/jboss/profiler/ant.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat May 17 12:09:31 EDT 2008


Author: jesper.pedersen
Date: 2008-05-17 12:09:31 -0400 (Sat, 17 May 2008)
New Revision: 450

Modified:
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/DisableProfilerTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/EnableProfilerTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StartProfilerTask.java
   branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StopProfilerTask.java
Log:
Ant tasks: Disconnect in finally

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/AddClassesTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -68,11 +68,12 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       if (classes != null && classes.trim().length() > 0) {
         InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
         
-        org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+        remotingClient =  new org.jboss.remoting.Client(locator);
         remotingClient.connect();
         
         StringTokenizer st = new StringTokenizer(classes, ", ");
@@ -100,11 +101,17 @@
           Command cmd = new Command(CommandType.ADD_CLASSES, new Object[] { clz, v } );
           String response = (String)remotingClient.invoke(cmd);
         }
-      
-        remotingClient.disconnect();
       }
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/ClearSnapshotsTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -46,19 +46,27 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       Command cmd = new Command(CommandType.CLEAR_SNAPSHOTS);
 
       InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
       
-      org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+      remotingClient =  new org.jboss.remoting.Client(locator);
       remotingClient.connect();
       
       String response = (String)remotingClient.invoke(cmd);
-      
-      remotingClient.disconnect();
+
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/DisableProfilerTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/DisableProfilerTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/DisableProfilerTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -46,19 +46,27 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       Command cmd = new Command(CommandType.DISABLE);
 
       InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
       
-      org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+      remotingClient =  new org.jboss.remoting.Client(locator);
       remotingClient.connect();
       
       String response = (String)remotingClient.invoke(cmd);
-      
-      remotingClient.disconnect();
+
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/EnableProfilerTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/EnableProfilerTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/EnableProfilerTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -46,19 +46,27 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       Command cmd = new Command(CommandType.ENABLE);
 
       InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
       
-      org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+      remotingClient =  new org.jboss.remoting.Client(locator);
       remotingClient.connect();
       
       String response = (String)remotingClient.invoke(cmd);
-      
-      remotingClient.disconnect();
+
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/GCTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -46,19 +46,27 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       Command cmd = new Command(CommandType.GC);
 
       InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
       
-      org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+      remotingClient = new org.jboss.remoting.Client(locator);
       remotingClient.connect();
       
       String response = (String)remotingClient.invoke(cmd);
       
-      remotingClient.disconnect();
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/RemoveClassesTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -67,11 +67,12 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       if (classes != null && classes.trim().length() > 0) {
         InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
         
-        org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+        remotingClient =  new org.jboss.remoting.Client(locator);
         remotingClient.connect();
         
         StringTokenizer st = new StringTokenizer(classes, ", ");
@@ -81,10 +82,17 @@
           String response = (String)remotingClient.invoke(cmd);
         }
       
-        remotingClient.disconnect();
       }
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/SaveTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -88,12 +88,13 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       Command cmd = new Command(CommandType.SAVE, new Object[] { Integer.valueOf(snapshot) } );
 
       InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
       
-      org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+      remotingClient =  new org.jboss.remoting.Client(locator);
       remotingClient.connect();
       
       Snapshot snapshot = (Snapshot)remotingClient.invoke(cmd);
@@ -106,9 +107,16 @@
         }
       }
       
-      remotingClient.disconnect();
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StartProfilerTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StartProfilerTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StartProfilerTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -46,19 +46,27 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       Command cmd = new Command(CommandType.START_PROFILER);
 
       InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
       
-      org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+      remotingClient =  new org.jboss.remoting.Client(locator);
       remotingClient.connect();
       
       String response = (String)remotingClient.invoke(cmd);
       
-      remotingClient.disconnect();
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StopProfilerTask.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StopProfilerTask.java	2008-05-17 16:01:42 UTC (rev 449)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ant/StopProfilerTask.java	2008-05-17 16:09:31 UTC (rev 450)
@@ -46,19 +46,27 @@
    * @exception BuildException If an error occurs
    */
   public void execute() throws BuildException {
+    org.jboss.remoting.Client remotingClient = null;
     try {
       Command cmd = new Command(CommandType.STOP_PROFILER);
 
       InvokerLocator locator = new InvokerLocator(getProtocol() + "://" + getHost() + ":" + getPort());
       
-      org.jboss.remoting.Client remotingClient =  new org.jboss.remoting.Client(locator);
+      remotingClient = new org.jboss.remoting.Client(locator);
       remotingClient.connect();
       
       String response = (String)remotingClient.invoke(cmd);
       
-      remotingClient.disconnect();
     } catch (Throwable t) {
       throw new BuildException(t.getMessage(), t);
+    } finally {
+      if (remotingClient != null) {
+        try {
+          remotingClient.disconnect();
+        } catch (Throwable it) {
+          // Ignore
+        }
+      }
     }
   }
 }




More information about the jboss-cvs-commits mailing list