@@ -228,36 +228,8 @@ public String parseAndCollectParameterBindingsFromQueryIntoBindings(String input
228
228
String transformedInput = transformQueryAndCollectExpressionParametersIntoBindings (input , bindings );
229
229
String parseableInput = makeParameterReferencesParseable (transformedInput );
230
230
231
- collectParameterReferencesIntoBindings (bindings , JSON .parse (parseableInput , new JSONCallback () {
232
-
233
- /*
234
- * (non-Javadoc)
235
- * @see com.mongodb.util.JSONCallback#objectDone()
236
- */
237
- @ Override
238
- public Object objectDone () {
239
- return exceptionSwallowingStackReducingObjectDone ();
240
- }
241
-
242
- private Object exceptionSwallowingStackReducingObjectDone /*CauseWeJustNeedTheStructureNotTheActualValue*/ () {
243
-
244
- Object value ;
245
-
246
- try {
247
- return super .objectDone ();
248
- } catch (PatternSyntaxException e ) {
249
- value = Pattern .compile ("" );
250
- }
251
-
252
- if (!isStackEmpty ()) {
253
- _put (curName (), value );
254
- } else {
255
- value = !BSON .hasDecodeHooks () ? value : BSON .applyDecodingHooks (value );
256
- setRoot (value );
257
- }
258
- return value ;
259
- }
260
- }));
231
+ collectParameterReferencesIntoBindings (bindings ,
232
+ JSON .parse (parseableInput , new LenientPatternDecodingCallback ()));
261
233
262
234
return transformedInput ;
263
235
}
@@ -392,6 +364,43 @@ private static int getIndexOfExpressionParameter(String input, int position) {
392
364
}
393
365
}
394
366
367
+ /**
368
+ * {@link JSONCallback} with lenient handling for {@link PatternSyntaxException} falling back to a placeholder
369
+ * {@link Pattern} for intermediate query document rendering.
370
+ */
371
+ private static class LenientPatternDecodingCallback extends JSONCallback {
372
+
373
+ private static final Pattern EMPTY_MARKER = Pattern .compile ("__Spring_Data_MongoDB_Bind_Marker__" );
374
+
375
+ /*
376
+ * (non-Javadoc)
377
+ * @see com.mongodb.util.JSONCallback#objectDone()
378
+ */
379
+ @ Override
380
+ public Object objectDone () {
381
+ return exceptionSwallowingStackReducingObjectDone ();
382
+ }
383
+
384
+ private Object exceptionSwallowingStackReducingObjectDone /*CauseWeJustNeedTheStructureNotTheActualValue*/ () {
385
+
386
+ Object value ;
387
+
388
+ try {
389
+ return super .objectDone ();
390
+ } catch (PatternSyntaxException e ) {
391
+ value = EMPTY_MARKER ;
392
+ }
393
+
394
+ if (!isStackEmpty ()) {
395
+ _put (curName (), value );
396
+ } else {
397
+ value = !BSON .hasDecodeHooks () ? value : BSON .applyDecodingHooks (value );
398
+ setRoot (value );
399
+ }
400
+ return value ;
401
+ }
402
+ }
403
+
395
404
/**
396
405
* A generic parameter binding with name or position information.
397
406
*
0 commit comments