From: Mathieu Baudier Date: Thu, 28 Jun 2012 14:54:03 +0000 (+0000) Subject: Make isSpringInstrumented test safer X-Git-Tag: argeo-slc-2.1.7~683 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=0bcd250a018411af9bef57e93b859df7d76ec98e;p=gpl%2Fargeo-slc.git Make isSpringInstrumented test safer git-svn-id: https://svn.argeo.org/slc/trunk@5390 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java index 58ae32a65..4ae06f8b3 100644 --- a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java +++ b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java @@ -292,10 +292,7 @@ public class OsgiExecutionModulesManager extends Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle( nameVersion)); bundlesManager.startSynchronous(bundle); - boolean isSpringInstrumented = bundle.getEntryPaths( - "/META-INF/spring").hasMoreElements() - || bundle.getHeaders().get("Spring-Context") == null; - if (isSpringInstrumented) { + if (isSpringInstrumented(bundle)) { // Wait for Spring application context to be ready String filter = "(Bundle-SymbolicName=" + bundle.getSymbolicName() + ")"; @@ -313,6 +310,18 @@ public class OsgiExecutionModulesManager extends } } + /** Do it calmly in order to avoid NPE */ + private Boolean isSpringInstrumented(Bundle bundle) { + Dictionary headers = bundle.getHeaders(); + if (headers != null && headers.get("Spring-Context") != null) + return true; + Enumeration springEntryPaths = bundle + .getEntryPaths("/META-INF/spring"); + if (springEntryPaths != null && springEntryPaths.hasMoreElements()) + return true; + return false; + } + public void stop(NameVersion nameVersion) { try { Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(