Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22A8D965E for ; Mon, 27 Feb 2012 07:25:53 +0000 (UTC) Received: (qmail 86368 invoked by uid 500); 27 Feb 2012 07:25:52 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 86118 invoked by uid 500); 27 Feb 2012 07:25:46 -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 86090 invoked by uid 99); 27 Feb 2012 07:25:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2012 07:25:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2012 07:25:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 45A3323889C5; Mon, 27 Feb 2012 07:25:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1294046 - /geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Date: Mon, 27 Feb 2012 07:25:22 -0000 To: scm@geronimo.apache.org From: johnxiao@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120227072522.45A3323889C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: johnxiao Date: Mon Feb 27 07:25:21 2012 New Revision: 1294046 URL: http://svn.apache.org/viewvc?rev=1294046&view=rev Log: GERONIMO-6224 NPE while accessing the system modules portlet Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=1294046&r1=1294045&r2=1294046&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Mon Feb 27 07:25:21 2012 @@ -498,7 +498,7 @@ public class SimpleConfigurationManager return configuration; } - protected List buildAllServiceParents(Map loadedConfigurations, DependencyNode dependencyNode) throws InvalidConfigException { + protected List buildAllServiceParents(Map loadedConfigurations, DependencyNode dependencyNode) throws InvalidConfigException, MissingDependencyException { List allServiceParents = new ArrayList(); for (Artifact parentId : dependencyNode.getServiceParents()) { addDepthFirstServiceParents(parentId, allServiceParents, new HashSet(), loadedConfigurations); @@ -512,9 +512,14 @@ public class SimpleConfigurationManager return dependencyNode; } - private void addDepthFirstServiceParents(Artifact id, List ancestors, Set ids, Map loadedConfigurations) throws InvalidConfigException { + private void addDepthFirstServiceParents(Artifact id, List ancestors, Set ids, Map loadedConfigurations) throws InvalidConfigException, MissingDependencyException { if (!ids.contains(id)) { - Configuration configuration = getConfiguration(id, loadedConfigurations); + Configuration configuration = null; + try { + configuration = getConfiguration(id, loadedConfigurations); + } catch (InvalidConfigException e) { + throw new MissingDependencyException(id); + } ancestors.add(configuration); ids.add(id); for (Artifact parentId : configuration.getDependencyNode().getServiceParents()) { @@ -936,7 +941,9 @@ public class SimpleConfigurationManager LifecycleResults results = new LifecycleResults(); for (Artifact configurationId : unloadList) { Configuration configuration = getConfiguration(configurationId); - + + if(configuration == null) throw new NoSuchConfigException(configurationId); + // first make sure it is stopped if (started.contains(configurationId)) { monitor.stopping(configurationId); @@ -959,6 +966,11 @@ public class SimpleConfigurationManager try { Bundle bundle = bundles.remove(configurationId); + if(bundle == null) { + // Attempt to get the bundle from framework directly + bundle = attemptGetBundleByLocation(configurationId, monitor); + } + if (bundle != null) { if (BundleUtils.canStop(bundle)) { bundle.stop(Bundle.STOP_TRANSIENT); @@ -975,7 +987,34 @@ public class SimpleConfigurationManager monitor.finished(); return results; } - + /** + * Attempt to get the bundle by searching the bundle's location in all bundles in framework + * + * @param artifact + * @param monitor + * @return + * @throws NoSuchConfigException + * @throws IOException + * @throws InvalidConfigException + */ + protected Bundle attemptGetBundleByLocation(Artifact artifact, LifecycleMonitor monitor) { + String artifactLoc = ""; + try { + artifactLoc = locateBundle(artifact, monitor); + } catch (Exception e) { + // Because just attempt to get, so ignore + return null; + } + + Bundle[] bundles = this.bundleContext.getBundles(); + + for(Bundle bundle : bundles) { + if(artifactLoc.equals(bundle.getLocation())) return bundle; + } + + return null; + } + protected void removeConfigurationFromModel(Artifact configurationId) throws NoSuchConfigException { if (configurationModel.containsConfiguration(configurationId)) { configurationModel.removeConfiguration(configurationId);