Skip to content

Commit 754c183

Browse files
christophstroblmp911de
authored andcommitted
tmp save
..:: GAME OVER ::.. continue from last save point? [y/n]
1 parent 41a3fe1 commit 754c183

File tree

69 files changed

+355
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+355
-198
lines changed

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/BulkOperationException.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.List;
1919

20+
import org.jspecify.annotations.Nullable;
2021
import org.springframework.dao.DataAccessException;
2122

2223
import com.mongodb.MongoBulkWriteException;
@@ -43,7 +44,7 @@ public class BulkOperationException extends DataAccessException {
4344
* @param message must not be {@literal null}.
4445
* @param source must not be {@literal null}.
4546
*/
46-
public BulkOperationException(String message, MongoBulkWriteException source) {
47+
public BulkOperationException(@Nullable String message, MongoBulkWriteException source) {
4748

4849
super(message, source);
4950

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public CollectionOptions collation(@Nullable Collation collation) {
184184
* @since 2.1
185185
*/
186186
public CollectionOptions schema(@Nullable MongoJsonSchema schema) {
187-
return validator(Validator.schema(schema));
187+
return validator(schema != null ? Validator.schema(schema) : null);
188188
}
189189

190190
/**

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionPreparerSupport.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
import java.util.function.BiFunction;
2121
import java.util.function.Function;
2222

23+
import jakarta.validation.constraints.Null;
2324
import org.bson.Document;
2425

2526
import com.mongodb.ReadConcern;
2627
import com.mongodb.ReadPreference;
2728
import com.mongodb.client.MongoCollection;
29+
import org.jspecify.annotations.Nullable;
2830

2931
/**
3032
* Support class for delegate implementations to apply {@link ReadConcern} and {@link ReadPreference} settings upon
@@ -84,7 +86,7 @@ public boolean hasReadConcern() {
8486
}
8587

8688
@Override
87-
public ReadConcern getReadConcern() {
89+
public @Nullable ReadConcern getReadConcern() {
8890

8991
for (Object aware : sources) {
9092
if (aware instanceof ReadConcernAware rca && rca.hasReadConcern()) {
@@ -108,7 +110,7 @@ public boolean hasReadPreference() {
108110
}
109111

110112
@Override
111-
public ReadPreference getReadPreference() {
113+
public @Nullable ReadPreference getReadPreference() {
112114

113115
for (Object aware : sources) {
114116
if (aware instanceof ReadPreferenceAware rpa && rpa.hasReadPreference()) {

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultBulkOperations.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public boolean skipEventPublishing() {
412412
return eventPublisher == null;
413413
}
414414

415-
@SuppressWarnings("rawtypes")
415+
@SuppressWarnings({"rawtypes","NullAway"})
416416
public <T> T callback(Class<? extends EntityCallback> callbackType, T entity, String collectionName) {
417417

418418
if (skipEntityCallbacks()) {
@@ -422,7 +422,7 @@ public <T> T callback(Class<? extends EntityCallback> callbackType, T entity, St
422422
return entityCallbacks.callback(callbackType, entity, collectionName);
423423
}
424424

425-
@SuppressWarnings("rawtypes")
425+
@SuppressWarnings({"rawtypes","NullAway"})
426426
public <T> T callback(Class<? extends EntityCallback> callbackType, T entity, Document document,
427427
String collectionName) {
428428

@@ -433,6 +433,7 @@ public <T> T callback(Class<? extends EntityCallback> callbackType, T entity, Do
433433
return entityCallbacks.callback(callbackType, entity, document, collectionName);
434434
}
435435

436+
@SuppressWarnings("NullAway")
436437
public void publishEvent(ApplicationEvent event) {
437438

438439
if (skipEventPublishing()) {

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/EntityOperations.java

+16-10
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
import java.util.concurrent.TimeUnit;
2525

2626
import org.bson.BsonNull;
27+
import org.bson.BsonValue;
2728
import org.bson.Document;
2829
import org.jspecify.annotations.Nullable;
2930
import org.springframework.core.convert.ConversionService;
3031
import org.springframework.core.env.Environment;
3132
import org.springframework.core.env.EnvironmentCapable;
33+
import org.springframework.core.env.StandardEnvironment;
3234
import org.springframework.dao.InvalidDataAccessApiUsageException;
3335
import org.springframework.data.convert.CustomConversions;
3436
import org.springframework.data.expression.ValueEvaluationContext;
@@ -64,6 +66,7 @@
6466
import org.springframework.data.projection.TargetAware;
6567
import org.springframework.data.util.Optionals;
6668
import org.springframework.expression.spel.support.SimpleEvaluationContext;
69+
import org.springframework.lang.Contract;
6770
import org.springframework.util.Assert;
6871
import org.springframework.util.ClassUtils;
6972
import org.springframework.util.LinkedMultiValueMap;
@@ -413,7 +416,7 @@ interface Entity<T> {
413416
*
414417
* @return
415418
*/
416-
Object getId();
419+
@Nullable Object getId();
417420

418421
/**
419422
* Returns the property value for {@code key}.
@@ -521,7 +524,7 @@ interface AdaptibleEntity<T> extends Entity<T> {
521524
* @param id must not be {@literal null}.
522525
* @return
523526
*/
524-
@Nullable
527+
@Contract("null -> fail")
525528
T populateIdIfNecessary(@Nullable Object id);
526529

527530
/**
@@ -564,12 +567,12 @@ public String getIdFieldName() {
564567
}
565568

566569
@Override
567-
public Object getId() {
570+
public @Nullable Object getId() {
568571
return getPropertyValue(ID_FIELD);
569572
}
570573

571574
@Override
572-
public Object getPropertyValue(String key) {
575+
public @Nullable Object getPropertyValue(String key) {
573576
return map.get(key);
574577
}
575578

@@ -579,7 +582,7 @@ public Query getByIdQuery() {
579582
}
580583

581584
@Override
582-
public @Nullable T populateIdIfNecessary(@Nullable Object id) {
585+
public T populateIdIfNecessary(@Nullable Object id) {
583586

584587
map.put(ID_FIELD, id);
585588

@@ -721,7 +724,7 @@ public Object getId() {
721724
}
722725

723726
@Override
724-
public Object getPropertyValue(String key) {
727+
public @Nullable Object getPropertyValue(String key) {
725728
return propertyAccessor.getProperty(entity.getRequiredPersistentProperty(key));
726729
}
727730

@@ -836,7 +839,6 @@ public Map<String, Object> extractKeys(Document sortObject, Class<?> sourceType)
836839
return keyset;
837840
}
838841

839-
@Nullable
840842
private Object getNestedPropertyValue(String key) {
841843

842844
String[] segments = key.split("\\.");
@@ -849,6 +851,10 @@ private Object getNestedPropertyValue(String key) {
849851
currentValue = currentEntity.getPropertyValue(segment);
850852

851853
if (i < segments.length - 1) {
854+
if(currentValue == null) {
855+
return BsonNull.VALUE;
856+
}
857+
852858
currentEntity = entityOperations.forEntity(currentValue);
853859
}
854860
}
@@ -886,7 +892,7 @@ private static <T> AdaptibleEntity<T> of(T bean,
886892
}
887893

888894
@Override
889-
public @Nullable T populateIdIfNecessary(@Nullable Object id) {
895+
public T populateIdIfNecessary(@Nullable Object id) {
890896

891897
if (id == null) {
892898
return propertyAccessor.getBean();
@@ -1122,7 +1128,7 @@ public TimeSeriesOptions mapTimeSeriesOptions(TimeSeriesOptions source) {
11221128

11231129
@Override
11241130
public String getIdKeyName() {
1125-
return entity.getIdProperty().getName();
1131+
return entity.getIdProperty() != null ? entity.getIdProperty().getName() : ID_FIELD;
11261132
}
11271133

11281134
private String mappedNameOrDefault(String name) {
@@ -1142,7 +1148,7 @@ private ValueEvaluationContext getEvaluationContextForEntity(@Nullable Persisten
11421148
return mongoEntity.getValueEvaluationContext(null);
11431149
}
11441150

1145-
return ValueEvaluationContext.of(this.environment, SimpleEvaluationContext.forReadOnlyDataBinding().build());
1151+
return ValueEvaluationContext.of(this.environment != null ? this.environment : new StandardEnvironment(), SimpleEvaluationContext.forReadOnlyDataBinding().build());
11461152
}
11471153

11481154
/**

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MappedDocument.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.bson.Document;
2222
import org.bson.conversions.Bson;
23+
import org.jspecify.annotations.Nullable;
2324
import org.springframework.data.mongodb.core.mapping.FieldName;
2425
import org.springframework.data.mongodb.core.query.Update;
2526
import org.springframework.data.mongodb.core.query.UpdateDefinition;
@@ -70,7 +71,7 @@ public boolean hasNonNullId() {
7071
return hasId() && document.get(ID_FIELD) != null;
7172
}
7273

73-
public Object getId() {
74+
public @Nullable Object getId() {
7475
return document.get(ID_FIELD);
7576
}
7677

@@ -86,7 +87,7 @@ public Bson getIdFilter() {
8687
return new Document(ID_FIELD, document.get(ID_FIELD));
8788
}
8889

89-
public Object get(String key) {
90+
public @Nullable Object get(String key) {
9091
return document.get(key);
9192
}
9293

0 commit comments

Comments
 (0)