You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/10/03 09:46:38 UTC
[1/2] camel git commit: Avoid potential NPE such as when using
camel-test-blueprint
Repository: camel
Updated Branches:
refs/heads/master 0f5e3afb4 -> d5f0aefdf
Avoid potential NPE such as when using camel-test-blueprint
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec464604
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec464604
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec464604
Branch: refs/heads/master
Commit: ec464604b0f9f9dc01b3821a3c6f83ea1769b204
Parents: 0f5e3af
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 3 09:30:28 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 3 09:30:28 2015 +0200
----------------------------------------------------------------------
.../main/java/org/apache/camel/impl/osgi/Activator.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ec464604/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
index f0e584c..e7d3da3 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
@@ -242,11 +242,13 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer {
return true;
}
BundleCapability packageCap = packageCapabilities.get(clazz.getPackage().getName());
- BundleWiring wiring = bundle.adapt(BundleWiring.class);
- List<BundleWire> imports = wiring.getRequiredWires(PACKAGE_NAMESPACE);
- for (BundleWire importWire : imports) {
- if (packageCap.equals(importWire.getCapability())) {
- return true;
+ if (packageCap != null) {
+ BundleWiring wiring = bundle.adapt(BundleWiring.class);
+ List<BundleWire> imports = wiring.getRequiredWires(PACKAGE_NAMESPACE);
+ for (BundleWire importWire : imports) {
+ if (packageCap.equals(importWire.getCapability())) {
+ return true;
+ }
}
}
return false;
[2/2] camel git commit: CAMEL-9144: Fixed Camel Activtor not being
able to detect Camel dataformats (likely also languages/components) when
using camel-test-blueprint. Have to use the old checkCompact method for that.
Posted by da...@apache.org.
CAMEL-9144: Fixed Camel Activtor not being able to detect Camel dataformats (likely also languages/components) when using camel-test-blueprint. Have to use the old checkCompact method for that.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d5f0aefd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d5f0aefd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d5f0aefd
Branch: refs/heads/master
Commit: d5f0aefdffc74ac0971b87946a21fe4be8c305b4
Parents: ec46460
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 3 09:39:23 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 3 09:39:23 2015 +0200
----------------------------------------------------------------------
.../org/apache/camel/impl/osgi/Activator.java | 25 ++++++++++++++++++++
1 file changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d5f0aefd/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
index e7d3da3..2071912 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
@@ -251,9 +251,34 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer {
}
}
}
+
+ // it may be running outside real OSGi container such as when unit testing with camel-test-blueprint
+ // then we need to use a different canSee algorithm that works outside real OSGi
+ if (bundle.getBundleId() > 0) {
+ Bundle root = bundle.getBundleContext().getBundle(0);
+ if (root != null && "org.apache.felix.connect".equals(root.getSymbolicName())) {
+ return checkCompat(bundle, clazz);
+ }
+ }
+
return false;
}
+ /**
+ * Check if bundle can see the given class used by camel-test-blueprint
+ */
+ protected static boolean checkCompat(Bundle bundle, Class<?> clazz) {
+ // Check bundle compatibility
+ try {
+ if (bundle.loadClass(clazz.getName()) != clazz) {
+ return false;
+ }
+ } catch (Throwable t) {
+ return false;
+ }
+ return true;
+ }
+
protected static class BundleComponentResolver extends BaseResolver<Component> implements ComponentResolver {
private final Map<String, String> components;