Skip to content

Commit 699a7a0

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 16d55c8 commit 699a7a0

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
@@ -242,7 +242,7 @@ private <T> T createProxyInstance(com.mongodb.session.ClientSession session, T t
242242
factory.addAdvice(new SessionAwareMethodInterceptor<>(session, target, ClientSession.class, MongoDatabase.class,
243243
this::proxyDatabase, MongoCollection.class, this::proxyCollection));
244244

245-
return targetType.cast(factory.getProxy());
245+
return targetType.cast(factory.getProxy(target.getClass().getClassLoader()));
246246
}
247247
}
248248
}

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
@@ -61,7 +61,7 @@ static Query decorateSort(Query query, Document defaultSort) {
6161
return combinedSort;
6262
});
6363

64-
return (Query) factory.getProxy();
64+
return (Query) factory.getProxy(query.getClass().getClassLoader());
6565
}
6666

6767
/**

0 commit comments

Comments
 (0)