DATAMONGO-2547 - Use target class ClassLoader instead of default CL when creating proxy instances.

Original pull request: #865.
This commit is contained in:
Christoph Strobl
2020-05-14 10:51:22 +02:00
committed by Mark Paluch
parent 8b50778350
commit af39b422b6
4 changed files with 4 additions and 4 deletions

View File

@@ -257,7 +257,7 @@ public abstract class MongoDatabaseFactorySupport<C> implements MongoDatabaseFac
factory.addAdvice(new SessionAwareMethodInterceptor<>(session, target, ClientSession.class, MongoDatabase.class,
this::proxyDatabase, MongoCollection.class, this::proxyCollection));
return targetType.cast(factory.getProxy());
return targetType.cast(factory.getProxy(target.getClass().getClassLoader()));
}
public ClientSession getSession() {

View File

@@ -271,7 +271,7 @@ public class SimpleReactiveMongoDatabaseFactory implements DisposableBean, React
factory.addAdvice(new SessionAwareMethodInterceptor<>(session, target, ClientSession.class, MongoDatabase.class,
this::proxyDatabase, MongoCollection.class, this::proxyCollection));
return targetType.cast(factory.getProxy());
return targetType.cast(factory.getProxy(target.getClass().getClassLoader()));
}
public ClientSession getSession() {

View File

@@ -202,7 +202,7 @@ public class DefaultDbRefResolver implements DbRefResolver {
proxyFactory.addInterface(propertyType);
proxyFactory.addAdvice(interceptor);
return handler.populateId(property, dbref, proxyFactory.getProxy());
return handler.populateId(property, dbref, proxyFactory.getProxy(LazyLoadingProxy.class.getClassLoader()));
}
/**

View File

@@ -61,7 +61,7 @@ class QueryUtils {
return combinedSort;
});
return (Query) factory.getProxy();
return (Query) factory.getProxy(query.getClass().getClassLoader());
}
/**