Compare commits

...

22 Commits

Author SHA1 Message Date
Mark Paluch
c7e4673e29 DATAMONGO-2532 - Release version 2.1.18 (Lovelace SR18). 2020-06-10 10:53:41 +02:00
Mark Paluch
9d694dbdd5 DATAMONGO-2532 - Prepare 2.1.18 (Lovelace SR18). 2020-06-10 10:53:13 +02:00
Mark Paluch
74179a9af9 DATAMONGO-2532 - Updated changelog. 2020-06-10 10:53:01 +02:00
Christoph Strobl
c1c5e3bdbb DATAMONGO-2547 - Use target class ClassLoader instead of default CL when creating proxy instances.
Original pull request: #865.
2020-05-26 08:55:47 +02:00
Greg Turnquist
24978577cc DATAMONGO-2535 - Remove Travis CI. 2020-05-04 15:09:31 -05:00
Mark Paluch
c43ae822be DATAMONGO-2503 - Updated changelog. 2020-04-28 15:12:26 +02:00
Mark Paluch
881a69864f DATAMONGO-2500 - Updated changelog. 2020-04-28 14:46:52 +02:00
Mark Paluch
dc054a793f DATAMONGO-2484 - After release cleanups. 2020-04-28 11:55:28 +02:00
Mark Paluch
f048fb6800 DATAMONGO-2484 - Prepare next development iteration. 2020-04-28 11:55:27 +02:00
Mark Paluch
20fdb0e63c DATAMONGO-2484 - Release version 2.1.17 (Lovelace SR17). 2020-04-28 11:32:50 +02:00
Mark Paluch
7e3ff86d36 DATAMONGO-2484 - Prepare 2.1.17 (Lovelace SR17). 2020-04-28 11:32:27 +02:00
Mark Paluch
54c9933535 DATAMONGO-2484 - Updated changelog. 2020-04-28 11:32:19 +02:00
Mark Paluch
1f07a3eb29 DATAMONGO-2529 - Ensure that MappingMongoConverter.read(…) is never called with null.
Previously, various methods attempted to pass a null argument as source for the converter. The API is non-null and implementations relying on these constraints were easily breakable.

We now make sure that the source is never null.
2020-04-23 15:25:51 +02:00
Mark Paluch
76f4328498 DATAMONGO-2492 - Updated changelog. 2020-03-31 15:08:50 +02:00
Mark Paluch
c572ca4e3b DATAMONGO-2485 - Updated changelog. 2020-03-25 10:59:48 +01:00
Christoph Strobl
f1d214b87d DATAMONGO-2300 - Polishing.
Move null check to event publishing logic.

Original Pull Request: #763
2020-03-23 10:12:48 +01:00
Heesu Jung
f4854a15f9 DATAMONGO-2300 - Add check rawType is null in readMap.
Original Pull Request: #763
2020-03-23 10:12:12 +01:00
Mark Paluch
b491d6ce81 DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor. 2020-03-19 15:37:42 +01:00
Jens Schauder
0b482f8dcf DATAMONGO-2473 - Updated changelog. 2020-03-11 09:59:32 +01:00
Mark Paluch
9f1b27c305 DATAMONGO-2453 - Updated changelog. 2020-02-26 11:55:06 +01:00
Mark Paluch
b6e69606b1 DATAMONGO-2452 - After release cleanups. 2020-02-26 11:25:51 +01:00
Mark Paluch
0429ea69fa DATAMONGO-2452 - Prepare next development iteration. 2020-02-26 11:25:50 +01:00
16 changed files with 156 additions and 64 deletions

View File

@@ -1,35 +0,0 @@
language: java
jdk:
- oraclejdk8
before_install:
- mkdir -p downloads
- mkdir -p var/db var/log
- if [[ ! -d downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION} ]] ; then cd downloads && wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}.tgz && tar xzf mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}.tgz && cd ..; fi
- downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongod --version
- downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongod --dbpath var/db --replSet rs0 --fork --logpath var/log/mongod.log
- sleep 10
- |-
downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongo --eval "rs.initiate({_id: 'rs0', members:[{_id: 0, host: '127.0.0.1:27017'}]});"
sleep 15
env:
matrix:
- PROFILE=ci
global:
- MONGO_VERSION=4.0.0
addons:
apt:
packages:
- oracle-java8-installer
sudo: false
cache:
directories:
- $HOME/.m2
- downloads
script: "mvn clean dependency:list test -P${PROFILE} -Dsort"

View File

@@ -5,7 +5,7 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.1.16.RELEASE</version>
<version>2.1.18.RELEASE</version>
<packaging>pom</packaging>
<name>Spring Data MongoDB</name>
@@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>2.1.16.RELEASE</version>
<version>2.1.18.RELEASE</version>
</parent>
<modules>
@@ -27,7 +27,7 @@
<properties>
<project.type>multi</project.type>
<dist.id>spring-data-mongodb</dist.id>
<springdata.commons>2.1.16.RELEASE</springdata.commons>
<springdata.commons>2.1.18.RELEASE</springdata.commons>
<mongo>3.8.2</mongo>
<mongo.reactivestreams>1.9.2</mongo.reactivestreams>
<jmh.version>1.19</jmh.version>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.1.16.RELEASE</version>
<version>2.1.18.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.1.16.RELEASE</version>
<version>2.1.18.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>2.1.16.RELEASE</version>
<version>2.1.18.RELEASE</version>
</dependency>
<!-- reactive -->

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.1.16.RELEASE</version>
<version>2.1.18.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.1.16.RELEASE</version>
<version>2.1.18.RELEASE</version>
<relativePath>../pom.xml</relativePath>
</parent>

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

@@ -3029,12 +3029,13 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Nullable
public T doWith(@Nullable Document object) {
T source = null;
if (null != object) {
maybeEmitEvent(new AfterLoadEvent<>(object, type, collectionName));
source = reader.read(type, object);
}
T source = reader.read(type, object);
if (null != source) {
maybeEmitEvent(new AfterConvertEvent<>(object, source, collectionName));
}
@@ -3074,9 +3075,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
Class<?> typeToRead = targetType.isInterface() || targetType.isAssignableFrom(entityType) ? entityType
: targetType;
if (null != object) {
maybeEmitEvent(new AfterLoadEvent<>(object, targetType, collectionName));
}
maybeEmitEvent(new AfterLoadEvent<>(object, targetType, collectionName));
Object source = reader.read(typeToRead, object);
Object result = targetType.isInterface() ? projectionFactory.createProjection(targetType, source) : source;

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

@@ -76,6 +76,7 @@ import com.mongodb.DBRef;
* @author Christoph Strobl
* @author Jordi Llach
* @author Mark Paluch
* @author Heesu Jung
*/
public class MappingMongoConverter extends AbstractMongoConverter implements ApplicationContextAware {
@@ -199,11 +200,9 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@Nullable
@SuppressWarnings("unchecked")
private <S extends Object> S read(TypeInformation<S> type, @Nullable Bson bson, ObjectPath path) {
private <S extends Object> S read(TypeInformation<S> type, Bson bson, ObjectPath path) {
if (null == bson) {
return null;
}
Assert.notNull(bson, "Bson must not be null!");
TypeInformation<? extends S> typeToUse = typeMapper.readType(bson, type);
Class<? extends S> rawType = typeToUse.getType();
@@ -1523,7 +1522,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@Nullable
private <T> T readAndConvertDBRef(@Nullable DBRef dbref, TypeInformation<?> type, ObjectPath path,
final Class<?> rawType) {
@Nullable Class<?> rawType) {
List<T> result = bulkReadAndConvertDBRefs(Collections.singletonList(dbref), type, path, rawType);
return CollectionUtils.isEmpty(result) ? null : result.iterator().next();
@@ -1546,7 +1545,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
@SuppressWarnings("unchecked")
private <T> List<T> bulkReadAndConvertDBRefs(List<DBRef> dbrefs, TypeInformation<?> type, ObjectPath path,
final Class<?> rawType) {
@Nullable Class<?> rawType) {
if (CollectionUtils.isEmpty(dbrefs)) {
return Collections.emptyList();
@@ -1561,16 +1560,19 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
for (Document document : referencedRawDocuments) {
T target = null;
if (document != null) {
maybeEmitEvent(new AfterLoadEvent<>(document, (Class<T>) rawType, collectionName));
}
final T target = (T) read(type, document, path);
targeList.add(target);
maybeEmitEvent(
new AfterLoadEvent<>(document, (Class<T>) (rawType != null ? rawType : Object.class), collectionName));
target = (T) read(type, document, path);
}
if (target != null) {
maybeEmitEvent(new AfterConvertEvent<>(document, target, collectionName));
}
targeList.add(target);
}
return targeList;

View File

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

View File

@@ -96,6 +96,7 @@ import com.mongodb.DBRef;
* @author Patrik Wasik
* @author Christoph Strobl
* @author Mark Paluch
* @author Heesu Jung
*/
@RunWith(MockitoJUnitRunner.class)
public class MappingMongoConverterUnitTests {
@@ -1938,6 +1939,23 @@ public class MappingMongoConverterUnitTests {
.isEqualTo(new BasicDBObject("property", "value"));
}
@Test // DATAMONGO-2300
public void readAndConvertDBRefNestedByMapCorrectly() {
org.bson.Document cluster = new org.bson.Document("_id", 100L);
DBRef dbRef = new DBRef("clusters", 100L);
org.bson.Document data = new org.bson.Document("_id", 3L);
data.append("cluster", dbRef);
MappingMongoConverter spyConverter = spy(converter);
Mockito.doReturn(cluster).when(spyConverter).readRef(dbRef);
Map<Object, Object> result = spyConverter.readMap(ClassTypeInformation.MAP, data, ObjectPath.ROOT);
assertThat(((LinkedHashMap) result.get("cluster")).get("_id")).isEqualTo(100L);
}
static class GenericType<T> {
T content;
}

View File

@@ -391,7 +391,7 @@ The MappingMongoConverter can use metadata to drive the mapping of objects to do
* `@GeoSpatialIndexed`: Applied at the field level to describe how to geoindex the field.
* `@TextIndexed`: Applied at the field level to mark the field to be included in the text index.
* `@Language`: Applied at the field level to set the language override property for text index.
* `@Transient`: By default all private fields are mapped to the document, this annotation excludes the field where it is applied from being stored in the database
* `@Transient`: By default, all fields are mapped to the document. This annotation excludes the field where it is applied from being stored in the database. Transient properties cannot be used within a persistence constructor as the converter cannot materialize a value for the constructor argument.
* `@PersistenceConstructor`: Marks a given constructor - even a package protected one - to use when instantiating the object from the database. Constructor arguments are mapped by name to the key values in the retrieved Document.
* `@Value`: This annotation is part of the Spring Framework . Within the mapping framework it can be applied to constructor arguments. This lets you use a Spring Expression Language statement to transform a key's value retrieved in the database before it is used to construct a domain object. In order to reference a property of a given document one has to use expressions like: `@Value("#root.myProperty")` where `root` refers to the root of the given document.
* `@Field`: Applied at the field level and described the name of the field as it will be represented in the MongoDB BSON document thus allowing the name to be different than the fieldname of the class.

View File

@@ -1,6 +1,104 @@
Spring Data MongoDB Changelog
=============================
Changes in version 2.1.18.RELEASE (2020-06-10)
----------------------------------------------
* DATAMONGO-2547 - java.lang.IllegalArgumentException: com.mongodb.client.MongoDatabase referenced from a method is not visible from class loader.
* DATAMONGO-2535 - Remove Travis CI.
* DATAMONGO-2532 - Release 2.1.18 (Lovelace SR18).
Changes in version 3.0.0.RC2 (2020-04-28)
-----------------------------------------
* DATAMONGO-2531 - Fix MongoClientSettings UUID configuration hook in MongoConfigurationSupport.
* DATAMONGO-2529 - EntityReader called with null argument.
* DATAMONGO-2523 - ParameterBindingJsonReader skips too many chars.
* DATAMONGO-2517 - Text search fails on entity with second constructor.
* DATAMONGO-2516 - Assert compatibility with MongoDB 4.4-rc0.
* DATAMONGO-2513 - ComparisonOperators.Eq#equalToValue doesn't work well with Lists.
* DATAMONGO-2510 - Use JDK 14 for Java.NEXT CI testing.
* DATAMONGO-2508 - Upgrade to MongoDB 4.0.2 Drivers.
* DATAMONGO-2507 - Add default method accepting CriteriaDefinition on ReactiveFindOperation.DistinctWithQuery.
* DATAMONGO-2506 - StringBasedAggregation should raise meaningful error when unsupported return type requested.
* DATAMONGO-2505 - Deferred Database retrieval from ReactiveMongoDatabaseFactory.
* DATAMONGO-2504 - TextCriteria Hashcode and equals.
* DATAMONGO-2503 - Release 3.0 RC2 (Neumann).
* DATAMONGO-2502 - Regression in Update property mapping.
Changes in version 2.2.7.RELEASE (2020-04-28)
---------------------------------------------
* DATAMONGO-2529 - EntityReader called with null argument.
* DATAMONGO-2523 - ParameterBindingJsonReader skips too many chars.
* DATAMONGO-2517 - Text search fails on entity with second constructor.
* DATAMONGO-2513 - ComparisonOperators.Eq#equalToValue doesn't work well with Lists.
* DATAMONGO-2506 - StringBasedAggregation should raise meaningful error when unsupported return type requested.
* DATAMONGO-2504 - TextCriteria Hashcode and equals.
* DATAMONGO-2502 - Regression in Update property mapping.
* DATAMONGO-2500 - Release 2.2.7 (Moore SR7).
Changes in version 2.1.17.RELEASE (2020-04-28)
----------------------------------------------
* DATAMONGO-2529 - EntityReader called with null argument.
* DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor.
* DATAMONGO-2484 - Release 2.1.17 (Lovelace SR17).
* DATAMONGO-2300 - Can't read and convert DBRef when the type is Map.
Changes in version 3.0.0.RC1 (2020-03-31)
-----------------------------------------
* DATAMONGO-2501 - Upgrade to Querydsl 4.3.
* DATAMONGO-2498 - Upgrade to MongoDB 4.0.1 Drivers.
* DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor.
* DATAMONGO-2492 - Release 3.0 RC1 (Neumann).
* DATAMONGO-2488 - KeyMapper.mapPropertyName does not work for nested arrays.
* DATAMONGO-2479 - More EntityCallback specializations.
* DATAMONGO-2477 - Disable auto-index creation by default.
* DATAMONGO-2475 - QueryDSL: $and and $or with more than two arguments in final query document.
* DATAMONGO-2416 - Add default methods accepting CriteriaDefinition on Fluent API.
* DATAMONGO-2300 - Can't read and convert DBRef when the type is Map.
* DATAMONGO-1026 - Joda, JSR-310 and ThreeTenBp converters are timezone-sensitive.
* DATAMONGO-931 - Add support for $redact operation.
* DATAMONGO-625 - GridFsOperations.createFile method should allow specification of _id.
Changes in version 2.2.6.RELEASE (2020-03-25)
---------------------------------------------
* DATAMONGO-2497 - Update documentation regarding @Transient properties usage in the persistence constructor.
* DATAMONGO-2488 - KeyMapper.mapPropertyName does not work for nested arrays.
* DATAMONGO-2485 - Release 2.2.6 (Moore SR6).
* DATAMONGO-2445 - Deprecate ReactiveGridFs methods using AsyncInputStream.
* DATAMONGO-2300 - Can't read and convert DBRef when the type is Map.
Changes in version 3.0.0.M4 (2020-03-11)
----------------------------------------
* DATAMONGO-2491 - Adapt to Mockito 3.3 changes.
* DATAMONGO-2489 - Upgrade to MongoDB Driver 4.0.
* DATAMONGO-2481 - Speed up build.
* DATAMONGO-2478 - NPE when using Query annotation and with sort and pageable.
* DATAMONGO-2476 - JsonParseException: JSON reader was expecting a value but found '}'.
* DATAMONGO-2474 - Upgrade to MongoDB Driver 4.0.0-rc0.
* DATAMONGO-2473 - Release 3.0 M4 (Neumann).
* DATAMONGO-2363 - Add support for $merge aggregation stage.
* DATAMONGO-2355 - Revise Abstract…MongoConfiguration to expose more bean detail and avoid proxying.
* DATAMONGO-2341 - Support shard key derivation.
Changes in version 2.2.5.RELEASE (2020-02-26)
---------------------------------------------
* DATAMONGO-2478 - NPE when using Query annotation and with sort and pageable.
* DATAMONGO-2476 - JsonParseException: JSON reader was expecting a value but found '}'.
* DATAMONGO-2464 - Fix code examples in reference documentation.
* DATAMONGO-2460 - @Field annotation behaviour changed.
* DATAMONGO-2459 - Update Documentation of Reactive Repositories to mention usage of PageRequest.
* DATAMONGO-2457 - Reference documentation: Text does not match with code example.
* DATAMONGO-2453 - Release 2.2.5 (Moore SR5).
* DATAMONGO-2406 - Allow Mono<Void> as return type for derived deleteBy queries.
* DATAMONGO-2079 - MappingMongoConverter cannot be proxied because it implements the package-private ValueResolver interface.
Changes in version 2.1.16.RELEASE (2020-02-26)
----------------------------------------------
* DATAMONGO-2464 - Fix code examples in reference documentation.
@@ -2921,3 +3019,11 @@ Repository

View File

@@ -1,4 +1,4 @@
Spring Data MongoDB 2.1.16
Spring Data MongoDB 2.1.18
Copyright (c) [2010-2019] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
@@ -11,3 +11,5 @@ conditions of the subcomponent's license, as noted in the LICENSE file.