Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 26282 invoked from network); 10 Jun 2006 23:47:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Jun 2006 23:47:51 -0000 Received: (qmail 43131 invoked by uid 500); 10 Jun 2006 23:47:50 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 43123 invoked by uid 500); 10 Jun 2006 23:47:50 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 43112 invoked by uid 99); 10 Jun 2006 23:47:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jun 2006 16:47:50 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jun 2006 16:47:49 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 516FB1A983A; Sat, 10 Jun 2006 16:47:29 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r413386 - /geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Date: Sat, 10 Jun 2006 23:47:28 -0000 To: scm@geronimo.apache.org From: kevan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060610234729.516FB1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: kevan Date: Sat Jun 10 16:47:28 2006 New Revision: 413386 URL: http://svn.apache.org/viewvc?rev=413386&view=rev Log: GERONIMO-2078 Insure configuration files are cleaned up, if service deployment fails Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=413386&r1=413385&r2=413386&view=diff ============================================================================== --- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original) +++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Sat Jun 10 16:47:28 2006 @@ -228,23 +228,25 @@ throw new DeploymentException(e); } - ConfigurationManager configurationManager = this.configurationManager; - if (configurationManager == null) { - configurationManager = new SimpleConfigurationManager(configurationStores, artifactResolver, repositories); - } - DeploymentContext context = new DeploymentContext(outfile, - inPlaceDeployment && null != jar ? DeploymentUtil.toFile(jar) : null, - environment, - ConfigurationModuleType.SERVICE, - naming, - configurationManager, - repositories - ); - if(jar != null) { - File file = new File(jar.getName()); - context.addIncludeAsPackedJar(URI.create(file.getName()), jar); - } + DeploymentContext context = null; try { + ConfigurationManager configurationManager = this.configurationManager; + if (configurationManager == null) { + configurationManager = new SimpleConfigurationManager(configurationStores, artifactResolver, repositories); + } + + context = new DeploymentContext(outfile, + inPlaceDeployment && null != jar ? DeploymentUtil.toFile(jar) : null, + environment, + ConfigurationModuleType.SERVICE, + naming, + configurationManager, + repositories); + if(jar != null) { + File file = new File(jar.getName()); + context.addIncludeAsPackedJar(URI.create(file.getName()), jar); + } + ClassLoader cl = context.getClassLoader(); @@ -253,13 +255,34 @@ addGBeans(gbeans, cl, moduleName, context); return context; - } catch (RuntimeException t) { - context.close(); - throw t; + } catch (DeploymentException de) { + cleanupAfterFailedBuild(context, outfile); + throw de; + } catch (IOException ie) { + cleanupAfterFailedBuild(context, outfile); + throw ie; + } catch (RuntimeException re) { + cleanupAfterFailedBuild(context, outfile); + throw re; } catch (Error e) { - context.close(); + cleanupAfterFailedBuild(context, outfile); throw e; - } + } + } + + private void cleanupAfterFailedBuild(DeploymentContext context, File directory) { + try { + if (context !=null) { + context.close(); + } + } catch (DeploymentException de) { + // ignore error on cleanup + } catch (IOException ioe) { + // ignore error on cleanu + } + if (directory != null) { + DeploymentUtil.recursiveDelete(directory); + } } public static void addGBeans(GbeanType[] gbeans, ClassLoader cl, AbstractName moduleName, DeploymentContext context) throws DeploymentException {