Skip to content

Commit b577877

Browse files
committed
DATAMONGO-2545 - Polishing.
Fix warnings and typos. Original pull request: #864.
1 parent 0f55fb3 commit b577877

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/ParameterBindingDocumentCodec.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public Document decode(@Nullable String json, ParameterBindingContext bindingCon
176176
return this.decode(reader, DecoderContext.builder().build());
177177
}
178178

179+
@SuppressWarnings({ "rawtypes", "unchecked" })
179180
@Override
180181
public Document decode(final BsonReader reader, final DecoderContext decoderContext) {
181182

@@ -203,12 +204,13 @@ public Document decode(final BsonReader reader, final DecoderContext decoderCont
203204
try {
204205

205206
Object value = readValue(reader, decoderContext);
206-
if (value instanceof Map) {
207+
if (value instanceof Map<?, ?>) {
207208
if (!((Map) value).isEmpty()) {
208-
return new Document((Map) value);
209+
return new Document((Map<String, Object>) value);
209210
}
210211
}
211212
} catch (Exception ex) {
213+
e.addSuppressed(ex);
212214
throw e;
213215
}
214216
}

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/util/json/ParameterBindingJsonReaderUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void shouldABindArgumentsViaIndexInSpelExpressions() {
299299
}
300300

301301
@Test // DATAMONGO-2545
302-
void shouldAllowMethodArgumentPlaceholdersInQuotedSpelExpressions/*becuase this worked before*/() {
302+
void shouldAllowMethodArgumentPlaceholdersInQuotedSpelExpressions/*because this worked before*/() {
303303

304304
Object[] args = new Object[] { "yess", "nooo" };
305305
StandardEvaluationContext evaluationContext = (StandardEvaluationContext) EvaluationContextProvider.DEFAULT
@@ -322,15 +322,15 @@ void evaluatesSpelExpressionDefiningEntireQuery() {
322322
evaluationContext.setRootObject(new DummySecurityObject(new DummyWithId("wonderwoman")));
323323

324324
String json = "?#{ T(" + this.getClass().getName()
325-
+ ").isBatman() ? {'_class': { '$eq' : 'region' }} : { '$and' : { {'_class': { '$eq' : 'region' } }, {'user.superviser': principal.id } } } }";
325+
+ ").isBatman() ? {'_class': { '$eq' : 'region' }} : { '$and' : { {'_class': { '$eq' : 'region' } }, {'user.supervisor': principal.id } } } }";
326326

327327
ParameterBindingJsonReader reader = new ParameterBindingJsonReader(json,
328328
new ParameterBindingContext((index) -> args[index], new SpelExpressionParser(), evaluationContext));
329329
Document target = new ParameterBindingDocumentCodec().decode(reader, DecoderContext.builder().build());
330330

331331
assertThat(target)
332332
.isEqualTo(new Document("$and", Arrays.asList(new Document("_class", new Document("$eq", "region")),
333-
new Document("user.superviser", "wonderwoman"))));
333+
new Document("user.supervisor", "wonderwoman"))));
334334
}
335335

336336
private static Document parse(String json, Object... args) {

0 commit comments

Comments
 (0)