You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by mi...@apache.org on 2011/08/24 04:30:34 UTC

svn commit: r1160963 - /geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java

Author: michaelfang
Date: Wed Aug 24 02:30:31 2011
New Revision: 1160963

URL: http://svn.apache.org/viewvc?rev=1160963&view=rev
Log:
GERONIMO-6118 Add 'close' action to each catch block for better error handling

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=1160963&r1=1160962&r2=1160963&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Wed Aug 24 02:30:31 2011
@@ -776,21 +776,25 @@ public class EARConfigBuilder implements
 
             if (createPlanMode.get()) {
                 EARConfigBuilder.appInfo.set(applicationInfo);
-                earContext.close();
                 throw new DeploymentException();
             }
 
             // it's the caller's responsibility to close the context...
             return earContext;
         } catch (GBeanAlreadyExistsException e) {
+            cleanupContext(earContext);
             throw new DeploymentException(e);
         } catch (IOException e) {
+            cleanupContext(earContext);
             throw e;
         } catch (DeploymentException e) {
+            cleanupContext(earContext);
             throw e;
         } catch (RuntimeException e) {
+            cleanupContext(earContext);
             throw e;
         } catch (Error e) {
+            cleanupContext(earContext);
             throw e;
         } finally {
             for (Module<?, ?> module : applicationInfo.getModules()) {
@@ -799,6 +803,18 @@ public class EARConfigBuilder implements
         }
     }
 
+    private void cleanupContext(EARContext earContext) {
+        if (earContext != null) {
+            try {
+                earContext.close();
+            } catch (IOException ioe) {
+                // ignore any cleanup problems
+            } catch (DeploymentException de) {
+                // ignore any cleanup problems
+            }
+        }
+    }
+
     private String getLibraryDirectory(Application specDD) {
         if (specDD == null || specDD.getLibraryDirectory() == null) {
             //value 'lib' is used if element not set or ear does not contain a dd