Skip to content

Commit c1c5e3b

Browse files
christophstroblmp911de
authored andcommitted
DATAMONGO-2547 - Use target class ClassLoader instead of default CL when creating proxy instances.
Original pull request: #865.
1 parent 2497857 commit c1c5e3b

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDbFactorySupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private <T> T createProxyInstance(com.mongodb.session.ClientSession session, T t
265265
factory.addAdvice(new SessionAwareMethodInterceptor<>(session, target, ClientSession.class, MongoDatabase.class,
266266
this::proxyDatabase, MongoCollection.class, this::proxyCollection));
267267

268-
return targetType.cast(factory.getProxy());
268+
return targetType.cast(factory.getProxy(target.getClass().getClassLoader()));
269269
}
270270
}
271271

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/SimpleReactiveMongoDatabaseFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private <T> T createProxyInstance(com.mongodb.session.ClientSession session, T t
233233
factory.addAdvice(new SessionAwareMethodInterceptor<>(session, target, ClientSession.class, MongoDatabase.class,
234234
this::proxyDatabase, MongoCollection.class, this::proxyCollection));
235235

236-
return targetType.cast(factory.getProxy());
236+
return targetType.cast(factory.getProxy(target.getClass().getClassLoader()));
237237
}
238238
}
239239
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultDbRefResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private Object createLazyLoadingProxy(MongoPersistentProperty property, @Nullabl
202202
proxyFactory.addInterface(propertyType);
203203
proxyFactory.addAdvice(interceptor);
204204

205-
return handler.populateId(property, dbref, proxyFactory.getProxy());
205+
return handler.populateId(property, dbref, proxyFactory.getProxy(LazyLoadingProxy.class.getClassLoader()));
206206
}
207207

208208
/**

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/QueryUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ static Query decorateSort(Query query, Document defaultSort) {
5656
return combinedSort;
5757
});
5858

59-
return (Query) factory.getProxy();
59+
return (Query) factory.getProxy(query.getClass().getClassLoader());
6060
}
6161
}

0 commit comments

Comments
 (0)