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 24978577cc
commit c1c5e3bdbb
4 changed files with 4 additions and 4 deletions

View File

@@ -265,7 +265,7 @@ public abstract class MongoDbFactorySupport<C> implements MongoDbFactory {
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()));
}
}

View File

@@ -233,7 +233,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()));
}
}
}

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

@@ -56,6 +56,6 @@ class QueryUtils {
return combinedSort;
});
return (Query) factory.getProxy();
return (Query) factory.getProxy(query.getClass().getClassLoader());
}
}