Return-Path: X-Original-To: apmail-aries-dev-archive@www.apache.org Delivered-To: apmail-aries-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 51A2718BD2 for ; Wed, 24 Feb 2016 19:35:18 +0000 (UTC) Received: (qmail 71234 invoked by uid 500); 24 Feb 2016 19:35:18 -0000 Delivered-To: apmail-aries-dev-archive@aries.apache.org Received: (qmail 71187 invoked by uid 500); 24 Feb 2016 19:35:18 -0000 Mailing-List: contact dev-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list dev@aries.apache.org Received: (qmail 71175 invoked by uid 99); 24 Feb 2016 19:35:18 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Feb 2016 19:35:18 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 14E282C1F58 for ; Wed, 24 Feb 2016 19:35:18 +0000 (UTC) Date: Wed, 24 Feb 2016 19:35:18 +0000 (UTC) From: "John Ross (JIRA)" To: dev@aries.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (ARIES-1225) NPE thrown by GetBundleContextAction MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/ARIES-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] John Ross resolved ARIES-1225. ------------------------------ Resolution: Fixed Assignee: John Ross Looks like this was addressed in http://svn.apache.org/viewvc?view=revision&revision=1614343. > NPE thrown by GetBundleContextAction > ------------------------------------- > > Key: ARIES-1225 > URL: https://issues.apache.org/jira/browse/ARIES-1225 > Project: Aries > Issue Type: Improvement > Components: Subsystem > Affects Versions: subsystem-2.0.6, subsystem-2.0.8 > Reporter: Adam Pilkington > Assignee: John Ross > Priority: Trivial > Original Estimate: 10m > Remaining Estimate: 10m > > Hi, I'm currently investigating a NPE thrown by GetBundleContextAction - stack trace is below. > java.lang.NullPointerException > at org.apache.aries.subsystem.core.internal.GetBundleContextAction.run(GetBundleContextAction.java:35) > at org.apache.aries.subsystem.core.internal.GetBundleContextAction.run(GetBundleContextAction.java:22) > at java.security.AccessController.doPrivileged(AccessController.java:273) > at org.apache.aries.subsystem.core.internal.BasicSubsystem.getBundleContext(BasicSubsystem.java:186) > > > I don't know what has caused this, but looking at GetBundleContextAction, line 35 contains nested method invocations more than one of which can return null. I'd like to submit/suggest the following patch which just splits this line out and adds some basic error checking. > Index: GetBundleContextAction.java > =================================================================== > --- GetBundleContextAction.java (revision 1607078) > +++ GetBundleContextAction.java (working copy) > @@ -16,6 +16,8 @@ > import java.security.PrivilegedAction; > import java.util.EnumSet; > > +import org.eclipse.equinox.region.Region; > +import org.osgi.framework.Bundle; > import org.osgi.framework.BundleContext; > import org.osgi.service.subsystem.Subsystem.State; > > @@ -26,15 +28,23 @@ > this.subsystem = subsystem; > } > > - @Override > public BundleContext run() { > if (EnumSet.of(State.INSTALL_FAILED, State.UNINSTALLED).contains( > subsystem.getState())) > return null; > BasicSubsystem subsystem = Utils.findScopedSubsystemInRegion(this.subsystem); > - return subsystem.getRegion().getBundle( > - RegionContextBundleHelper.SYMBOLICNAME_PREFIX > - + subsystem.getSubsystemId(), > - RegionContextBundleHelper.VERSION).getBundleContext(); > + > + Region region = subsystem.getRegion(); > + if(region == null) { > + //can return null as under the covers it calls RegionDigraph.getRegion(name) > + return null; > + } > + Bundle bundle = region.getBundle(RegionContextBundleHelper.SYMBOLICNAME_PREFIX > + + subsystem.getSubsystemId(), RegionContextBundleHelper.VERSION); > + if(bundle == null) { > + //null if no such bundle > + return null; > + } > + return bundle.getBundleContext(); > } > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)