Skip to content

Commit

Permalink
fix: use proper classloader for template model (#11379)
Browse files Browse the repository at this point in the history
fixes #7377
  • Loading branch information
Denis committed Jul 8, 2021
1 parent 6a63c04 commit 2aeefe3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
Expand All @@ -28,6 +29,7 @@
import net.bytebuddy.description.type.TypeDescription.Generic;
import net.bytebuddy.dynamic.DynamicType.Builder;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.dynamic.loading.MultipleParentClassLoader;
import net.bytebuddy.implementation.FieldAccessor;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
Expand Down Expand Up @@ -254,7 +256,12 @@ private static BiFunction<StateNode, BeanModelType<?>, Object> createProxyConstr

// Create the class
.name(proxyClassName).make()
.load(classLoader, ClassLoadingStrategy.Default.WRAPPER)
// In an OSGi Context we need two classloaders. The one from the
// Bundle that calls this ("classloader") + the Classloader
// the TemplateModelProxyHandler
.load(new MultipleParentClassLoader(Arrays.asList(classLoader,
TemplateModelProxyHandler.class.getClassLoader())),
ClassLoadingStrategy.Default.WRAPPER)
.getLoaded();

return (node, modelType) -> {
Expand Down

0 comments on commit 2aeefe3

Please sign in to comment.