DATAMONGO-1317 - Assert compatibility with mongo-java-driver 3.2.
We now do a defensive check against the actual WObject of WriteConcern to avoid the IllegalStateException raised by the new java-driver in case _w is null or not an Integer. This allows us to run against recent 2.13, 2.14, 3.0, 3.1 and the latest 3.2.0. Original pull request: #337.
This commit is contained in:
committed by
Oliver Gierke
parent
3e5b4f25a4
commit
704c130d94
@@ -774,11 +774,17 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
|
|||||||
protected WriteConcern prepareWriteConcern(MongoAction mongoAction) {
|
protected WriteConcern prepareWriteConcern(MongoAction mongoAction) {
|
||||||
|
|
||||||
WriteConcern wc = writeConcernResolver.resolve(mongoAction);
|
WriteConcern wc = writeConcernResolver.resolve(mongoAction);
|
||||||
|
return potentiallyForceAcknowledgedWrite(wc);
|
||||||
|
}
|
||||||
|
|
||||||
if (MongoClientVersion.isMongo3Driver()
|
private WriteConcern potentiallyForceAcknowledgedWrite(WriteConcern wc) {
|
||||||
&& ObjectUtils.nullSafeEquals(WriteResultChecking.EXCEPTION, writeResultChecking)
|
|
||||||
&& (wc == null || wc.getW() < 1)) {
|
if (ObjectUtils.nullSafeEquals(WriteResultChecking.EXCEPTION, writeResultChecking)
|
||||||
return WriteConcern.ACKNOWLEDGED;
|
&& MongoClientVersion.isMongo3Driver()) {
|
||||||
|
if (wc == null || wc.getWObject() == null
|
||||||
|
|| (wc.getWObject() instanceof Number && ((Number) wc.getWObject()).intValue() < 1)) {
|
||||||
|
return WriteConcern.ACKNOWLEDGED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return wc;
|
return wc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user