Repository: jclouds Updated Branches: refs/heads/1.9.x a28ebee39 -> c79b23559
Fix autovalue class loading in karaf When Class.forName is called for a class in a different bundle it will fail as the default karaf class loader won't load classes from other bundles. I have fixed this by using the classloader of the original (non-autovalue) type and assuming it will be in the same bundle as the autovalue type (I think this is a reasonable assumtion). So far the only place where I've actually seen this being an issue is when using the jclouds-labs-google provider within karaf. It fails when serialising the Firewall.Rule class within a FirewallOptions object. Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/c79b2355 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/c79b2355 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/c79b2355 Branch: refs/heads/1.9.x Commit: c79b23559421ebb78ac03428b305ebe45e7abda9 Parents: a28ebee Author: Duncan Grant <[email protected]> Authored: Mon Sep 5 09:40:48 2016 +0100 Committer: Ignasi Barrera <[email protected]> Committed: Mon Sep 5 14:23:27 2016 +0200 ---------------------------------------------------------------------- .../DeserializationConstructorAndReflectiveTypeAdapterFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/c79b2355/core/src/main/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactory.java b/core/src/main/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactory.java index de985fd..eff6c9d 100644 --- a/core/src/main/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactory.java +++ b/core/src/main/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactory.java @@ -132,7 +132,7 @@ public final class DeserializationConstructorAndReflectiveTypeAdapterFactory imp String autoClassName = type.getRawType().getName().replace('$', '_') .replace(packageName + ".", packageName + ".AutoValue_"); try { - type = (TypeToken<T>) TypeToken.get(Class.forName(autoClassName)); + type = (TypeToken<T>) TypeToken.get(type.getRawType().getClassLoader().loadClass(autoClassName)); } catch (ClassNotFoundException ignored) { } }
